diff options
author | Jeroen Bakker <jeroen@blender.org> | 2022-01-18 15:13:23 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-18 15:17:04 +0300 |
commit | 08d008a5085bf57ba43c7aa76d51ea60b732a11a (patch) | |
tree | 0e2f86d5f9ab3b4ee74c14deccbde76c249aef49 /source/blender/editors/interface/interface_icons.c | |
parent | 2486346f6f0418d90b714119466921ac1da477e4 (diff) |
GPU: Create Info for GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR.
This patch converts GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR shader to use
the GPUShaderCreateInfo pattern. It can be used as a reference when
converting other shaders.
In this special case the flat uniform vector cannot be used anymore as it
doesn't fit as push constants. To solve this a uniform buffer is used.
Diffstat (limited to 'source/blender/editors/interface/interface_icons.c')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 18018461ac2..0f5b4a1a0f1 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -31,6 +31,7 @@ #include "GPU_batch_presets.h" #include "GPU_immediate.h" #include "GPU_matrix.h" +#include "GPU_shader_shared.h" #include "GPU_state.h" #include "GPU_texture.h" @@ -1582,18 +1583,21 @@ static void icon_draw_cache_texture_flush_ex(GPUTexture *texture, GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR); GPU_shader_bind(shader); - const int img_binding = GPU_shader_get_texture_binding(shader, "image"); - const int data_loc = GPU_shader_get_uniform(shader, "calls_data"); + const int data_loc = GPU_shader_get_uniform_block(shader, "multi_rect_data"); + GPUUniformBuf *ubo = GPU_uniformbuf_create_ex( + sizeof(struct MultiRectCallData), texture_draw_calls->drawcall_cache, __func__); + GPU_uniformbuf_bind(ubo, data_loc); + const int img_binding = GPU_shader_get_texture_binding(shader, "image"); GPU_texture_bind_ex(texture, GPU_SAMPLER_ICON, img_binding, false); - GPU_shader_uniform_vector( - shader, data_loc, 4, ICON_DRAW_CACHE_SIZE * 3, (float *)texture_draw_calls->drawcall_cache); GPUBatch *quad = GPU_batch_preset_quad(); GPU_batch_set_shader(quad, shader); GPU_batch_draw_instanced(quad, texture_draw_calls->calls); GPU_texture_unbind(texture); + GPU_uniformbuf_unbind(ubo); + GPU_uniformbuf_free(ubo); texture_draw_calls->calls = 0; } |