28 if (metal_buffer_ !=
nullptr) {
29 metal_buffer_->free();
30 metal_buffer_ =
nullptr;
39 if (slot.
bound && slot.
ubo ==
this) {
48 ssbo_wrapper_ =
nullptr;
60 if (metal_buffer_ !=
nullptr) {
61 metal_buffer_->free();
62 metal_buffer_ =
nullptr;
80 static std::atomic<int> global_counter = 0;
81 int index = global_counter.fetch_add(1);
82 metal_buffer_->set_label([NSString stringWithFormat:
@"UBO %i %s",
index,
name_]);
86 BLI_assert(metal_buffer_->get_metal_buffer() != nil);
100 MTL_LOG_WARNING(
"Failed to bind UBO %p. uniform location %d invalid.",
this, slot);
111 ctx_ubo_bind_slot.
ubo =
this;
112 ctx_ubo_bind_slot.
bound =
true;
118 if (
data_ !=
nullptr) {
120 MEM_SAFE_DELETE_VOID(
data_);
124 if (metal_buffer_ ==
nullptr) {
132 MTL_LOG_WARNING(
"Failed to bind UBO %p as SSBO. uniform location %d invalid.",
this, slot);
138 if (metal_buffer_ ==
nullptr) {
140 if (
data_ !=
nullptr) {
142 MEM_SAFE_DELETE_VOID(
data_);
150 if (ssbo_wrapper_ ==
nullptr) {
154 ssbo_wrapper_->bind(slot);
168 if (bound_ctx_ !=
nullptr && bind_slot_ > -1) {
170 bound_ctx_->pipeline_state.ubo_bindings[bind_slot_];
171 if (ctx_ubo_bind_slot.
bound && ctx_ubo_bind_slot.
ubo ==
this) {
172 ctx_ubo_bind_slot.
bound =
false;
173 ctx_ubo_bind_slot.
ubo =
nullptr;
180 bound_ctx_ =
nullptr;
186 if (metal_buffer_ !=
nullptr) {
187 metal_buffer_->debug_ensure_used();
188 return metal_buffer_->get_metal_buffer();
#define UNUSED_VARS_NDEBUG(...)
gpu::MTLBuffer * allocate_with_data(uint64_t size, bool cpu_visible, const void *data=nullptr)
gpu::MTLBuffer * allocate(uint64_t size, bool cpu_visible)
static MTLContext * get()
MTLContextGlobalShaderPipelineState pipeline_state
static MTLBufferPool * get_global_memory_manager()
MTLStorageBuf(size_t size, GPUUsageType usage, const char *name)
#define MTL_MAX_BUFFER_BINDINGS
#define MTL_LOG_WARNING(info,...)
void free(Subdiv *subdiv)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BMesh const char void * data
std::array< MTLUniformBufferBinding, MTL_MAX_UBO > ubo_bindings