Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include <cstring>
#include "BLI_blenlib.h"
#include "BLI_math_base.h"
#include "gpu_backend.hh"
#include "gpu_node_graph.h"
#include "GPU_material.h"
#include "GPU_uniform_buffer.h"
#include "gpu_uniform_buffer_private.hh"
Go to the source code of this file.
Namespaces | |
blender | |
blender::gpu | |
Macros | |
#define | MAX_UBO_GPU_TYPE GPU_MAT4 |
Functions | |
Uniform buffer from GPUInput list | |
static eGPUType | get_padded_gpu_type (LinkData *link) |
static int | inputs_cmp (const void *a, const void *b) |
static void | buffer_from_list_inputs_sort (ListBase *inputs) |
static size_t | buffer_size_from_list (ListBase *inputs) |
static void | buffer_fill_from_list (void *data, ListBase *inputs) |
C-API | |
GPUUniformBuf * | GPU_uniformbuf_create_ex (size_t size, const void *data, const char *name) |
GPUUniformBuf * | GPU_uniformbuf_create_from_list (ListBase *inputs, const char *name) |
void | GPU_uniformbuf_free (GPUUniformBuf *ubo) |
void | GPU_uniformbuf_update (GPUUniformBuf *ubo, const void *data) |
void | GPU_uniformbuf_bind (GPUUniformBuf *ubo, int slot) |
void | GPU_uniformbuf_unbind (GPUUniformBuf *ubo) |
void | GPU_uniformbuf_unbind_all () |
Definition at line 159 of file gpu_uniform_buffer.cc.
References data, get_padded_gpu_type(), input, inputs, LISTBASE_FOREACH, and offset.
Referenced by GPU_uniformbuf_create_from_list().
Make sure we respect the expected alignment of UBOs. mat4, vec4, pad vec3 as vec4, then vec2, then floats.
Definition at line 83 of file gpu_uniform_buffer.cc.
References BLI_assert_msg, BLI_insertlinkafter(), BLI_listbase_sort(), BLI_remlink(), LinkData::data, GPU_FLOAT, GPU_MAT3, GPU_VEC3, if(), input, inputs, inputs_cmp(), LISTBASE_FOREACH, MAX_UBO_GPU_TYPE, and LinkData::next.
Referenced by GPU_uniformbuf_create_from_list().
|
inlinestatic |
Definition at line 145 of file gpu_uniform_buffer.cc.
References divide_ceil_u(), float(), get_padded_gpu_type(), inputs, and LISTBASE_FOREACH.
Referenced by GPU_uniformbuf_create_from_list().
We need to pad some data types (vec3) on the C side To match the GPU expected memory block alignment.
Definition at line 55 of file gpu_uniform_buffer.cc.
References LinkData::data, GPU_FLOAT, GPU_VEC3, GPU_VEC4, if(), input, and LinkData::next.
Referenced by buffer_fill_from_list(), and buffer_size_from_list().
void GPU_uniformbuf_bind | ( | GPUUniformBuf * | ubo, |
int | slot | ||
) |
Definition at line 216 of file gpu_uniform_buffer.cc.
References blender::gpu::unwrap().
Referenced by draw_call_resource_bind(), draw_subdiv_ubo_update_and_bind(), draw_update_uniforms(), DRW_sparse_uniform_buffer_bind(), icon_draw_cache_texture_flush_ex(), immBindUniformBuf(), and pygpu_shader_uniform_block().
GPUUniformBuf* GPU_uniformbuf_create_ex | ( | size_t | size, |
const void * | data, | ||
const char * | name | ||
) |
Definition at line 178 of file gpu_uniform_buffer.cc.
References data, blender::gpu::GPUBackend::get(), size(), blender::gpu::GPUBackend::uniformbuf_alloc(), blender::gpu::UniformBuf::update(), and blender::gpu::wrap().
Referenced by createGPUShader(), draw_subdiv_ubo_update_and_bind(), DRW_draw_depth_object(), DRW_globals_update(), drw_manager_init(), EEVEE_materials_init(), EEVEE_shadows_init(), gpencil_draw_stroke_3d(), icon_draw_cache_texture_flush_ex(), blender::ed::space_node::node_draw_link_bezier(), blender::ed::space_node::nodelink_batch_draw(), pygpu_uniformbuffer__tp_new(), ui_draw_but_UNITVEC(), blender::draw::detail::UniformCommon< T, len, device_only >::UniformCommon(), workbench_cavity_samples_ubo_ensure(), and workbench_view_layer_data_ensure_ex().
GPUUniformBuf* GPU_uniformbuf_create_from_list | ( | struct ListBase * | inputs, |
const char * | name | ||
) |
Create UBO from inputs list. Return NULL if failed to create or if
inputs | is empty. |
inputs | ListBase of BLI_genericNodeN(GPUInput). |
Definition at line 188 of file gpu_uniform_buffer.cc.
References blender::gpu::UniformBuf::attach_data(), BLI_listbase_is_empty(), buffer_fill_from_list(), buffer_from_list_inputs_sort(), buffer_size_from_list(), data, blender::gpu::GPUBackend::get(), inputs, MEM_mallocN, blender::gpu::GPUBackend::uniformbuf_alloc(), and blender::gpu::wrap().
Referenced by GPU_material_uniform_buffer_create().
void GPU_uniformbuf_free | ( | GPUUniformBuf * | ubo | ) |
Definition at line 206 of file gpu_uniform_buffer.cc.
References blender::gpu::unwrap().
Referenced by BPyGPUUniformBuf__tp_dealloc(), draw_subdiv_cache_free(), DRW_draw_depth_object(), drw_resource_buffer_finish(), DRW_sparse_uniform_buffer_clear(), DRW_viewport_data_free(), gpencil_draw_stroke_3d(), gpu_material_free_single(), icon_draw_cache_texture_flush_ex(), blender::ed::space_node::node_draw_link_bezier(), blender::ed::space_node::nodelink_batch_draw(), ui_draw_but_UNITVEC(), OCIO_GPUCurveMappping::~OCIO_GPUCurveMappping(), OCIO_GPUShader::~OCIO_GPUShader(), OCIO_GPUTextures::~OCIO_GPUTextures(), and blender::draw::detail::UniformCommon< T, len, device_only >::~UniformCommon().
void GPU_uniformbuf_unbind | ( | GPUUniformBuf * | ubo | ) |
Definition at line 221 of file gpu_uniform_buffer.cc.
References blender::gpu::unwrap().
Referenced by draw_call_batching_finish(), draw_call_resource_bind(), DRW_sparse_uniform_buffer_unbind(), icon_draw_cache_texture_flush_ex(), blender::ed::space_node::node_draw_link_bezier(), and blender::ed::space_node::nodelink_batch_draw().
Definition at line 226 of file gpu_uniform_buffer.cc.
Referenced by draw_shgroup(), and DRW_state_reset().
void GPU_uniformbuf_update | ( | GPUUniformBuf * | ubo, |
const void * | data | ||
) |
Definition at line 211 of file gpu_uniform_buffer.cc.
References data, and blender::gpu::unwrap().
Referenced by draw_subdiv_ubo_update_and_bind(), DRW_globals_update(), drw_resource_buffer_finish(), DRW_sparse_uniform_buffer_flush(), drw_update_view(), eevee_draw_scene(), eevee_lightbake_render_grid_sample(), eevee_lightbake_render_probe_sample(), eevee_lightbake_render_world_sample(), EEVEE_lightbake_update_world_quick(), EEVEE_lightprobes_cache_finish(), EEVEE_lightprobes_refresh_planar(), EEVEE_lights_cache_finish(), EEVEE_lookdev_draw(), EEVEE_material_output_accumulate(), EEVEE_materials_init(), EEVEE_render_draw(), EEVEE_shadows_draw(), GPENCIL_cache_finish(), GPU_material_sss_profile_get(), OVERLAY_grid_cache_init(), blender::draw::detail::UniformCommon< T, len, device_only >::push_update(), pygpu_uniformbuffer_update(), updateGPUCurveMapping(), updateGPUDisplayParameters(), workbench_dof_setup_samples(), workbench_update_material_ubos(), and workbench_update_world_ubo().
Returns 1 if the first item should be after second item. We make sure the vec4 uniforms come first.
Definition at line 71 of file gpu_uniform_buffer.cc.
References Freestyle::a, usdtokens::b(), LinkData::data, and GPUInput::type.
Referenced by buffer_from_list_inputs_sort().