diff --git a/source/blender/compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc b/source/blender/compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc index 00981243110..529628cb556 100644 --- a/source/blender/compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc +++ b/source/blender/compositor/cached_resources/intern/ocio_color_space_conversion_shader.cc @@ -344,7 +344,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { } for (auto item : float_buffers_.items()) { - GPUUniformBuf *buffer = GPU_uniformbuf_create_ex( + gpu::UniformBuf *buffer = GPU_uniformbuf_create_ex( buffers_sizes_.lookup(item.key)(), item.value(), item.key.c_str()); const int ubo_location = GPU_shader_get_ubo_binding(shader_, item.key.c_str()); GPU_uniformbuf_bind(buffer, ubo_location); @@ -352,7 +352,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { } for (auto item : int_buffers_.items()) { - GPUUniformBuf *buffer = GPU_uniformbuf_create_ex( + gpu::UniformBuf *buffer = GPU_uniformbuf_create_ex( buffers_sizes_.lookup(item.key)(), item.value(), item.key.c_str()); const int ubo_location = GPU_shader_get_ubo_binding(shader_, item.key.c_str()); GPU_uniformbuf_bind(buffer, ubo_location); @@ -369,7 +369,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { void unbind_shader_and_resources() { - for (GPUUniformBuf *buffer : uniform_buffers_) { + for (gpu::UniformBuf *buffer : uniform_buffers_) { GPU_uniformbuf_unbind(buffer); GPU_uniformbuf_free(buffer); } @@ -437,7 +437,7 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator { /* A vectors that stores the created uniform buffers when bind_shader_and_resources() is called, * so that they can be properly unbound and freed in the unbind_shader_and_resources() method. */ - Vector uniform_buffers_; + Vector uniform_buffers_; # if OCIO_VERSION_HEX >= 0x02030000 /* Allow creating 1D textures, or only use 2D textures. */ diff --git a/source/blender/compositor/intern/shader_operation.cc b/source/blender/compositor/intern/shader_operation.cc index 7431eaf7658..fb97781b06c 100644 --- a/source/blender/compositor/intern/shader_operation.cc +++ b/source/blender/compositor/intern/shader_operation.cc @@ -80,7 +80,7 @@ void ShaderOperation::bind_material_resources(gpu::Shader *shader) { /* Bind the uniform buffer of the material if it exists. It may not exist if the GPU material has * no uniforms. */ - GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material_); + gpu::UniformBuf *ubo = GPU_material_uniform_buffer_get(material_); if (ubo) { GPU_uniformbuf_bind(ubo, GPU_shader_get_ubo_binding(shader, GPU_UBO_BLOCK_NAME)); } diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc index d4035ee36c2..7ccb4be1df2 100644 --- a/source/blender/draw/engines/gpencil/gpencil_draw_data.cc +++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.cc @@ -304,7 +304,7 @@ void gpencil_material_resources_get(MaterialPool *first_pool, int mat_id, gpu::Texture **r_tex_stroke, gpu::Texture **r_tex_fill, - GPUUniformBuf **r_ubo_mat) + gpu::UniformBuf **r_ubo_mat) { MaterialPool *matpool = first_pool; BLI_assert(mat_id >= 0); diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc index dc7c4720e38..9257bafa77d 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_c.cc +++ b/source/blender/draw/engines/gpencil/gpencil_engine_c.cc @@ -447,10 +447,10 @@ tObject *Instance::object_sync_do(Object *ob, ResourceHandleRange res_handle) ((layer.base.flag & GP_LAYER_TREE_NODE_USE_LIGHTS) != 0) && (ob->dtx & OB_USE_GPENCIL_LIGHTS); - GPUUniformBuf *lights_ubo = (use_lights) ? this->global_light_pool->ubo : - this->shadeless_light_pool->ubo; + gpu::UniformBuf *lights_ubo = (use_lights) ? this->global_light_pool->ubo : + this->shadeless_light_pool->ubo; - GPUUniformBuf *ubo_mat; + gpu::UniformBuf *ubo_mat; gpencil_material_resources_get(matpool, 0, nullptr, nullptr, &ubo_mat); pass.bind_ubo("gp_lights", lights_ubo); @@ -502,7 +502,7 @@ tObject *Instance::object_sync_do(Object *ob, ResourceHandleRange res_handle) return; } - GPUUniformBuf *new_ubo_mat; + gpu::UniformBuf *new_ubo_mat; gpu::Texture *new_tex_fill = nullptr; gpu::Texture *new_tex_stroke = nullptr; gpencil_material_resources_get( diff --git a/source/blender/draw/engines/gpencil/gpencil_engine_private.hh b/source/blender/draw/engines/gpencil/gpencil_engine_private.hh index cac7501ec1b..7c94ec52c6a 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine_private.hh +++ b/source/blender/draw/engines/gpencil/gpencil_engine_private.hh @@ -49,7 +49,7 @@ struct MaterialPool { /* GPU representation of materials. */ gpMaterial mat_data[GPENCIL_MATERIAL_BUFFER_LEN]; /* Matching ubo. */ - GPUUniformBuf *ubo; + gpu::UniformBuf *ubo; /* Texture per material. NULL means none. */ gpu::Texture *tex_fill[GPENCIL_MATERIAL_BUFFER_LEN]; gpu::Texture *tex_stroke[GPENCIL_MATERIAL_BUFFER_LEN]; @@ -61,7 +61,7 @@ struct LightPool { /* GPU representation of materials. */ gpLight light_data[GPENCIL_LIGHT_BUFFER_LEN]; /* Matching ubo. */ - struct GPUUniformBuf *ubo; + gpu::UniformBuf *ubo; /* Number of light in the pool. */ int light_used; }; @@ -427,7 +427,7 @@ void gpencil_material_resources_get(MaterialPool *first_pool, int mat_id, gpu::Texture **r_tex_stroke, gpu::Texture **r_tex_fill, - struct GPUUniformBuf **r_ubo_mat); + gpu::UniformBuf **r_ubo_mat); void gpencil_light_ambient_add(LightPool *lightpool, const float color[3]); void gpencil_light_pool_populate(LightPool *lightpool, Object *ob); diff --git a/source/blender/draw/intern/DRW_gpu_wrapper.hh b/source/blender/draw/intern/DRW_gpu_wrapper.hh index 31f3084456c..b55540019df 100644 --- a/source/blender/draw/intern/DRW_gpu_wrapper.hh +++ b/source/blender/draw/intern/DRW_gpu_wrapper.hh @@ -167,7 +167,7 @@ class DataBuffer { template class UniformCommon : public DataBuffer, NonMovable, NonCopyable { protected: - GPUUniformBuf *ubo_; + gpu::UniformBuf *ubo_; #ifndef NDEBUG const char *name_ = typeid(T).name(); @@ -195,13 +195,13 @@ class UniformCommon : public DataBuffer, NonMovable, NonCopyable } /* To be able to use it with DRW_shgroup_*_ref(). */ - operator GPUUniformBuf *() const + operator gpu::UniformBuf *() const { return ubo_; } /* To be able to use it with DRW_shgroup_*_ref(). */ - GPUUniformBuf **operator&() + gpu::UniformBuf **operator&() { return &ubo_; } diff --git a/source/blender/draw/intern/DRW_render.hh b/source/blender/draw/intern/DRW_render.hh index 5464d097a66..811b60a2991 100644 --- a/source/blender/draw/intern/DRW_render.hh +++ b/source/blender/draw/intern/DRW_render.hh @@ -24,6 +24,7 @@ namespace blender::gpu { class Batch; class Shader; class Texture; +class UniformBuf; } // namespace blender::gpu struct ARegion; struct bContext; @@ -32,7 +33,6 @@ struct DefaultFramebufferList; struct DefaultTextureList; struct DupliObject; struct GPUMaterial; -struct GPUUniformBuf; struct Mesh; struct Object; struct ParticleSystem; diff --git a/source/blender/draw/intern/draw_cache_impl.hh b/source/blender/draw/intern/draw_cache_impl.hh index c91f54e3d29..9673f11c401 100644 --- a/source/blender/draw/intern/draw_cache_impl.hh +++ b/source/blender/draw/intern/draw_cache_impl.hh @@ -17,9 +17,9 @@ struct GPUMaterial; namespace blender::gpu { class Batch; +class UniformBuf; class VertBuf; } // namespace blender::gpu -struct GPUUniformBuf; struct ModifierData; struct PTCacheEdit; struct ParticleSystem; diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index b6b90c73178..67d03a7d728 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -179,8 +179,8 @@ struct ResourceBind { union { /** TODO: Use draw::Texture|StorageBuffer|UniformBuffer as resources as they will give more * debug info. */ - GPUUniformBuf *uniform_buf; - GPUUniformBuf **uniform_buf_ref; + gpu::UniformBuf *uniform_buf; + gpu::UniformBuf **uniform_buf_ref; GPUStorageBuf *storage_buf; GPUStorageBuf **storage_buf_ref; /** NOTE: Texture is used for both Sampler and Image binds. */ @@ -194,17 +194,17 @@ struct ResourceBind { ResourceBind() = default; - ResourceBind(int slot_, GPUUniformBuf *res) + ResourceBind(int slot_, gpu::UniformBuf *res) : slot(slot_), is_reference(false), type(Type::UniformBuf), uniform_buf(res){}; - ResourceBind(int slot_, GPUUniformBuf **res) + ResourceBind(int slot_, gpu::UniformBuf **res) : slot(slot_), is_reference(true), type(Type::UniformBuf), uniform_buf_ref(res){}; ResourceBind(int slot_, GPUStorageBuf *res) : slot(slot_), is_reference(false), type(Type::StorageBuf), storage_buf(res){}; ResourceBind(int slot_, GPUStorageBuf **res) : slot(slot_), is_reference(true), type(Type::StorageBuf), storage_buf_ref(res){}; - ResourceBind(int slot_, GPUUniformBuf *res, Type /*type*/) + ResourceBind(int slot_, gpu::UniformBuf *res, Type /*type*/) : slot(slot_), is_reference(false), type(Type::UniformAsStorageBuf), uniform_buf(res){}; - ResourceBind(int slot_, GPUUniformBuf **res, Type /*type*/) + ResourceBind(int slot_, gpu::UniformBuf **res, Type /*type*/) : slot(slot_), is_reference(true), type(Type::UniformAsStorageBuf), uniform_buf_ref(res){}; ResourceBind(int slot_, gpu::VertBuf *res, Type /*type*/) : slot(slot_), is_reference(false), type(Type::VertexAsStorageBuf), vertex_buf(res){}; diff --git a/source/blender/draw/intern/draw_common_c.hh b/source/blender/draw/intern/draw_common_c.hh index bba37db268b..8a6c6d565bb 100644 --- a/source/blender/draw/intern/draw_common_c.hh +++ b/source/blender/draw/intern/draw_common_c.hh @@ -10,10 +10,10 @@ struct FluidModifierData; struct GPUMaterial; -struct GPUUniformBuf; namespace blender::gpu { class Texture; +class UniformBuf; class VertBuf; } // namespace blender::gpu struct ModifierData; diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh index 74f3333e7b0..cd55c4ca211 100644 --- a/source/blender/draw/intern/draw_pass.hh +++ b/source/blender/draw/intern/draw_pass.hh @@ -364,10 +364,10 @@ class PassBase { void bind_ssbo(const char *name, GPUStorageBuf **buffer); void bind_ssbo(int slot, GPUStorageBuf *buffer); void bind_ssbo(int slot, GPUStorageBuf **buffer); - void bind_ssbo(const char *name, GPUUniformBuf *buffer); - void bind_ssbo(const char *name, GPUUniformBuf **buffer); - void bind_ssbo(int slot, GPUUniformBuf *buffer); - void bind_ssbo(int slot, GPUUniformBuf **buffer); + void bind_ssbo(const char *name, gpu::UniformBuf *buffer); + void bind_ssbo(const char *name, gpu::UniformBuf **buffer); + void bind_ssbo(int slot, gpu::UniformBuf *buffer); + void bind_ssbo(int slot, gpu::UniformBuf **buffer); void bind_ssbo(const char *name, gpu::VertBuf *buffer); void bind_ssbo(const char *name, gpu::VertBuf **buffer); void bind_ssbo(int slot, gpu::VertBuf *buffer); @@ -376,10 +376,10 @@ class PassBase { void bind_ssbo(const char *name, gpu::IndexBuf **buffer); void bind_ssbo(int slot, gpu::IndexBuf *buffer); void bind_ssbo(int slot, gpu::IndexBuf **buffer); - void bind_ubo(const char *name, GPUUniformBuf *buffer); - void bind_ubo(const char *name, GPUUniformBuf **buffer); - void bind_ubo(int slot, GPUUniformBuf *buffer); - void bind_ubo(int slot, GPUUniformBuf **buffer); + void bind_ubo(const char *name, gpu::UniformBuf *buffer); + void bind_ubo(const char *name, gpu::UniformBuf **buffer); + void bind_ubo(int slot, gpu::UniformBuf *buffer); + void bind_ubo(int slot, gpu::UniformBuf **buffer); /** * Update a shader constant. @@ -1177,7 +1177,7 @@ inline void PassBase::material_set(Manager &manager, } } - GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material); + gpu::UniformBuf *ubo = GPU_material_uniform_buffer_get(material); if (ubo != nullptr) { bind_ubo(GPU_NODE_TREE_UBO_SLOT, ubo); } @@ -1200,13 +1200,13 @@ template inline void PassBase::bind_ssbo(const char *name, GPUStorag this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer); } -template inline void PassBase::bind_ssbo(const char *name, GPUUniformBuf *buffer) +template inline void PassBase::bind_ssbo(const char *name, gpu::UniformBuf *buffer) { BLI_assert(buffer != nullptr); this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer); } -template inline void PassBase::bind_ssbo(const char *name, GPUUniformBuf **buffer) +template inline void PassBase::bind_ssbo(const char *name, gpu::UniformBuf **buffer) { BLI_assert(buffer != nullptr); this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer); @@ -1236,7 +1236,7 @@ template inline void PassBase::bind_ssbo(const char *name, gpu::Inde this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer); } -template inline void PassBase::bind_ubo(const char *name, GPUUniformBuf *buffer) +template inline void PassBase::bind_ubo(const char *name, gpu::UniformBuf *buffer) { BLI_assert(buffer != nullptr); this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer); @@ -1275,14 +1275,14 @@ template inline void PassBase::bind_ssbo(int slot, GPUStorageBuf *bu create_command(Type::ResourceBind).resource_bind = {slot, buffer}; } -template inline void PassBase::bind_ssbo(int slot, GPUUniformBuf *buffer) +template inline void PassBase::bind_ssbo(int slot, gpu::UniformBuf *buffer) { BLI_assert(buffer != nullptr); create_command(Type::ResourceBind).resource_bind = { slot, buffer, ResourceBind::Type::UniformAsStorageBuf}; } -template inline void PassBase::bind_ssbo(int slot, GPUUniformBuf **buffer) +template inline void PassBase::bind_ssbo(int slot, gpu::UniformBuf **buffer) { BLI_assert(buffer != nullptr); create_command(Type::ResourceBind).resource_bind = { @@ -1317,7 +1317,7 @@ template inline void PassBase::bind_ssbo(int slot, gpu::IndexBuf **b slot, buffer, ResourceBind::Type::IndexAsStorageBuf}; } -template inline void PassBase::bind_ubo(int slot, GPUUniformBuf *buffer) +template inline void PassBase::bind_ubo(int slot, gpu::UniformBuf *buffer) { BLI_assert(buffer != nullptr); create_command(Type::ResourceBind).resource_bind = {slot, buffer}; @@ -1354,7 +1354,7 @@ template inline void PassBase::bind_ssbo(const char *name, GPUStorag this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer); } -template inline void PassBase::bind_ubo(const char *name, GPUUniformBuf **buffer) +template inline void PassBase::bind_ubo(const char *name, gpu::UniformBuf **buffer) { BLI_assert(buffer != nullptr); this->bind_ubo(GPU_shader_get_ubo_binding(shader_, name), buffer); @@ -1382,7 +1382,7 @@ template inline void PassBase::bind_ssbo(int slot, GPUStorageBuf **b create_command(Type::ResourceBind).resource_bind = {slot, buffer}; } -template inline void PassBase::bind_ubo(int slot, GPUUniformBuf **buffer) +template inline void PassBase::bind_ubo(int slot, gpu::UniformBuf **buffer) { BLI_assert(buffer != nullptr); create_command(Type::ResourceBind).resource_bind = {slot, buffer}; diff --git a/source/blender/draw/intern/draw_subdivision.hh b/source/blender/draw/intern/draw_subdivision.hh index da06b7d0a77..98b1478cb10 100644 --- a/source/blender/draw/intern/draw_subdivision.hh +++ b/source/blender/draw/intern/draw_subdivision.hh @@ -13,9 +13,9 @@ #include "mesh_extractors/extract_mesh.hh" struct BMesh; -struct GPUUniformBuf; namespace blender::gpu { class IndexBuf; +class UniformBuf; class VertBuf; } // namespace blender::gpu struct GPUVertFormat; @@ -138,7 +138,7 @@ struct DRWSubdivCache { Array loose_edge_positions; /* UBO to store settings for the various compute shaders. */ - GPUUniformBuf *ubo; + gpu::UniformBuf *ubo; /* Extra flags, passed to the UBO. */ bool is_edit_mode; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc index d6fe3b30078..87995b501f4 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc @@ -277,12 +277,12 @@ void draw_polyline(const float4x4 &transform, immUnbindProgram(); } -static GPUUniformBuf *create_shader_ubo(const RegionView3D &rv3d, - const int2 &win_size, - const Object &object, - const eGPDstroke_Caps cap_start, - const eGPDstroke_Caps cap_end, - const bool is_fill_stroke) +static gpu::UniformBuf *create_shader_ubo(const RegionView3D &rv3d, + const int2 &win_size, + const Object &object, + const eGPDstroke_Caps cap_start, + const eGPDstroke_Caps cap_end, + const bool is_fill_stroke) { GPencilStrokeData data; copy_v2_v2(data.viewport, float2(win_size)); @@ -331,7 +331,8 @@ static void draw_grease_pencil_stroke(const float4x4 &transform, format, "color", blender::gpu::VertAttrType::SFLOAT_32_32_32_32); immBindBuiltinProgram(GPU_SHADER_GPENCIL_STROKE); - GPUUniformBuf *ubo = create_shader_ubo(rv3d, win_size, object, cap_start, cap_end, fill_stroke); + gpu::UniformBuf *ubo = create_shader_ubo( + rv3d, win_size, object, cap_start, cap_end, fill_stroke); immBindUniformBuf("gpencil_stroke_data", ubo); /* If cyclic the curve needs one more vertex. */ diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 6be3212f4d1..3981e02556d 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -1529,7 +1529,7 @@ void ui_draw_but_UNITVEC(uiBut *but, SimpleLightingData simple_lighting_data; copy_v4_fl4(simple_lighting_data.l_color, diffuse[0], diffuse[1], diffuse[2], 1.0f); copy_v3_v3(simple_lighting_data.light, light); - GPUUniformBuf *ubo = GPU_uniformbuf_create_ex( + blender::gpu::UniformBuf *ubo = GPU_uniformbuf_create_ex( sizeof(SimpleLightingData), &simple_lighting_data, __func__); GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index fc14fc77e0d..7c700575593 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -2018,7 +2018,8 @@ static void nodelink_batch_draw(const SpaceNode &snode) node_link_data.aspect = snode.runtime->aspect; node_link_data.arrowSize = ARROW_SIZE; - GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(sizeof(node_link_data), &node_link_data, __func__); + gpu::UniformBuf *ubo = GPU_uniformbuf_create_ex( + sizeof(node_link_data), &node_link_data, __func__); GPU_vertbuf_data_len_set(*g_batch_link.inst_vbo, g_batch_link.count); GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ @@ -2285,7 +2286,8 @@ static void node_draw_link_bezier_ex(const SpaceNode &snode, node_link_data.arrowSize = ARROW_SIZE; gpu::Batch *batch = g_batch_link.batch_single; - GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(sizeof(NodeLinkData), &node_link_data, __func__); + gpu::UniformBuf *ubo = GPU_uniformbuf_create_ex( + sizeof(NodeLinkData), &node_link_data, __func__); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); GPU_batch_uniformbuf_bind(batch, "node_link_data", ubo); diff --git a/source/blender/editors/space_sequencer/sequencer_strips_batch.hh b/source/blender/editors/space_sequencer/sequencer_strips_batch.hh index ab6aa94c092..3b3398488ff 100644 --- a/source/blender/editors/space_sequencer/sequencer_strips_batch.hh +++ b/source/blender/editors/space_sequencer/sequencer_strips_batch.hh @@ -14,8 +14,8 @@ namespace blender::gpu { class Shader; +class UniformBuf; } // namespace blender::gpu -struct GPUUniformBuf; struct View2D; namespace blender::gpu { @@ -32,8 +32,8 @@ namespace blender::ed::vse { class StripsDrawBatch { SeqContextDrawData context_; Array strips_; - GPUUniformBuf *ubo_context_ = nullptr; - GPUUniformBuf *ubo_strips_ = nullptr; + gpu::UniformBuf *ubo_context_ = nullptr; + gpu::UniformBuf *ubo_strips_ = nullptr; gpu::Shader *shader_ = nullptr; gpu::Batch *batch_ = nullptr; int binding_context_ = 0; @@ -76,7 +76,7 @@ class StripsDrawBatch { return x * view_cur_inv_size_.x * view_mask_size_.x; } - GPUUniformBuf *get_ubo_context() const + gpu::UniformBuf *get_ubo_context() const { return ubo_context_; } diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.cc b/source/blender/editors/space_sequencer/sequencer_thumbnails.cc index 1ac7a802b4b..aee675d11cf 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.cc +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.cc @@ -208,16 +208,16 @@ static void get_seq_strip_thumbnails(const View2D *v2d, struct ThumbsDrawBatch { StripsDrawBatch &strips_batch_; Array thumbs_; - GPUUniformBuf *ubo_thumbs_ = nullptr; + gpu::UniformBuf *ubo_thumbs_ = nullptr; gpu::Shader *shader_ = nullptr; gpu::Batch *batch_ = nullptr; - blender::gpu::Texture *atlas_ = nullptr; + gpu::Texture *atlas_ = nullptr; int binding_context_ = 0; int binding_thumbs_ = 0; int binding_image_ = 0; int thumbs_count_ = 0; - ThumbsDrawBatch(StripsDrawBatch &strips_batch, blender::gpu::Texture *atlas) + ThumbsDrawBatch(StripsDrawBatch &strips_batch, gpu::Texture *atlas) : strips_batch_(strips_batch), thumbs_(GPU_SEQ_STRIP_DRAW_DATA_LEN), atlas_(atlas) { shader_ = GPU_shader_get_builtin_shader(GPU_SHADER_SEQUENCER_THUMBS); diff --git a/source/blender/gpu/GPU_immediate.hh b/source/blender/gpu/GPU_immediate.hh index d719c2303fe..a24b929e3c4 100644 --- a/source/blender/gpu/GPU_immediate.hh +++ b/source/blender/gpu/GPU_immediate.hh @@ -17,7 +17,9 @@ #include "GPU_texture.hh" #include "GPU_vertex_format.hh" -struct GPUUniformBuf; +namespace blender::gpu { +class UniformBuf; +} // namespace blender::gpu /** Returns a cleared vertex format, ready for #add_attr. */ GPUVertFormat *immVertexFormat(); @@ -109,7 +111,7 @@ void immUniformMatrix4fv(const char *name, const float data[4][4]); void immBindTexture(const char *name, blender::gpu::Texture *tex); void immBindTextureSampler(const char *name, blender::gpu::Texture *tex, GPUSamplerState state); -void immBindUniformBuf(const char *name, GPUUniformBuf *ubo); +void immBindUniformBuf(const char *name, blender::gpu::UniformBuf *ubo); /* Convenience functions for setting "uniform vec4 color". */ /* The RGB functions have implicit alpha = 1.0. */ diff --git a/source/blender/gpu/GPU_material.hh b/source/blender/gpu/GPU_material.hh index 194c854abaf..3b642755a0c 100644 --- a/source/blender/gpu/GPU_material.hh +++ b/source/blender/gpu/GPU_material.hh @@ -24,8 +24,8 @@ struct GPUNodeStack; struct GPUPass; namespace blender::gpu { class Texture; -} -struct GPUUniformBuf; +class UniformBuf; +} // namespace blender::gpu struct Image; struct ImageUser; struct ListBase; @@ -146,7 +146,7 @@ eGPUMaterialOptimizationStatus GPU_material_optimization_status(GPUMaterial *mat uint64_t GPU_material_compilation_timestamp(GPUMaterial *mat); -GPUUniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material); +blender::gpu::UniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material); /** * Create dynamic UBO from parameters * diff --git a/source/blender/gpu/GPU_uniform_buffer.hh b/source/blender/gpu/GPU_uniform_buffer.hh index 245d2e5ff2e..801726dd3ee 100644 --- a/source/blender/gpu/GPU_uniform_buffer.hh +++ b/source/blender/gpu/GPU_uniform_buffer.hh @@ -19,34 +19,37 @@ struct ListBase; -/** Opaque type hiding blender::gpu::UniformBuf. */ -struct GPUUniformBuf; +namespace blender::gpu { +class UniformBuf; +} // namespace blender::gpu -GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name); +blender::gpu::UniformBuf *GPU_uniformbuf_create_ex(size_t size, + const void *data, + const char *name); /** * Create UBO from inputs list. * Return nullptr if failed to create or if \param inputs: is empty. * * \param inputs: ListBase of #BLI_genericNodeN(#GPUInput). */ -GPUUniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *name); +blender::gpu::UniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *name); #define GPU_uniformbuf_create(size) GPU_uniformbuf_create_ex(size, nullptr, __func__); -void GPU_uniformbuf_free(GPUUniformBuf *ubo); +void GPU_uniformbuf_free(blender::gpu::UniformBuf *ubo); -void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data); +void GPU_uniformbuf_update(blender::gpu::UniformBuf *ubo, const void *data); -void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot); -void GPU_uniformbuf_bind_as_ssbo(GPUUniformBuf *ubo, int slot); -void GPU_uniformbuf_unbind(GPUUniformBuf *ubo); +void GPU_uniformbuf_bind(blender::gpu::UniformBuf *ubo, int slot); +void GPU_uniformbuf_bind_as_ssbo(blender::gpu::UniformBuf *ubo, int slot); +void GPU_uniformbuf_unbind(blender::gpu::UniformBuf *ubo); /** * Resets the internal slot usage tracking. But there is no guarantee that * this actually undo the bindings for the next draw call. Only has effect when G_DEBUG_GPU is set. */ void GPU_uniformbuf_debug_unbind_all(); -void GPU_uniformbuf_clear_to_zero(GPUUniformBuf *ubo); +void GPU_uniformbuf_clear_to_zero(blender::gpu::UniformBuf *ubo); #define GPU_UBO_BLOCK_NAME "node_tree" #define GPU_ATTRIBUTE_UBO_BLOCK_NAME "unf_attrs" diff --git a/source/blender/gpu/intern/gpu_immediate.cc b/source/blender/gpu/intern/gpu_immediate.cc index 29a6a41324b..150ca128bc7 100644 --- a/source/blender/gpu/intern/gpu_immediate.cc +++ b/source/blender/gpu/intern/gpu_immediate.cc @@ -640,7 +640,7 @@ void immBindTextureSampler(const char *name, blender::gpu::Texture *tex, GPUSamp GPU_texture_bind_ex(tex, state, binding); } -void immBindUniformBuf(const char *name, GPUUniformBuf *ubo) +void immBindUniformBuf(const char *name, blender::gpu::UniformBuf *ubo) { int binding = GPU_shader_get_ubo_binding(imm->shader, name); GPU_uniformbuf_bind(ubo, binding); diff --git a/source/blender/gpu/intern/gpu_material.cc b/source/blender/gpu/intern/gpu_material.cc index 0706648e553..390c68c907d 100644 --- a/source/blender/gpu/intern/gpu_material.cc +++ b/source/blender/gpu/intern/gpu_material.cc @@ -67,7 +67,7 @@ struct GPUMaterial { GPUPass *optimized_pass = nullptr; /* UBOs for this material parameters. */ - GPUUniformBuf *ubo = nullptr; + blender::gpu::UniformBuf *ubo = nullptr; /* Some flags about the nodetree & the needed resources. */ eGPUMaterialFlag flag = GPU_MATFLAG_UPDATED; /* The engine type this material is compiled for. */ @@ -188,7 +188,8 @@ GPUMaterial *GPU_material_from_nodetree(Material *ma, } gpu_node_graph_free_nodes(&mat->graph); - /* Only free after GPU_pass_shader_get where GPUUniformBuf read data from the local tree. */ + /* Only free after GPU_pass_shader_get where blender::gpu::UniformBuf read data from the local + * tree. */ blender::bke::node_tree_free_local_tree(localtree); BLI_assert(!localtree->id.py_instance); /* Or call #BKE_libblock_free_data_py. */ MEM_freeN(localtree); @@ -374,7 +375,7 @@ void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs) material->ubo = GPU_uniformbuf_create_from_list(inputs, material->name.c_str()); } -GPUUniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material) +blender::gpu::UniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material) { return material->ubo; } diff --git a/source/blender/gpu/intern/gpu_uniform_buffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc index 46dd29a7c4d..3c717dc3c4f 100644 --- a/source/blender/gpu/intern/gpu_uniform_buffer.cc +++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc @@ -191,7 +191,7 @@ static inline void buffer_fill_from_list(void *data, ListBase *inputs) using namespace blender::gpu; -GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name) +blender::gpu::UniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name) { UniformBuf *ubo = GPUBackend::get()->uniformbuf_alloc(size, name); /* Direct init. */ @@ -204,10 +204,10 @@ GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const cha blender::Vector uninitialized_data(size, 0xFF); ubo->update(uninitialized_data.data()); } - return wrap(ubo); + return ubo; } -GPUUniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *name) +blender::gpu::UniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *name) { /* There is no point on creating an UBO if there is no arguments. */ if (BLI_listbase_is_empty(inputs)) { @@ -222,32 +222,32 @@ GPUUniformBuf *GPU_uniformbuf_create_from_list(ListBase *inputs, const char *nam UniformBuf *ubo = GPUBackend::get()->uniformbuf_alloc(buffer_size, name); /* Defer data upload. */ ubo->attach_data(data); - return wrap(ubo); + return ubo; } -void GPU_uniformbuf_free(GPUUniformBuf *ubo) +void GPU_uniformbuf_free(blender::gpu::UniformBuf *ubo) { - delete unwrap(ubo); + delete ubo; } -void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data) +void GPU_uniformbuf_update(blender::gpu::UniformBuf *ubo, const void *data) { - unwrap(ubo)->update(data); + ubo->update(data); } -void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot) +void GPU_uniformbuf_bind(blender::gpu::UniformBuf *ubo, int slot) { - unwrap(ubo)->bind(slot); + ubo->bind(slot); } -void GPU_uniformbuf_bind_as_ssbo(GPUUniformBuf *ubo, int slot) +void GPU_uniformbuf_bind_as_ssbo(blender::gpu::UniformBuf *ubo, int slot) { - unwrap(ubo)->bind_as_ssbo(slot); + ubo->bind_as_ssbo(slot); } -void GPU_uniformbuf_unbind(GPUUniformBuf *ubo) +void GPU_uniformbuf_unbind(blender::gpu::UniformBuf *ubo) { - unwrap(ubo)->unbind(); + ubo->unbind(); } void GPU_uniformbuf_debug_unbind_all() @@ -255,9 +255,9 @@ void GPU_uniformbuf_debug_unbind_all() Context::get()->debug_unbind_all_ubo(); } -void GPU_uniformbuf_clear_to_zero(GPUUniformBuf *ubo) +void GPU_uniformbuf_clear_to_zero(blender::gpu::UniformBuf *ubo) { - unwrap(ubo)->clear_to_zero(); + ubo->clear_to_zero(); } /** \} */ diff --git a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh index b2618f1c444..938619baa9f 100644 --- a/source/blender/gpu/intern/gpu_uniform_buffer_private.hh +++ b/source/blender/gpu/intern/gpu_uniform_buffer_private.hh @@ -10,8 +10,6 @@ #include "BLI_sys_types.h" -struct GPUUniformBuf; - namespace blender::gpu { #ifndef NDEBUG @@ -52,20 +50,6 @@ class UniformBuf { } }; -/* Syntactic sugar. */ -static inline GPUUniformBuf *wrap(UniformBuf *vert) -{ - return reinterpret_cast(vert); -} -static inline UniformBuf *unwrap(GPUUniformBuf *vert) -{ - return reinterpret_cast(vert); -} -static inline const UniformBuf *unwrap(const GPUUniformBuf *vert) -{ - return reinterpret_cast(vert); -} - #undef DEBUG_NAME_LEN } // namespace blender::gpu diff --git a/source/blender/gpu/metal/mtl_context.mm b/source/blender/gpu/metal/mtl_context.mm index a94b57dc5e7..10008b1c550 100644 --- a/source/blender/gpu/metal/mtl_context.mm +++ b/source/blender/gpu/metal/mtl_context.mm @@ -320,8 +320,7 @@ MTLContext::~MTLContext() if (this->pipeline_state.ubo_bindings[i].bound && this->pipeline_state.ubo_bindings[i].ubo != nullptr) { - GPUUniformBuf *ubo = wrap( - static_cast(this->pipeline_state.ubo_bindings[i].ubo)); + gpu::UniformBuf *ubo = this->pipeline_state.ubo_bindings[i].ubo; GPU_uniformbuf_unbind(ubo); } } diff --git a/source/blender/imbuf/opencolorio/intern/gpu_shader_binder_internal.hh b/source/blender/imbuf/opencolorio/intern/gpu_shader_binder_internal.hh index 699e8bb443f..80e4515881c 100644 --- a/source/blender/imbuf/opencolorio/intern/gpu_shader_binder_internal.hh +++ b/source/blender/imbuf/opencolorio/intern/gpu_shader_binder_internal.hh @@ -25,9 +25,9 @@ #endif struct CurveMapping; -struct GPUUniformBuf; namespace blender::gpu { class Shader; +class UniformBuf; class Texture; } // namespace blender::gpu @@ -81,7 +81,7 @@ class GPUTextures : NonCopyable, NonMovable { /* Uniforms */ Vector uniforms; - GPUUniformBuf *uniforms_buffer = nullptr; + gpu::UniformBuf *uniforms_buffer = nullptr; ~GPUTextures(); @@ -99,7 +99,7 @@ class GPUCurveMappping : NonCopyable, NonMovable { int lut_size = 0; float *lut = nullptr; - GPUUniformBuf *buffer = nullptr; + gpu::UniformBuf *buffer = nullptr; blender::gpu::Texture *texture = nullptr; size_t cache_id = 0; @@ -139,7 +139,7 @@ class GPUDisplayShader : NonCopyable, NonMovable { /* Uniform parameters. */ OCIO_GPUParameters parameters = {}; - GPUUniformBuf *parameters_buffer = nullptr; + gpu::UniformBuf *parameters_buffer = nullptr; GPUTextures textures; GPUCurveMappping curve_mapping; diff --git a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc index aa0da2ef551..57af8ca5daf 100644 --- a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc +++ b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc @@ -159,7 +159,7 @@ class PlaneTrackDeformOperation : public NodeOperation { void execute_gpu(const Array homography_matrices) { - GPUUniformBuf *homography_matrices_buffer = GPU_uniformbuf_create_ex( + gpu::UniformBuf *homography_matrices_buffer = GPU_uniformbuf_create_ex( homography_matrices.size() * sizeof(float4x4), homography_matrices.data(), "Plane Track Deform Homography Matrices"); @@ -188,7 +188,7 @@ class PlaneTrackDeformOperation : public NodeOperation { } void compute_plane_gpu(const Array &homography_matrices, - GPUUniformBuf *homography_matrices_buffer, + gpu::UniformBuf *homography_matrices_buffer, Result &plane_mask) { gpu::Shader *shader = context().get_shader("compositor_plane_deform_motion_blur"); @@ -224,7 +224,7 @@ class PlaneTrackDeformOperation : public NodeOperation { } Result compute_plane_mask_gpu(const Array &homography_matrices, - GPUUniformBuf *homography_matrices_buffer) + gpu::UniformBuf *homography_matrices_buffer) { gpu::Shader *shader = context().get_shader("compositor_plane_deform_motion_blur_mask"); GPU_shader_bind(shader); diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.cc b/source/blender/python/gpu/gpu_py_uniformbuffer.cc index f8788e19bf8..5bcdfdb2f1a 100644 --- a/source/blender/python/gpu/gpu_py_uniformbuffer.cc +++ b/source/blender/python/gpu/gpu_py_uniformbuffer.cc @@ -24,7 +24,7 @@ #include "gpu_py_uniformbuffer.hh" /* own include */ /* -------------------------------------------------------------------- */ -/** \name GPUUniformBuf Common Utilities +/** \name blender::gpu::UniformBuf Common Utilities * \{ */ static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub) @@ -53,7 +53,7 @@ static int pygpu_uniformbuffer_valid_check(BPyGPUUniformBuf *bpygpu_ub) /** \} */ /* -------------------------------------------------------------------- */ -/** \name GPUUniformBuf Type +/** \name blender::gpu::UniformBuf Type * \{ */ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject * /*self*/, @@ -62,7 +62,7 @@ static PyObject *pygpu_uniformbuffer__tp_new(PyTypeObject * /*self*/, { BPYGPU_IS_INIT_OR_ERROR_OBJ; - GPUUniformBuf *ubo = nullptr; + blender::gpu::UniformBuf *ubo = nullptr; PyObject *pybuffer_obj; char err_out[256] = "unknown error. See console"; @@ -231,7 +231,7 @@ PyTypeObject BPyGPUUniformBuf_Type = { /** \name Public API * \{ */ -PyObject *BPyGPUUniformBuf_CreatePyObject(GPUUniformBuf *ubo) +PyObject *BPyGPUUniformBuf_CreatePyObject(blender::gpu::UniformBuf *ubo) { BPyGPUUniformBuf *self; diff --git a/source/blender/python/gpu/gpu_py_uniformbuffer.hh b/source/blender/python/gpu/gpu_py_uniformbuffer.hh index 84dec9a2fc1..998aa4e5fca 100644 --- a/source/blender/python/gpu/gpu_py_uniformbuffer.hh +++ b/source/blender/python/gpu/gpu_py_uniformbuffer.hh @@ -12,7 +12,9 @@ #include "BLI_compiler_attrs.h" -struct GPUUniformBuf; +namespace blender::gpu { +class UniformBuf; +} // namespace blender::gpu extern PyTypeObject BPyGPUUniformBuf_Type; @@ -20,7 +22,8 @@ extern PyTypeObject BPyGPUUniformBuf_Type; struct BPyGPUUniformBuf { PyObject_HEAD - GPUUniformBuf *ubo; + blender::gpu::UniformBuf *ubo; }; -[[nodiscard]] PyObject *BPyGPUUniformBuf_CreatePyObject(GPUUniformBuf *ubo) ATTR_NONNULL(1); +[[nodiscard]] PyObject *BPyGPUUniformBuf_CreatePyObject(blender::gpu::UniformBuf *ubo) + ATTR_NONNULL(1);