GPU: Remove wrapper type for gpu::UniformBuf
This is the first step into merging `DRW_gpu_wrapper.hh` into the GPU module. This is very similar to #119825. Pull Request: https://projects.blender.org/blender/blender/pulls/144328
This commit is contained in:
committed by
Clément Foucault
parent
1388a70914
commit
9fbf7e9ec2
@@ -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<GPUUniformBuf *> uniform_buffers_;
|
||||
Vector<gpu::UniformBuf *> uniform_buffers_;
|
||||
|
||||
# if OCIO_VERSION_HEX >= 0x02030000
|
||||
/* Allow creating 1D textures, or only use 2D textures. */
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -167,7 +167,7 @@ class DataBuffer {
|
||||
template<typename T, int64_t len, bool device_only>
|
||||
class UniformCommon : public DataBuffer<T, len, false>, NonMovable, NonCopyable {
|
||||
protected:
|
||||
GPUUniformBuf *ubo_;
|
||||
gpu::UniformBuf *ubo_;
|
||||
|
||||
#ifndef NDEBUG
|
||||
const char *name_ = typeid(T).name();
|
||||
@@ -195,13 +195,13 @@ class UniformCommon : public DataBuffer<T, len, false>, 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_;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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){};
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
|
||||
struct FluidModifierData;
|
||||
struct GPUMaterial;
|
||||
struct GPUUniformBuf;
|
||||
|
||||
namespace blender::gpu {
|
||||
class Texture;
|
||||
class UniformBuf;
|
||||
class VertBuf;
|
||||
} // namespace blender::gpu
|
||||
struct ModifierData;
|
||||
|
||||
@@ -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<T>::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<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorag
|
||||
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf *buffer)
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::UniformBuf *buffer)
|
||||
{
|
||||
BLI_assert(buffer != nullptr);
|
||||
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUUniformBuf **buffer)
|
||||
template<class T> inline void PassBase<T>::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<class T> inline void PassBase<T>::bind_ssbo(const char *name, gpu::Inde
|
||||
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf *buffer)
|
||||
template<class T> inline void PassBase<T>::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<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf *bu
|
||||
create_command(Type::ResourceBind).resource_bind = {slot, buffer};
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUUniformBuf *buffer)
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::UniformBuf *buffer)
|
||||
{
|
||||
BLI_assert(buffer != nullptr);
|
||||
create_command(Type::ResourceBind).resource_bind = {
|
||||
slot, buffer, ResourceBind::Type::UniformAsStorageBuf};
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUUniformBuf **buffer)
|
||||
template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::UniformBuf **buffer)
|
||||
{
|
||||
BLI_assert(buffer != nullptr);
|
||||
create_command(Type::ResourceBind).resource_bind = {
|
||||
@@ -1317,7 +1317,7 @@ template<class T> inline void PassBase<T>::bind_ssbo(int slot, gpu::IndexBuf **b
|
||||
slot, buffer, ResourceBind::Type::IndexAsStorageBuf};
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ubo(int slot, GPUUniformBuf *buffer)
|
||||
template<class T> inline void PassBase<T>::bind_ubo(int slot, gpu::UniformBuf *buffer)
|
||||
{
|
||||
BLI_assert(buffer != nullptr);
|
||||
create_command(Type::ResourceBind).resource_bind = {slot, buffer};
|
||||
@@ -1354,7 +1354,7 @@ template<class T> inline void PassBase<T>::bind_ssbo(const char *name, GPUStorag
|
||||
this->bind_ssbo(GPU_shader_get_ssbo_binding(shader_, name), buffer);
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ubo(const char *name, GPUUniformBuf **buffer)
|
||||
template<class T> inline void PassBase<T>::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<class T> inline void PassBase<T>::bind_ssbo(int slot, GPUStorageBuf **b
|
||||
create_command(Type::ResourceBind).resource_bind = {slot, buffer};
|
||||
}
|
||||
|
||||
template<class T> inline void PassBase<T>::bind_ubo(int slot, GPUUniformBuf **buffer)
|
||||
template<class T> inline void PassBase<T>::bind_ubo(int slot, gpu::UniformBuf **buffer)
|
||||
{
|
||||
BLI_assert(buffer != nullptr);
|
||||
create_command(Type::ResourceBind).resource_bind = {slot, buffer};
|
||||
|
||||
@@ -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<float3> 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;
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<SeqStripDrawData> 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_;
|
||||
}
|
||||
|
||||
@@ -208,16 +208,16 @@ static void get_seq_strip_thumbnails(const View2D *v2d,
|
||||
struct ThumbsDrawBatch {
|
||||
StripsDrawBatch &strips_batch_;
|
||||
Array<SeqStripThumbData> 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);
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<uchar> 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();
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -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<GPUUniformBuf *>(vert);
|
||||
}
|
||||
static inline UniformBuf *unwrap(GPUUniformBuf *vert)
|
||||
{
|
||||
return reinterpret_cast<UniformBuf *>(vert);
|
||||
}
|
||||
static inline const UniformBuf *unwrap(const GPUUniformBuf *vert)
|
||||
{
|
||||
return reinterpret_cast<const UniformBuf *>(vert);
|
||||
}
|
||||
|
||||
#undef DEBUG_NAME_LEN
|
||||
|
||||
} // namespace blender::gpu
|
||||
|
||||
@@ -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<UniformBuf *>(this->pipeline_state.ubo_bindings[i].ubo));
|
||||
gpu::UniformBuf *ubo = this->pipeline_state.ubo_bindings[i].ubo;
|
||||
GPU_uniformbuf_unbind(ubo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<GPUUniform> 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;
|
||||
|
||||
@@ -159,7 +159,7 @@ class PlaneTrackDeformOperation : public NodeOperation {
|
||||
|
||||
void execute_gpu(const Array<float4x4> 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<float4x4> &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<float4x4> &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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user