Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2020-08-21 00:09:37 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-08-21 15:16:42 +0300
commit7edd8a7738481b3d4f0720a173dca2a1853996d6 (patch)
tree4b507b4535c0fbe84fc25a21ddf2db55476b1b9b
parent4f0a749489af9de9b2ec0b5768d6e10898885a17 (diff)
GPUUniformBuf: Rename struct and change API a bit
This follows the GPU module naming of other buffers. We pass name to distinguish each GPUUniformBuf in debug mode. Also remove DRW_uniform_buffer interface.
-rw-r--r--source/blender/draw/engines/eevee/eevee_data.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightcache.c12
-rw-r--r--source/blender/draw/engines/eevee/eevee_lightprobes.c16
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_lookdev.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c57
-rw-r--r--source/blender/draw/engines/eevee/eevee_private.h30
-rw-r--r--source/blender/draw/engines/eevee/eevee_render.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_shadows.c10
-rw-r--r--source/blender/draw/engines/eevee/eevee_subsurface.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_data.c8
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c12
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h6
-rw-r--r--source/blender/draw/engines/workbench/workbench_data.c18
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_cavity.c4
-rw-r--r--source/blender/draw/engines/workbench/workbench_effect_dof.c6
-rw-r--r--source/blender/draw/engines/workbench/workbench_materials.c2
-rw-r--r--source/blender/draw/engines/workbench/workbench_private.h12
-rw-r--r--source/blender/draw/intern/DRW_render.h13
-rw-r--r--source/blender/draw/intern/draw_common.c5
-rw-r--r--source/blender/draw/intern/draw_common.h4
-rw-r--r--source/blender/draw/intern/draw_manager.c4
-rw-r--r--source/blender/draw/intern/draw_manager.h6
-rw-r--r--source/blender/draw/intern/draw_manager_data.c48
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c26
-rw-r--r--source/blender/gpu/CMakeLists.txt4
-rw-r--r--source/blender/gpu/GPU_material.h20
-rw-r--r--source/blender/gpu/GPU_shader.h2
-rw-r--r--source/blender/gpu/GPU_uniform_buffer.h (renamed from source/blender/gpu/GPU_uniformbuffer.h)20
-rw-r--r--source/blender/gpu/GPU_viewport.h4
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c2
-rw-r--r--source/blender/gpu/intern/gpu_material.c37
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c8
-rw-r--r--source/blender/gpu/intern/gpu_shader.cc2
-rw-r--r--source/blender/gpu/intern/gpu_shader_builtin.c2
-rw-r--r--source/blender/gpu/intern/gpu_uniform_buffer.cc (renamed from source/blender/gpu/intern/gpu_uniformbuffer.cc)48
-rw-r--r--source/blender/gpu/intern/gpu_viewport.c6
-rw-r--r--source/blender/nodes/shader/node_shader_util.h2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_rgb.c2
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_value.cc2
41 files changed, 231 insertions, 241 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_data.c b/source/blender/draw/engines/eevee/eevee_data.c
index e18c43fc643..5c4ee015c86 100644
--- a/source/blender/draw/engines/eevee/eevee_data.c
+++ b/source/blender/draw/engines/eevee/eevee_data.c
@@ -254,7 +254,7 @@ EEVEE_ViewLayerData *EEVEE_view_layer_data_get(void)
static void eevee_view_layer_init(EEVEE_ViewLayerData *sldata)
{
- sldata->common_ubo = DRW_uniformbuffer_create(sizeof(sldata->common_data), NULL);
+ sldata->common_ubo = GPU_uniformbuf_create(sizeof(sldata->common_data));
}
EEVEE_ViewLayerData *EEVEE_view_layer_data_ensure_ex(struct ViewLayer *view_layer)
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 72f008ea66a..6ab267ceb03 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -267,7 +267,7 @@ static void eevee_draw_scene(void *vedata)
/* Set ray type. */
sldata->common_data.ray_type = EEVEE_RAY_CAMERA;
sldata->common_data.ray_depth = 0.0f;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
GPU_framebuffer_bind(fbl->main_fb);
eGPUFrameBufferBits clear_bits = GPU_DEPTH_BIT;
diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c
index a785d27c2db..088a08fb51a 100644
--- a/source/blender/draw/engines/eevee/eevee_lightcache.c
+++ b/source/blender/draw/engines/eevee/eevee_lightcache.c
@@ -942,7 +942,7 @@ static void eevee_lightbake_render_world_sample(void *ved, void *user_data)
sldata->common_data.ray_type = EEVEE_RAY_GLOSSY;
sldata->common_data.ray_depth = 1;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_world(sldata, vedata, lbake->rt_fb);
EEVEE_lightbake_filter_glossy(sldata,
vedata,
@@ -956,7 +956,7 @@ static void eevee_lightbake_render_world_sample(void *ved, void *user_data)
sldata->common_data.ray_type = EEVEE_RAY_DIFFUSE;
sldata->common_data.ray_depth = 1;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_world(sldata, vedata, lbake->rt_fb);
EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake->rt_color, lbake->store_fb, 0, 1.0f);
@@ -1079,7 +1079,7 @@ static void eevee_lightbake_render_grid_sample(void *ved, void *user_data)
if (lbake->bounce_curr == 0) {
common_data->prb_num_render_grid = 0;
}
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_scene(sldata, vedata, lbake->rt_fb, pos, prb->clipsta, prb->clipend);
@@ -1145,7 +1145,7 @@ static void eevee_lightbake_render_probe_sample(void *ved, void *user_data)
common_data->prb_num_render_cube = 0;
common_data->ray_type = EEVEE_RAY_GLOSSY;
common_data->ray_depth = 1;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_scene(
sldata, vedata, lbake->rt_fb, eprobe->position, prb->clipsta, prb->clipend);
@@ -1430,7 +1430,7 @@ void EEVEE_lightbake_update_world_quick(EEVEE_ViewLayerData *sldata,
sldata->common_data.ray_type = EEVEE_RAY_GLOSSY;
sldata->common_data.ray_depth = 1;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_world(sldata, vedata, lbake.rt_fb);
EEVEE_lightbake_filter_glossy(sldata,
vedata,
@@ -1444,7 +1444,7 @@ void EEVEE_lightbake_update_world_quick(EEVEE_ViewLayerData *sldata,
sldata->common_data.ray_type = EEVEE_RAY_DIFFUSE;
sldata->common_data.ray_depth = 1;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
EEVEE_lightbake_render_world(sldata, vedata, lbake.rt_fb);
EEVEE_lightbake_filter_diffuse(sldata, vedata, lbake.rt_color, lbake.store_fb, 0, 1.0f);
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 0f4a9dc79b6..63cc07c321e 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -39,6 +39,7 @@
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_texture.h"
+#include "GPU_uniform_buffer.h"
#include "DEG_depsgraph_query.h"
@@ -203,10 +204,9 @@ void EEVEE_lightprobes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
if (!sldata->probes) {
sldata->probes = MEM_callocN(sizeof(EEVEE_LightProbesInfo), "EEVEE_LightProbesInfo");
- sldata->probe_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightProbe) * MAX_PROBE, NULL);
- sldata->grid_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_LightGrid) * MAX_GRID, NULL);
- sldata->planar_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR,
- NULL);
+ sldata->probe_ubo = GPU_uniformbuf_create(sizeof(EEVEE_LightProbe) * MAX_PROBE);
+ sldata->grid_ubo = GPU_uniformbuf_create(sizeof(EEVEE_LightGrid) * MAX_GRID);
+ sldata->planar_ubo = GPU_uniformbuf_create(sizeof(EEVEE_PlanarReflection) * MAX_PLANAR);
}
common_data->prb_num_planar = 0;
@@ -724,8 +724,8 @@ void EEVEE_lightprobes_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *ved
eevee_lightprobes_extract_from_cache(sldata->probes, light_cache);
- DRW_uniformbuffer_update(sldata->probe_ubo, &sldata->probes->probe_data);
- DRW_uniformbuffer_update(sldata->grid_ubo, &sldata->probes->grid_data);
+ GPU_uniformbuf_update(sldata->probe_ubo, &sldata->probes->probe_data);
+ GPU_uniformbuf_update(sldata->grid_ubo, &sldata->probes->grid_data);
/* For shading, save max level of the octahedron map */
sldata->common_data.prb_lod_cube_max = (float)light_cache->mips_len;
@@ -1241,7 +1241,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
common_data->ray_type = EEVEE_RAY_GLOSSY;
common_data->ray_depth = 1.0f;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
/* Rendering happens here! */
eevee_lightbake_render_scene_to_planars(sldata, vedata);
@@ -1249,7 +1249,7 @@ void EEVEE_lightprobes_refresh_planar(EEVEE_ViewLayerData *sldata, EEVEE_Data *v
/* Make sure no additional visibility check runs after this. */
pinfo->vis_data.collection = NULL;
- DRW_uniformbuffer_update(sldata->planar_ubo, &sldata->probes->planar_data);
+ GPU_uniformbuf_update(sldata->planar_ubo, &sldata->probes->planar_data);
/* Restore */
common_data->prb_num_planar = pinfo->num_planar;
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index c6e8bac0949..b7112c07cab 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -214,5 +214,5 @@ void EEVEE_lights_cache_finish(EEVEE_ViewLayerData *sldata, EEVEE_Data *UNUSED(v
sldata->common_data.la_num_light = linfo->num_light;
- DRW_uniformbuffer_update(sldata->light_ubo, &linfo->light_data);
+ GPU_uniformbuf_update(sldata->light_ubo, &linfo->light_data);
}
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index f79d90500bd..6253203bab6 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -275,7 +275,7 @@ void EEVEE_lookdev_draw(EEVEE_Data *vedata)
common->ao_dist = 0.0f;
common->ao_factor = 0.0f;
common->ao_settings = 0.0f;
- DRW_uniformbuffer_update(sldata->common_ubo, common);
+ GPU_uniformbuf_update(sldata->common_ubo, common);
/* override matrices */
float winmat[4][4], viewmat[4][4];
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index fb07208be47..b6e20416dfb 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -243,33 +243,34 @@ void EEVEE_materials_init(EEVEE_ViewLayerData *sldata,
{
/* Create RenderPass UBO */
if (sldata->renderpass_ubo.combined == NULL) {
- sldata->renderpass_ubo.combined = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){true, true, true, true, true, false, false});
-
- sldata->renderpass_ubo.diff_color = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){true, false, false, false, false, true, false});
-
- sldata->renderpass_ubo.diff_light = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){true, true, false, false, false, false, false});
-
- sldata->renderpass_ubo.spec_color = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){false, false, true, false, false, false, false});
-
- sldata->renderpass_ubo.spec_light = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){false, false, true, true, false, false, false});
-
- sldata->renderpass_ubo.emit = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){false, false, false, false, true, false, false});
-
- sldata->renderpass_ubo.environment = DRW_uniformbuffer_create(
- sizeof(EEVEE_RenderPassData),
- &(const EEVEE_RenderPassData){true, true, true, true, true, false, true});
+ EEVEE_RenderPassData data;
+ data = (EEVEE_RenderPassData){true, true, true, true, true, false, false};
+ sldata->renderpass_ubo.combined = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.combined");
+
+ data = (EEVEE_RenderPassData){true, false, false, false, false, true, false};
+ sldata->renderpass_ubo.diff_color = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.diff_color");
+
+ data = (EEVEE_RenderPassData){true, true, false, false, false, false, false};
+ sldata->renderpass_ubo.diff_light = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.diff_light");
+
+ data = (EEVEE_RenderPassData){false, false, true, false, false, false, false};
+ sldata->renderpass_ubo.spec_color = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.spec_color");
+
+ data = (EEVEE_RenderPassData){false, false, true, true, false, false, false};
+ sldata->renderpass_ubo.spec_light = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.spec_light");
+
+ data = (EEVEE_RenderPassData){false, false, false, false, true, false, false};
+ sldata->renderpass_ubo.emit = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.emit");
+
+ data = (EEVEE_RenderPassData){true, true, true, true, true, false, true};
+ sldata->renderpass_ubo.environment = GPU_uniformbuf_create_ex(
+ sizeof(data), &data, "renderpass_ubo.environment");
}
/* Used combined pass by default. */
@@ -962,7 +963,7 @@ static void material_renderpass_accumulate(EEVEE_FramebufferList *fbl,
DRWPass *renderpass,
EEVEE_PrivateData *pd,
GPUTexture *output_tx,
- struct GPUUniformBuffer *renderpass_option_ubo)
+ struct GPUUniformBuf *renderpass_option_ubo)
{
GPU_framebuffer_texture_attach(fbl->material_accum_fb, output_tx, 0, 0);
GPU_framebuffer_bind(fbl->material_accum_fb);
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 40d7676c38c..9cde9e871e5 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -818,9 +818,9 @@ typedef struct EEVEE_ViewLayerData {
/* Lights */
struct EEVEE_LightsInfo *lights;
- struct GPUUniformBuffer *light_ubo;
- struct GPUUniformBuffer *shadow_ubo;
- struct GPUUniformBuffer *shadow_samples_ubo;
+ struct GPUUniformBuf *light_ubo;
+ struct GPUUniformBuf *shadow_ubo;
+ struct GPUUniformBuf *shadow_samples_ubo;
struct GPUFrameBuffer *shadow_fb;
@@ -832,24 +832,24 @@ typedef struct EEVEE_ViewLayerData {
/* Probes */
struct EEVEE_LightProbesInfo *probes;
- struct GPUUniformBuffer *probe_ubo;
- struct GPUUniformBuffer *grid_ubo;
- struct GPUUniformBuffer *planar_ubo;
+ struct GPUUniformBuf *probe_ubo;
+ struct GPUUniformBuf *grid_ubo;
+ struct GPUUniformBuf *planar_ubo;
/* Material Render passes */
struct {
- struct GPUUniformBuffer *combined;
- struct GPUUniformBuffer *environment;
- struct GPUUniformBuffer *diff_color;
- struct GPUUniformBuffer *diff_light;
- struct GPUUniformBuffer *spec_color;
- struct GPUUniformBuffer *spec_light;
- struct GPUUniformBuffer *emit;
+ struct GPUUniformBuf *combined;
+ struct GPUUniformBuf *environment;
+ struct GPUUniformBuf *diff_color;
+ struct GPUUniformBuf *diff_light;
+ struct GPUUniformBuf *spec_color;
+ struct GPUUniformBuf *spec_light;
+ struct GPUUniformBuf *emit;
} renderpass_ubo;
/* Common Uniform Buffer */
struct EEVEE_CommonUniformBuffer common_data;
- struct GPUUniformBuffer *common_ubo;
+ struct GPUUniformBuf *common_ubo;
struct LightCache *fallback_lightcache;
@@ -953,7 +953,7 @@ typedef struct EEVEE_PrivateData {
GPUTexture *renderpass_col_input;
GPUTexture *renderpass_light_input;
/* Renderpass ubo reference used by material pass. */
- struct GPUUniformBuffer *renderpass_ubo;
+ struct GPUUniformBuf *renderpass_ubo;
/** For rendering shadows. */
struct DRWView *cube_views[6];
/** For rendering probes. */
diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c
index 65a856c39e1..2351b06db98 100644
--- a/source/blender/draw/engines/eevee/eevee_render.c
+++ b/source/blender/draw/engines/eevee/eevee_render.c
@@ -574,7 +574,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl
/* Set ray type. */
sldata->common_data.ray_type = EEVEE_RAY_CAMERA;
sldata->common_data.ray_depth = 0.0f;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
GPU_framebuffer_bind(fbl->main_fb);
GPU_framebuffer_clear_color_depth_stencil(fbl->main_fb, clear_col, clear_depth, clear_stencil);
diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c
index 71a4da9fcab..79d89ab620c 100644
--- a/source/blender/draw/engines/eevee/eevee_shadows.c
+++ b/source/blender/draw/engines/eevee/eevee_shadows.c
@@ -71,8 +71,8 @@ void EEVEE_shadows_init(EEVEE_ViewLayerData *sldata)
if (!sldata->lights) {
sldata->lights = MEM_callocN(sizeof(EEVEE_LightsInfo), "EEVEE_LightsInfo");
- sldata->light_ubo = DRW_uniformbuffer_create(sizeof(EEVEE_Light) * MAX_LIGHT, NULL);
- sldata->shadow_ubo = DRW_uniformbuffer_create(shadow_ubo_size, NULL);
+ sldata->light_ubo = GPU_uniformbuf_create_ex(sizeof(EEVEE_Light) * MAX_LIGHT, NULL, "evLight");
+ sldata->shadow_ubo = GPU_uniformbuf_create_ex(shadow_ubo_size, NULL, "evShadow");
for (int i = 0; i < 2; i++) {
sldata->shcasters_buffers[i].bbox = MEM_callocN(
@@ -338,7 +338,7 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
if (any_visible) {
sldata->common_data.ray_type = EEVEE_RAY_SHADOW;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
}
DRW_stats_group_start("Cube Shadow Maps");
@@ -361,11 +361,11 @@ void EEVEE_shadows_draw(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
DRW_view_set_active(view);
- DRW_uniformbuffer_update(sldata->shadow_ubo, &linfo->shadow_data); /* Update all data at once */
+ GPU_uniformbuf_update(sldata->shadow_ubo, &linfo->shadow_data); /* Update all data at once */
if (any_visible) {
sldata->common_data.ray_type = saved_ray_type;
- DRW_uniformbuffer_update(sldata->common_ubo, &sldata->common_data);
+ GPU_uniformbuf_update(sldata->common_ubo, &sldata->common_data);
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c
index 74fb7ac99b7..5daa6e7c622 100644
--- a/source/blender/draw/engines/eevee/eevee_subsurface.c
+++ b/source/blender/draw/engines/eevee/eevee_subsurface.c
@@ -212,7 +212,7 @@ void EEVEE_subsurface_add_pass(EEVEE_ViewLayerData *sldata,
GPUTexture **depth_src = GPU_depth_blitting_workaround() ? &effects->sss_stencil : &dtxl->depth;
struct GPUTexture *sss_tex_profile = NULL;
- struct GPUUniformBuffer *sss_profile = GPU_material_sss_profile_get(
+ struct GPUUniformBuf *sss_profile = GPU_material_sss_profile_get(
gpumat, stl->effects->sss_sample_count, &sss_tex_profile);
if (!sss_profile) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_data.c b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
index 51152475a06..7faf426c4e0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_data.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_data.c
@@ -30,7 +30,7 @@
#include "BLI_math_color.h"
#include "BLI_memblock.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "IMB_imbuf_types.h"
@@ -46,7 +46,7 @@ static GPENCIL_MaterialPool *gpencil_material_pool_add(GPENCIL_PrivateData *pd)
matpool->next = NULL;
matpool->used_count = 0;
if (matpool->ubo == NULL) {
- matpool->ubo = GPU_uniformbuffer_create(sizeof(matpool->mat_data), NULL, NULL);
+ matpool->ubo = GPU_uniformbuf_create(sizeof(matpool->mat_data));
}
pd->last_material_pool = matpool;
return matpool;
@@ -301,7 +301,7 @@ void gpencil_material_resources_get(GPENCIL_MaterialPool *first_pool,
int mat_id,
GPUTexture **r_tex_stroke,
GPUTexture **r_tex_fill,
- GPUUniformBuffer **r_ubo_mat)
+ GPUUniformBuf **r_ubo_mat)
{
GPENCIL_MaterialPool *matpool = first_pool;
int pool_id = mat_id / GP_MATERIAL_BUFFER_LEN;
@@ -331,7 +331,7 @@ GPENCIL_LightPool *gpencil_light_pool_add(GPENCIL_PrivateData *pd)
/* Tag light list end. */
lightpool->light_data[0].color[0] = -1.0;
if (lightpool->ubo == NULL) {
- lightpool->ubo = GPU_uniformbuffer_create(sizeof(lightpool->light_data), NULL, NULL);
+ lightpool->ubo = GPU_uniformbuf_create(sizeof(lightpool->light_data));
}
pd->last_light_pool = lightpool;
return lightpool;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 015e631dc14..491ddfbcc94 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -42,7 +42,7 @@
#include "DNA_view3d_types.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "gpencil_engine.h"
@@ -345,8 +345,8 @@ typedef struct gpIterPopulateData {
GPENCIL_MaterialPool *matpool;
DRWShadingGroup *grp;
/* Last material UBO bound. Used to avoid uneeded buffer binding. */
- GPUUniformBuffer *ubo_mat;
- GPUUniformBuffer *ubo_lights;
+ GPUUniformBuf *ubo_mat;
+ GPUUniformBuf *ubo_lights;
/* Last texture bound. */
GPUTexture *tex_fill;
GPUTexture *tex_stroke;
@@ -501,7 +501,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
return;
}
- GPUUniformBuffer *ubo_mat;
+ GPUUniformBuf *ubo_mat;
GPUTexture *tex_stroke, *tex_fill;
gpencil_material_resources_get(
iter->matpool, iter->mat_ofs + gps->mat_nr, &tex_stroke, &tex_fill, &ubo_mat);
@@ -654,13 +654,13 @@ void GPENCIL_cache_finish(void *ved)
BLI_memblock_iternew(pd->gp_material_pool, &iter);
GPENCIL_MaterialPool *pool;
while ((pool = (GPENCIL_MaterialPool *)BLI_memblock_iterstep(&iter))) {
- GPU_uniformbuffer_update(pool->ubo, pool->mat_data);
+ GPU_uniformbuf_update(pool->ubo, pool->mat_data);
}
BLI_memblock_iternew(pd->gp_light_pool, &iter);
GPENCIL_LightPool *lpool;
while ((lpool = (GPENCIL_LightPool *)BLI_memblock_iterstep(&iter))) {
- GPU_uniformbuffer_update(lpool->ubo, lpool->light_data);
+ GPU_uniformbuf_update(lpool->ubo, lpool->light_data);
}
/* Sort object by decreasing Z to avoid most of alpha ordering issues. */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index a406df530fc..34d4488d066 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -108,7 +108,7 @@ typedef struct GPENCIL_MaterialPool {
/* GPU representatin of materials. */
gpMaterial mat_data[GP_MATERIAL_BUFFER_LEN];
/* Matching ubo. */
- struct GPUUniformBuffer *ubo;
+ struct GPUUniformBuf *ubo;
/* Texture per material. NULL means none. */
struct GPUTexture *tex_fill[GP_MATERIAL_BUFFER_LEN];
struct GPUTexture *tex_stroke[GP_MATERIAL_BUFFER_LEN];
@@ -120,7 +120,7 @@ typedef struct GPENCIL_LightPool {
/* GPU representatin of materials. */
gpLight light_data[GPENCIL_LIGHT_BUFFER_LEN];
/* Matching ubo. */
- struct GPUUniformBuffer *ubo;
+ struct GPUUniformBuf *ubo;
/* Number of light in the pool. */
int light_used;
} GPENCIL_LightPool;
@@ -384,7 +384,7 @@ void gpencil_material_resources_get(GPENCIL_MaterialPool *first_pool,
int mat_id,
struct GPUTexture **r_tex_stroke,
struct GPUTexture **r_tex_fill,
- struct GPUUniformBuffer **r_ubo_mat);
+ struct GPUUniformBuf **r_ubo_mat);
void gpencil_light_ambient_add(GPENCIL_LightPool *lightpool, const float color[3]);
void gpencil_light_pool_populate(GPENCIL_LightPool *matpool, Object *ob);
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 0d7f4ee660b..b6cfc019b8d 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -32,24 +32,24 @@
#include "UI_resources.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
/* -------------------------------------------------------------------- */
/** \name World Data
* \{ */
-GPUUniformBuffer *workbench_material_ubo_alloc(WORKBENCH_PrivateData *wpd)
+GPUUniformBuf *workbench_material_ubo_alloc(WORKBENCH_PrivateData *wpd)
{
- struct GPUUniformBuffer **ubo = BLI_memblock_alloc(wpd->material_ubo);
+ struct GPUUniformBuf **ubo = BLI_memblock_alloc(wpd->material_ubo);
if (*ubo == NULL) {
- *ubo = GPU_uniformbuffer_create(sizeof(WORKBENCH_UBO_Material) * MAX_MATERIAL, NULL, NULL);
+ *ubo = GPU_uniformbuf_create(sizeof(WORKBENCH_UBO_Material) * MAX_MATERIAL);
}
return *ubo;
}
static void workbench_ubo_free(void *elem)
{
- GPUUniformBuffer **ubo = elem;
+ GPUUniformBuf **ubo = elem;
DRW_UBO_FREE_SAFE(*ubo);
}
@@ -78,7 +78,7 @@ static WORKBENCH_ViewLayerData *workbench_view_layer_data_ensure_ex(struct ViewL
size_t matbuf_size = sizeof(WORKBENCH_UBO_Material) * MAX_MATERIAL;
(*vldata)->material_ubo_data = BLI_memblock_create_ex(matbuf_size, matbuf_size * 2);
(*vldata)->material_ubo = BLI_memblock_create_ex(sizeof(void *), sizeof(void *) * 8);
- (*vldata)->world_ubo = DRW_uniformbuffer_create(sizeof(WORKBENCH_UBO_World), NULL);
+ (*vldata)->world_ubo = GPU_uniformbuf_create_ex(sizeof(WORKBENCH_UBO_World), NULL, "wb_World");
}
return *vldata;
@@ -275,7 +275,7 @@ void workbench_update_world_ubo(WORKBENCH_PrivateData *wpd)
workbench_shadow_data_update(wpd, &wd);
workbench_cavity_data_update(wpd, &wd);
- DRW_uniformbuffer_update(wpd->world_ubo, &wd);
+ GPU_uniformbuf_update(wpd->world_ubo, &wd);
}
void workbench_update_material_ubos(WORKBENCH_PrivateData *UNUSED(wpd))
@@ -288,9 +288,9 @@ void workbench_update_material_ubos(WORKBENCH_PrivateData *UNUSED(wpd))
BLI_memblock_iternew(vldata->material_ubo_data, &iter_data);
WORKBENCH_UBO_Material *matchunk;
while ((matchunk = BLI_memblock_iterstep(&iter_data))) {
- GPUUniformBuffer **ubo = BLI_memblock_iterstep(&iter);
+ GPUUniformBuf **ubo = BLI_memblock_iterstep(&iter);
BLI_assert(*ubo != NULL);
- GPU_uniformbuffer_update(*ubo, matchunk);
+ GPU_uniformbuf_update(*ubo, matchunk);
}
BLI_memblock_clear(vldata->material_ubo, workbench_ubo_free);
diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.c b/source/blender/draw/engines/workbench/workbench_effect_cavity.c
index 4a8db65c02e..c9ac6660445 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_cavity.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.c
@@ -139,8 +139,8 @@ void workbench_cavity_samples_ubo_ensure(WORKBENCH_PrivateData *wpd)
float *samples = create_disk_samples(cavity_sample_count_single_iteration, max_iter_count);
wpd->vldata->cavity_jitter_tx = create_jitter_texture(cavity_sample_count);
/* NOTE: Uniform buffer needs to always be filled to be valid. */
- wpd->vldata->cavity_sample_ubo = DRW_uniformbuffer_create(
- sizeof(float[4]) * CAVITY_MAX_SAMPLES, samples);
+ wpd->vldata->cavity_sample_ubo = GPU_uniformbuf_create_ex(
+ sizeof(float[4]) * CAVITY_MAX_SAMPLES, samples, "wb_CavitySamples");
wpd->vldata->cavity_sample_count = cavity_sample_count;
MEM_freeN(samples);
}
diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c
index 32f6a3392b5..abbca0988d4 100644
--- a/source/blender/draw/engines/workbench/workbench_effect_dof.c
+++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c
@@ -74,7 +74,7 @@ static void square_to_circle(float x, float y, float *r, float *T)
#define KERNEL_RAD (3)
#define SAMP_LEN SQUARE_UNSAFE(KERNEL_RAD * 2 + 1)
-static void workbench_dof_setup_samples(struct GPUUniformBuffer **ubo,
+static void workbench_dof_setup_samples(struct GPUUniformBuf **ubo,
float **data,
float bokeh_sides,
float bokeh_rotation,
@@ -84,7 +84,7 @@ static void workbench_dof_setup_samples(struct GPUUniformBuffer **ubo,
*data = MEM_callocN(sizeof(float[4]) * SAMP_LEN, "workbench dof samples");
}
if (*ubo == NULL) {
- *ubo = DRW_uniformbuffer_create(sizeof(float[4]) * SAMP_LEN, NULL);
+ *ubo = GPU_uniformbuf_create(sizeof(float[4]) * SAMP_LEN);
}
float *samp = *data;
@@ -120,7 +120,7 @@ static void workbench_dof_setup_samples(struct GPUUniformBuffer **ubo,
}
}
- DRW_uniformbuffer_update(*ubo, *data);
+ GPU_uniformbuf_update(*ubo, *data);
}
void workbench_dof_engine_init(WORKBENCH_Data *vedata)
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 538083b4beb..6aa794bda51 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -33,7 +33,7 @@
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "ED_uvedit.h"
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 4a6dadc32fd..12e573a02d0 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -238,7 +238,7 @@ typedef struct WORKBENCH_PrivateData {
/** Copy of context mode for faster access. */
eContextObjectMode ctx_mode;
/** Shorthand for wpd->vldata->world_ubo. */
- struct GPUUniformBuffer *world_ubo;
+ struct GPUUniformBuf *world_ubo;
/** Background color to clear the color buffer with. */
float background_color[4];
@@ -309,7 +309,7 @@ typedef struct WORKBENCH_PrivateData {
struct BLI_memblock *material_ubo_data;
/** Current material chunk being filled by workbench_material_setup_ex(). */
WORKBENCH_UBO_Material *material_ubo_data_curr;
- struct GPUUniformBuffer *material_ubo_curr;
+ struct GPUUniformBuf *material_ubo_curr;
/** Copy of txl->dummy_image_tx for faster access. */
struct GPUTexture *dummy_image_tx;
/** Total number of used material chunk. */
@@ -359,11 +359,11 @@ typedef struct WORKBENCH_ObjectData {
typedef struct WORKBENCH_ViewLayerData {
/** Depth of field sample location array.*/
- struct GPUUniformBuffer *dof_sample_ubo;
+ struct GPUUniformBuf *dof_sample_ubo;
/** All constant data used for a render loop.*/
- struct GPUUniformBuffer *world_ubo;
+ struct GPUUniformBuf *world_ubo;
/** Cavity sample location array.*/
- struct GPUUniformBuffer *cavity_sample_ubo;
+ struct GPUUniformBuf *cavity_sample_ubo;
/** Blue noise texture used to randomize the sampling of some effects.*/
struct GPUTexture *cavity_jitter_tx;
/** Materials ubos allocated in a memblock for easy bookeeping. */
@@ -490,7 +490,7 @@ DRWShadingGroup *workbench_image_setup_ex(WORKBENCH_PrivateData *wpd,
void workbench_private_data_init(WORKBENCH_PrivateData *wpd);
void workbench_update_world_ubo(WORKBENCH_PrivateData *wpd);
void workbench_update_material_ubos(WORKBENCH_PrivateData *wpd);
-struct GPUUniformBuffer *workbench_material_ubo_alloc(WORKBENCH_PrivateData *wpd);
+struct GPUUniformBuf *workbench_material_ubo_alloc(WORKBENCH_PrivateData *wpd);
/* workbench_volume.c */
void workbench_volume_engine_init(WORKBENCH_Data *vedata);
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 63625fae185..697f4f77601 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -48,6 +48,7 @@
#include "GPU_primitive.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
+#include "GPU_uniform_buffer.h"
#include "draw_cache.h"
#include "draw_common.h"
@@ -67,7 +68,7 @@ struct GPUFrameBuffer;
struct GPUMaterial;
struct GPUShader;
struct GPUTexture;
-struct GPUUniformBuffer;
+struct GPUUniformBuf;
struct Object;
struct ParticleSystem;
struct RenderEngineType;
@@ -184,14 +185,10 @@ void DRW_texture_free(struct GPUTexture *tex);
} \
} while (0)
-/* UBOs */
-struct GPUUniformBuffer *DRW_uniformbuffer_create(int size, const void *data);
-void DRW_uniformbuffer_update(struct GPUUniformBuffer *ubo, const void *data);
-void DRW_uniformbuffer_free(struct GPUUniformBuffer *ubo);
#define DRW_UBO_FREE_SAFE(ubo) \
do { \
if (ubo != NULL) { \
- DRW_uniformbuffer_free(ubo); \
+ GPU_uniformbuf_free(ubo); \
ubo = NULL; \
} \
} while (0)
@@ -516,10 +513,10 @@ void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup,
struct GPUTexture **tex);
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
const char *name,
- const struct GPUUniformBuffer *ubo);
+ const struct GPUUniformBuf *ubo);
void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup,
const char *name,
- struct GPUUniformBuffer **ubo);
+ struct GPUUniformBuf **ubo);
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup,
const char *name,
const float *value,
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index aac9af088de..f80b5bd71fd 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -214,10 +214,11 @@ void DRW_globals_update(void)
}
if (G_draw.block_ubo == NULL) {
- G_draw.block_ubo = DRW_uniformbuffer_create(sizeof(GlobalsUboStorage), gb);
+ G_draw.block_ubo = GPU_uniformbuf_create_ex(
+ sizeof(GlobalsUboStorage), gb, "GlobalsUboStorage");
}
- DRW_uniformbuffer_update(G_draw.block_ubo, gb);
+ GPU_uniformbuf_update(G_draw.block_ubo, gb);
if (!G_draw.ramp) {
ColorBand ramp = {0};
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index d6402127e5e..645848e7fe0 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -205,11 +205,11 @@ struct DRW_Global {
* Not needed for constant color. */
GlobalsUboStorage block;
/** Define "globalsBlock" uniform for 'block'. */
- struct GPUUniformBuffer *block_ubo;
+ struct GPUUniformBuf *block_ubo;
struct GPUTexture *ramp;
struct GPUTexture *weight_ramp;
- struct GPUUniformBuffer *view_ubo;
+ struct GPUUniformBuf *view_ubo;
};
extern struct DRW_Global G_draw;
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index b515a83959e..5f3e981c92b 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -69,7 +69,7 @@
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_state.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "GPU_viewport.h"
#include "IMB_colormanagement.h"
@@ -600,7 +600,7 @@ static void drw_viewport_var_init(void)
}
if (G_draw.view_ubo == NULL) {
- G_draw.view_ubo = DRW_uniformbuffer_create(sizeof(DRWViewUboStorage), NULL);
+ G_draw.view_ubo = GPU_uniformbuf_create_ex(sizeof(DRWViewUboStorage), NULL, "G_draw.view_ubo");
}
if (DST.draw_list == NULL) {
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index d15a55e7bef..c0bcb0e679f 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -38,7 +38,7 @@
#include "GPU_drawlist.h"
#include "GPU_framebuffer.h"
#include "GPU_shader.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "GPU_viewport.h"
#include "draw_instance_data.h"
@@ -308,8 +308,8 @@ struct DRWUniform {
};
/* DRW_UNIFORM_BLOCK */
union {
- GPUUniformBuffer *block;
- GPUUniformBuffer **block_ref;
+ GPUUniformBuf *block;
+ GPUUniformBuf **block_ref;
};
/* DRW_UNIFORM_FLOAT_COPY */
float fvalue[4];
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index c12b4a96488..afea820b057 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -48,6 +48,7 @@
#include "GPU_buffers.h"
#include "GPU_material.h"
+#include "GPU_uniform_buffer.h"
#include "intern/gpu_codegen.h"
@@ -85,27 +86,12 @@ static void draw_call_sort(DRWCommand *array, DRWCommand *array_tmp, int array_l
memcpy(array, array_tmp, sizeof(*array) * array_len);
}
-GPUUniformBuffer *DRW_uniformbuffer_create(int size, const void *data)
-{
- return GPU_uniformbuffer_create(size, data, NULL);
-}
-
-void DRW_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
-{
- GPU_uniformbuffer_update(ubo, data);
-}
-
-void DRW_uniformbuffer_free(GPUUniformBuffer *ubo)
-{
- GPU_uniformbuffer_free(ubo);
-}
-
void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
{
int chunk_id = DRW_handle_chunk_get(&DST.resource_handle);
int elem_id = DRW_handle_id_get(&DST.resource_handle);
int ubo_len = 1 + chunk_id - ((elem_id == 0) ? 1 : 0);
- size_t list_size = sizeof(GPUUniformBuffer *) * ubo_len;
+ size_t list_size = sizeof(GPUUniformBuf *) * ubo_len;
/* TODO find a better system. currently a lot of obinfos UBO are going to be unused
* if not rendering with Eevee. */
@@ -118,8 +104,8 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
/* Remove unnecessary buffers */
for (int i = ubo_len; i < vmempool->ubo_len; i++) {
- GPU_uniformbuffer_free(vmempool->matrices_ubo[i]);
- GPU_uniformbuffer_free(vmempool->obinfos_ubo[i]);
+ GPU_uniformbuf_free(vmempool->matrices_ubo[i]);
+ GPU_uniformbuf_free(vmempool->obinfos_ubo[i]);
}
if (ubo_len != vmempool->ubo_len) {
@@ -133,15 +119,13 @@ void drw_resource_buffer_finish(ViewportMemoryPool *vmempool)
void *data_obmat = BLI_memblock_elem_get(vmempool->obmats, i, 0);
void *data_infos = BLI_memblock_elem_get(vmempool->obinfos, i, 0);
if (vmempool->matrices_ubo[i] == NULL) {
- vmempool->matrices_ubo[i] = GPU_uniformbuffer_create(
- sizeof(DRWObjectMatrix) * DRW_RESOURCE_CHUNK_LEN, data_obmat, NULL);
- vmempool->obinfos_ubo[i] = GPU_uniformbuffer_create(
- sizeof(DRWObjectInfos) * DRW_RESOURCE_CHUNK_LEN, data_infos, NULL);
- }
- else {
- GPU_uniformbuffer_update(vmempool->matrices_ubo[i], data_obmat);
- GPU_uniformbuffer_update(vmempool->obinfos_ubo[i], data_infos);
+ vmempool->matrices_ubo[i] = GPU_uniformbuf_create(sizeof(DRWObjectMatrix) *
+ DRW_RESOURCE_CHUNK_LEN);
+ vmempool->obinfos_ubo[i] = GPU_uniformbuf_create(sizeof(DRWObjectInfos) *
+ DRW_RESOURCE_CHUNK_LEN);
}
+ GPU_uniformbuf_update(vmempool->matrices_ubo[i], data_obmat);
+ GPU_uniformbuf_update(vmempool->obinfos_ubo[i], data_infos);
}
/* Aligned alloc to avoid unaligned memcpy. */
@@ -210,10 +194,10 @@ static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup,
memcpy(uni->fvalue, value, sizeof(float) * length);
break;
case DRW_UNIFORM_BLOCK:
- uni->block = (GPUUniformBuffer *)value;
+ uni->block = (GPUUniformBuf *)value;
break;
case DRW_UNIFORM_BLOCK_REF:
- uni->block_ref = (GPUUniformBuffer **)value;
+ uni->block_ref = (GPUUniformBuf **)value;
break;
case DRW_UNIFORM_TEXTURE:
uni->texture = (GPUTexture *)value;
@@ -279,16 +263,14 @@ void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name,
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup,
const char *name,
- const GPUUniformBuffer *ubo)
+ const GPUUniformBuf *ubo)
{
BLI_assert(ubo != NULL);
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
drw_shgroup_uniform_create_ex(shgroup, loc, DRW_UNIFORM_BLOCK, ubo, 0, 0, 1);
}
-void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup,
- const char *name,
- GPUUniformBuffer **ubo)
+void DRW_shgroup_uniform_block_ref(DRWShadingGroup *shgroup, const char *name, GPUUniformBuf **ubo)
{
BLI_assert(ubo != NULL);
int loc = GPU_shader_get_uniform_block_binding(shgroup->shader, name);
@@ -1327,7 +1309,7 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, struct GPUMaterial
}
}
- GPUUniformBuffer *ubo = GPU_material_uniform_buffer_get(material);
+ GPUUniformBuf *ubo = GPU_material_uniform_buffer_get(material);
if (ubo != NULL) {
DRW_shgroup_uniform_block(grp, GPU_UBO_BLOCK_NAME, ubo);
}
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 9902d3b0aeb..31d7cbaad40 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -296,7 +296,7 @@ void DRW_state_reset(void)
DRW_state_reset_ex(DRW_STATE_DEFAULT);
GPU_texture_unbind_all();
- GPU_uniformbuffer_unbind_all();
+ GPU_uniformbuf_unbind_all();
/* Should stay constant during the whole rendering. */
GPU_point_size(5);
@@ -648,18 +648,18 @@ static void draw_update_uniforms(DRWShadingGroup *shgroup,
GPU_texture_bind_ex(*uni->texture_ref, uni->sampler_state, uni->location, false);
break;
case DRW_UNIFORM_BLOCK:
- GPU_uniformbuffer_bind(uni->block, uni->location);
+ GPU_uniformbuf_bind(uni->block, uni->location);
break;
case DRW_UNIFORM_BLOCK_REF:
- GPU_uniformbuffer_bind(*uni->block_ref, uni->location);
+ GPU_uniformbuf_bind(*uni->block_ref, uni->location);
break;
case DRW_UNIFORM_BLOCK_OBMATS:
state->obmats_loc = uni->location;
- GPU_uniformbuffer_bind(DST.vmempool->matrices_ubo[0], uni->location);
+ GPU_uniformbuf_bind(DST.vmempool->matrices_ubo[0], uni->location);
break;
case DRW_UNIFORM_BLOCK_OBINFOS:
state->obinfos_loc = uni->location;
- GPU_uniformbuffer_bind(DST.vmempool->obinfos_ubo[0], uni->location);
+ GPU_uniformbuf_bind(DST.vmempool->obinfos_ubo[0], uni->location);
break;
case DRW_UNIFORM_RESOURCE_CHUNK:
state->chunkid_loc = uni->location;
@@ -769,12 +769,12 @@ static void draw_call_resource_bind(DRWCommandsState *state, const DRWResourceHa
GPU_shader_uniform_int(DST.shader, state->chunkid_loc, chunk);
}
if (state->obmats_loc != -1) {
- GPU_uniformbuffer_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
- GPU_uniformbuffer_bind(DST.vmempool->matrices_ubo[chunk], state->obmats_loc);
+ GPU_uniformbuf_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
+ GPU_uniformbuf_bind(DST.vmempool->matrices_ubo[chunk], state->obmats_loc);
}
if (state->obinfos_loc != -1) {
- GPU_uniformbuffer_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
- GPU_uniformbuffer_bind(DST.vmempool->obinfos_ubo[chunk], state->obinfos_loc);
+ GPU_uniformbuf_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
+ GPU_uniformbuf_bind(DST.vmempool->obinfos_ubo[chunk], state->obinfos_loc);
}
state->resource_chunk = chunk;
}
@@ -893,10 +893,10 @@ static void draw_call_batching_finish(DRWShadingGroup *shgroup, DRWCommandsState
GPU_front_facing(DST.view_active->is_inverted);
}
if (state->obmats_loc != -1) {
- GPU_uniformbuffer_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
+ GPU_uniformbuf_unbind(DST.vmempool->matrices_ubo[state->resource_chunk]);
}
if (state->obinfos_loc != -1) {
- GPU_uniformbuffer_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
+ GPU_uniformbuf_unbind(DST.vmempool->obinfos_ubo[state->resource_chunk]);
}
}
@@ -926,7 +926,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
/* Unbinding can be costly. Skip in normal condition. */
if (G.debug & G_DEBUG_GPU) {
GPU_texture_unbind_all();
- GPU_uniformbuffer_unbind_all();
+ GPU_uniformbuf_unbind_all();
}
}
GPU_shader_bind(shgroup->shader);
@@ -1062,7 +1062,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
static void drw_update_view(void)
{
/* TODO(fclem) update a big UBO and only bind ranges here. */
- DRW_uniformbuffer_update(G_draw.view_ubo, &DST.view_active->storage);
+ GPU_uniformbuf_update(G_draw.view_ubo, &DST.view_active->storage);
/* TODO get rid of this. */
DST.view_storage_cpy = DST.view_active->storage;
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 50a5a0243f8..3b867429acc 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -84,7 +84,7 @@ set(SRC
intern/gpu_shader_interface.cc
intern/gpu_state.cc
intern/gpu_texture.cc
- intern/gpu_uniformbuffer.cc
+ intern/gpu_uniform_buffer.cc
intern/gpu_vertex_buffer.cc
intern/gpu_vertex_format.cc
intern/gpu_viewport.c
@@ -122,7 +122,7 @@ set(SRC
GPU_shader.h
GPU_state.h
GPU_texture.h
- GPU_uniformbuffer.h
+ GPU_uniform_buffer.h
GPU_vertex_buffer.h
GPU_vertex_format.h
GPU_viewport.h
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 9dcf9b7d5bb..680e717e615 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -39,7 +39,7 @@ struct GPUNode;
struct GPUNodeLink;
struct GPUNodeStack;
struct GPUTexture;
-struct GPUUniformBuffer;
+struct GPUUniformBuf;
struct Image;
struct ImageUser;
struct ListBase;
@@ -158,10 +158,10 @@ bool GPU_stack_link(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out,
...);
-GPUNodeLink *GPU_uniformbuffer_link_out(struct GPUMaterial *mat,
- struct bNode *node,
- struct GPUNodeStack *stack,
- const int index);
+GPUNodeLink *GPU_uniformbuf_link_out(struct GPUMaterial *mat,
+ struct bNode *node,
+ struct GPUNodeStack *stack,
+ const int index);
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
@@ -169,9 +169,9 @@ void GPU_material_sss_profile_create(GPUMaterial *material,
float radii[3],
const short *falloff_type,
const float *sharpness);
-struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material,
- int sample_len,
- struct GPUTexture **tex_profile);
+struct GPUUniformBuf *GPU_material_sss_profile_get(GPUMaterial *material,
+ int sample_len,
+ struct GPUTexture **tex_profile);
/* High level functions to create and use GPU materials */
GPUMaterial *GPU_material_from_nodetree_find(struct ListBase *gpumaterials,
@@ -201,9 +201,9 @@ struct GPUShader *GPU_material_get_shader(GPUMaterial *material);
struct Material *GPU_material_get_material(GPUMaterial *material);
eGPUMaterialStatus GPU_material_status(GPUMaterial *mat);
-struct GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material);
+struct GPUUniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material);
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs);
-struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void);
+struct GPUUniformBuf *GPU_material_create_sss_profile_ubo(void);
bool GPU_material_has_surface_output(GPUMaterial *mat);
bool GPU_material_has_volume_output(GPUMaterial *mat);
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h
index b38cc1f3244..0aff7b11fc1 100644
--- a/source/blender/gpu/GPU_shader.h
+++ b/source/blender/gpu/GPU_shader.h
@@ -28,7 +28,7 @@ extern "C" {
#endif
struct GPUTexture;
-struct GPUUniformBuffer;
+struct GPUUniformBuf;
struct GPUVertBuf;
/* TODO(fclem) These members should be private and the
diff --git a/source/blender/gpu/GPU_uniformbuffer.h b/source/blender/gpu/GPU_uniform_buffer.h
index e2b2a757fb9..2f3ce61bce0 100644
--- a/source/blender/gpu/GPU_uniformbuffer.h
+++ b/source/blender/gpu/GPU_uniform_buffer.h
@@ -29,22 +29,20 @@ extern "C" {
struct ListBase;
-typedef struct GPUUniformBuffer GPUUniformBuffer;
+typedef struct GPUUniformBuf GPUUniformBuf;
-GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256]);
-GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(struct ListBase *inputs, char err_out[256]);
+GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name);
+GPUUniformBuf *GPU_uniformbuf_dynamic_create(struct ListBase *inputs, const char *name);
-void GPU_uniformbuffer_free(GPUUniformBuffer *ubo);
+#define GPU_uniformbuf_create(size) GPU_uniformbuf_create_ex(size, NULL, __func__);
-void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data);
-void GPU_uniformbuffer_dynamic_update(GPUUniformBuffer *ubo_);
+void GPU_uniformbuf_free(GPUUniformBuf *ubo);
-void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number);
-void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo);
-void GPU_uniformbuffer_unbind_all(void);
+void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data);
-bool GPU_uniformbuffer_is_empty(GPUUniformBuffer *ubo);
-bool GPU_uniformbuffer_is_dirty(GPUUniformBuffer *ubo);
+void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int number);
+void GPU_uniformbuf_unbind(GPUUniformBuf *ubo);
+void GPU_uniformbuf_unbind_all(void);
#define GPU_UBO_BLOCK_NAME "nodeTree"
diff --git a/source/blender/gpu/GPU_viewport.h b/source/blender/gpu/GPU_viewport.h
index 60b78ecd59b..c3e2f1788b4 100644
--- a/source/blender/gpu/GPU_viewport.h
+++ b/source/blender/gpu/GPU_viewport.h
@@ -55,8 +55,8 @@ typedef struct ViewportMemoryPool {
struct BLI_memblock *views;
struct BLI_memblock *passes;
struct BLI_memblock *images;
- struct GPUUniformBuffer **matrices_ubo;
- struct GPUUniformBuffer **obinfos_ubo;
+ struct GPUUniformBuf **matrices_ubo;
+ struct GPUUniformBuf **obinfos_ubo;
uint ubo_len;
} ViewportMemoryPool;
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index b051d4fe59a..1629584e841 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -43,7 +43,7 @@
#include "GPU_extensions.h"
#include "GPU_material.h"
#include "GPU_shader.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "GPU_vertex_format.h"
#include "BLI_sys_types.h" /* for intptr_t support */
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index 8df1f94238a..95fb0aa56fc 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -47,7 +47,7 @@
#include "GPU_material.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "DRW_engine.h"
@@ -88,11 +88,11 @@ struct GPUMaterial {
eGPUMatFlag flag;
/* Used by 2.8 pipeline */
- GPUUniformBuffer *ubo; /* UBOs for shader uniforms. */
+ GPUUniformBuf *ubo; /* UBOs for shader uniforms. */
/* Eevee SSS */
- GPUUniformBuffer *sss_profile; /* UBO containing SSS profile. */
- GPUTexture *sss_tex_profile; /* Texture containing SSS profile. */
+ GPUUniformBuf *sss_profile; /* UBO containing SSS profile. */
+ GPUTexture *sss_tex_profile; /* Texture containing SSS profile. */
float sss_enabled;
float sss_radii[3];
int sss_samples;
@@ -174,13 +174,13 @@ static void gpu_material_free_single(GPUMaterial *material)
GPU_pass_release(material->pass);
}
if (material->ubo != NULL) {
- GPU_uniformbuffer_free(material->ubo);
+ GPU_uniformbuf_free(material->ubo);
}
if (material->sss_tex_profile != NULL) {
GPU_texture_free(material->sss_tex_profile);
}
if (material->sss_profile != NULL) {
- GPU_uniformbuffer_free(material->sss_profile);
+ GPU_uniformbuf_free(material->sss_profile);
}
if (material->coba_tex != NULL) {
GPU_texture_free(material->coba_tex);
@@ -220,7 +220,7 @@ Material *GPU_material_get_material(GPUMaterial *material)
return material->ma;
}
-GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material)
+GPUUniformBuf *GPU_material_uniform_buffer_get(GPUMaterial *material)
{
return material->ubo;
}
@@ -232,7 +232,12 @@ GPUUniformBuffer *GPU_material_uniform_buffer_get(GPUMaterial *material)
*/
void GPU_material_uniform_buffer_create(GPUMaterial *material, ListBase *inputs)
{
- material->ubo = GPU_uniformbuffer_dynamic_create(inputs, NULL);
+#ifndef NDEBUG
+ const char *name = material->name;
+#else
+ const char *name = NULL;
+#endif
+ material->ubo = GPU_uniformbuf_dynamic_create(inputs, name);
}
/* Eevee Subsurface scattering. */
@@ -507,13 +512,13 @@ void GPU_material_sss_profile_create(GPUMaterial *material,
/* Update / Create UBO */
if (material->sss_profile == NULL) {
- material->sss_profile = GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
+ material->sss_profile = GPU_uniformbuf_create(sizeof(GPUSssKernelData));
}
}
-struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material,
- int sample_len,
- GPUTexture **tex_profile)
+struct GPUUniformBuf *GPU_material_sss_profile_get(GPUMaterial *material,
+ int sample_len,
+ GPUTexture **tex_profile)
{
if (!material->sss_enabled) {
return NULL;
@@ -530,7 +535,7 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material,
compute_sss_kernel(&kd, material->sss_radii, sample_len, material->sss_falloff, sharpness);
/* Update / Create UBO */
- GPU_uniformbuffer_update(material->sss_profile, &kd);
+ GPU_uniformbuf_update(material->sss_profile, &kd);
/* Update / Create Tex */
float *translucence_profile;
@@ -555,9 +560,9 @@ struct GPUUniformBuffer *GPU_material_sss_profile_get(GPUMaterial *material,
return material->sss_profile;
}
-struct GPUUniformBuffer *GPU_material_create_sss_profile_ubo(void)
+struct GPUUniformBuf *GPU_material_create_sss_profile_ubo(void)
{
- return GPU_uniformbuffer_create(sizeof(GPUSssKernelData), NULL, NULL);
+ return GPU_uniformbuf_create(sizeof(GPUSssKernelData));
}
#undef SSS_EXPONENT
@@ -735,7 +740,7 @@ GPUMaterial *GPU_material_from_nodetree(Scene *scene,
gpu_node_graph_free(&mat->graph);
}
- /* Only free after GPU_pass_shader_get where GPUUniformBuffer
+ /* Only free after GPU_pass_shader_get where GPUUniformBuf
* read data from the local tree. */
ntreeFreeLocalTree(localtree);
MEM_freeN(localtree);
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index 81cf2d69f4d..1b8a5e20240 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -592,10 +592,10 @@ bool GPU_stack_link(GPUMaterial *material,
return true;
}
-GPUNodeLink *GPU_uniformbuffer_link_out(GPUMaterial *mat,
- bNode *node,
- GPUNodeStack *stack,
- const int index)
+GPUNodeLink *GPU_uniformbuf_link_out(GPUMaterial *mat,
+ bNode *node,
+ GPUNodeStack *stack,
+ const int index)
{
return gpu_uniformbuffer_link(mat, node, stack, index, SOCK_OUT);
}
diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc
index 21678548b13..9437da19b78 100644
--- a/source/blender/gpu/intern/gpu_shader.cc
+++ b/source/blender/gpu/intern/gpu_shader.cc
@@ -41,7 +41,7 @@
#include "GPU_platform.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "gpu_backend.hh"
#include "gpu_context_private.hh"
diff --git a/source/blender/gpu/intern/gpu_shader_builtin.c b/source/blender/gpu/intern/gpu_shader_builtin.c
index da5bcaeca17..ed95a236da5 100644
--- a/source/blender/gpu/intern/gpu_shader_builtin.c
+++ b/source/blender/gpu/intern/gpu_shader_builtin.c
@@ -40,7 +40,7 @@
#include "GPU_platform.h"
#include "GPU_shader.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
/* Adjust these constants as needed. */
#define MAX_DEFINE_LENGTH 256
diff --git a/source/blender/gpu/intern/gpu_uniformbuffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc
index e203ffd848f..76459dcf9f0 100644
--- a/source/blender/gpu/intern/gpu_uniformbuffer.cc
+++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc
@@ -33,46 +33,52 @@
#include "GPU_extensions.h"
#include "GPU_glew.h"
#include "GPU_material.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
-typedef struct GPUUniformBuffer {
+typedef struct GPUUniformBuf {
/** Data size in bytes. */
int size;
/** GL handle for UBO. */
GLuint bindcode;
/** Current binding point. */
int bindpoint;
- /** Continuous memory block to copy to GPU. Is own by the GPUUniformBuffer. */
+ /** Continuous memory block to copy to GPU. Is own by the GPUUniformBuf. */
void *data;
-} GPUUniformBuffer;
-GPUUniformBuffer *GPU_uniformbuffer_create(int size, const void *data, char err_out[256])
+#ifndef NDEBUG
+ char name[64];
+#endif
+} GPUUniformBuf;
+
+GPUUniformBuf *GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
{
/* Make sure that UBO is padded to size of vec4 */
BLI_assert((size % 16) == 0);
if (size > GPU_max_ubo_size()) {
- if (err_out) {
- BLI_strncpy(err_out, "GPUUniformBuffer: UBO too big", 256);
- }
+ fprintf(stderr, "GPUUniformBuf: UBO too big. %s", name);
return NULL;
}
- GPUUniformBuffer *ubo = (GPUUniformBuffer *)MEM_mallocN(sizeof(GPUUniformBuffer), __func__);
+ GPUUniformBuf *ubo = (GPUUniformBuf *)MEM_mallocN(sizeof(GPUUniformBuf), __func__);
ubo->size = size;
ubo->data = NULL;
ubo->bindcode = 0;
ubo->bindpoint = -1;
+#ifndef NDEBUG
+ BLI_strncpy(ubo->name, name, sizeof(ubo->name));
+#endif
+
/* Direct init. */
if (data != NULL) {
- GPU_uniformbuffer_update(ubo, data);
+ GPU_uniformbuf_update(ubo, data);
}
return ubo;
}
-void GPU_uniformbuffer_free(GPUUniformBuffer *ubo)
+void GPU_uniformbuf_free(GPUUniformBuf *ubo)
{
MEM_SAFE_FREE(ubo->data);
GPU_buf_free(ubo->bindcode);
@@ -179,7 +185,7 @@ static void gpu_uniformbuffer_inputs_sort(ListBase *inputs)
*
* \param inputs: ListBase of #BLI_genericNodeN(#GPUInput).
*/
-GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_out[256])
+GPUUniformBuf *GPU_uniformbuf_dynamic_create(ListBase *inputs, const char *name)
{
/* There is no point on creating an UBO if there is no arguments. */
if (BLI_listbase_is_empty(inputs)) {
@@ -208,19 +214,19 @@ GPUUniformBuffer *GPU_uniformbuffer_dynamic_create(ListBase *inputs, char err_ou
}
/* Pass data as NULL for late init. */
- GPUUniformBuffer *ubo = GPU_uniformbuffer_create(buffer_size, NULL, err_out);
+ GPUUniformBuf *ubo = GPU_uniformbuf_create_ex(buffer_size, NULL, name);
/* Data will be update just before binding. */
ubo->data = data;
return ubo;
}
-static void gpu_uniformbuffer_init(GPUUniformBuffer *ubo)
+static void gpu_uniformbuffer_init(GPUUniformBuf *ubo)
{
BLI_assert(ubo->bindcode == 0);
ubo->bindcode = GPU_buf_alloc();
if (ubo->bindcode == 0) {
- fprintf(stderr, "GPUUniformBuffer: UBO create failed");
+ fprintf(stderr, "GPUUniformBuf: UBO create failed");
BLI_assert(0);
return;
}
@@ -229,7 +235,7 @@ static void gpu_uniformbuffer_init(GPUUniformBuffer *ubo)
glBufferData(GL_UNIFORM_BUFFER, ubo->size, NULL, GL_DYNAMIC_DRAW);
}
-void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
+void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
{
if (ubo->bindcode == 0) {
gpu_uniformbuffer_init(ubo);
@@ -240,10 +246,10 @@ void GPU_uniformbuffer_update(GPUUniformBuffer *ubo, const void *data)
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
-void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
+void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int number)
{
if (number >= GPU_max_ubo_binds()) {
- fprintf(stderr, "Not enough UBO slots.\n");
+ fprintf(stderr, "GPUUniformBuf: UBO too big.");
return;
}
@@ -252,7 +258,7 @@ void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
}
if (ubo->data != NULL) {
- GPU_uniformbuffer_update(ubo, ubo->data);
+ GPU_uniformbuf_update(ubo, ubo->data);
MEM_SAFE_FREE(ubo->data);
}
@@ -260,7 +266,7 @@ void GPU_uniformbuffer_bind(GPUUniformBuffer *ubo, int number)
ubo->bindpoint = number;
}
-void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo)
+void GPU_uniformbuf_unbind(GPUUniformBuf *ubo)
{
#ifndef NDEBUG
glBindBufferBase(GL_UNIFORM_BUFFER, ubo->bindpoint, 0);
@@ -268,7 +274,7 @@ void GPU_uniformbuffer_unbind(GPUUniformBuffer *ubo)
ubo->bindpoint = 0;
}
-void GPU_uniformbuffer_unbind_all(void)
+void GPU_uniformbuf_unbind_all(void)
{
for (int i = 0; i < GPU_max_ubo_binds(); i++) {
glBindBufferBase(GL_UNIFORM_BUFFER, i, 0);
diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c
index ba938349761..fd1265dc2a6 100644
--- a/source/blender/gpu/intern/gpu_viewport.c
+++ b/source/blender/gpu/intern/gpu_viewport.c
@@ -41,7 +41,7 @@
#include "GPU_immediate.h"
#include "GPU_matrix.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#include "GPU_viewport.h"
#include "DRW_engine.h"
@@ -1020,8 +1020,8 @@ void GPU_viewport_free(GPUViewport *viewport)
}
for (int i = 0; i < viewport->vmempool.ubo_len; i++) {
- GPU_uniformbuffer_free(viewport->vmempool.matrices_ubo[i]);
- GPU_uniformbuffer_free(viewport->vmempool.obinfos_ubo[i]);
+ GPU_uniformbuf_free(viewport->vmempool.matrices_ubo[i]);
+ GPU_uniformbuf_free(viewport->vmempool.obinfos_ubo[i]);
}
MEM_SAFE_FREE(viewport->vmempool.matrices_ubo);
MEM_SAFE_FREE(viewport->vmempool.obinfos_ubo);
diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h
index de192f51a5f..c1687e1a349 100644
--- a/source/blender/nodes/shader/node_shader_util.h
+++ b/source/blender/nodes/shader/node_shader_util.h
@@ -67,7 +67,7 @@
#include "GPU_material.h"
#include "GPU_texture.h"
-#include "GPU_uniformbuffer.h"
+#include "GPU_uniform_buffer.h"
#ifdef __cplusplus
# include "FN_multi_function_builder.hh"
diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c
index 47d9496c889..0bdef9a2a17 100644
--- a/source/blender/nodes/shader/nodes/node_shader_rgb.c
+++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c
@@ -35,7 +35,7 @@ static int gpu_shader_rgb(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- GPUNodeLink *link = GPU_uniformbuffer_link_out(mat, node, out, 0);
+ GPUNodeLink *link = GPU_uniformbuf_link_out(mat, node, out, 0);
return GPU_stack_link(mat, node, "set_rgba", in, out, link);
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc
index 1d7c3f47233..1a1382fa8af 100644
--- a/source/blender/nodes/shader/nodes/node_shader_value.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_value.cc
@@ -35,7 +35,7 @@ static int gpu_shader_value(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- GPUNodeLink *link = GPU_uniformbuffer_link_out(mat, node, out, 0);
+ GPUNodeLink *link = GPU_uniformbuf_link_out(mat, node, out, 0);
return GPU_stack_link(mat, node, "set_value", in, out, link);
}