diff options
Diffstat (limited to 'source/blender/gpu')
6 files changed, 30 insertions, 9 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 691c131b1c0..bb7e9e8b26f 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -432,6 +432,7 @@ shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh shaders/infos/gpu_shader_2D_area_borders_info.hh +shaders/infos/gpu_shader_2D_image_multi_rect_color_info.hh shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh shaders/infos/gpu_shader_3D_point_info.hh shaders/infos/gpu_shader_2D_nodelink_info.hh diff --git a/source/blender/gpu/GPU_shader_shared.h b/source/blender/gpu/GPU_shader_shared.h index 4d277921773..f400e151487 100644 --- a/source/blender/gpu/GPU_shader_shared.h +++ b/source/blender/gpu/GPU_shader_shared.h @@ -80,3 +80,10 @@ struct SimpleLightingData { float _pad; }; BLI_STATIC_ASSERT_ALIGN(struct SimpleLightingData, 16) + +#define MAX_CALLS 16 + +struct MultiRectCallData { + float4 calls_data[MAX_CALLS * 3]; +}; +BLI_STATIC_ASSERT_ALIGN(struct MultiRectCallData, 16) diff --git a/source/blender/gpu/intern/gpu_shader_builtin.c b/source/blender/gpu/intern/gpu_shader_builtin.c index cae7383f885..13f1774df03 100644 --- a/source/blender/gpu/intern/gpu_shader_builtin.c +++ b/source/blender/gpu/intern/gpu_shader_builtin.c @@ -210,12 +210,9 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { }, [GPU_SHADER_2D_IMAGE_RECT_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_RECT_COLOR", .create_info = "gpu_shader_2D_image_rect_color"}, - [GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR] = - { - .name = "GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR", - .vert = datatoc_gpu_shader_2D_image_multi_rect_vert_glsl, - .frag = datatoc_gpu_shader_image_varying_color_frag_glsl, - }, + [GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR] = {.name = "GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR", + .create_info = + "gpu_shader_2D_image_multi_rect_color"}, [GPU_SHADER_3D_UNIFORM_COLOR] = { diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl index f4d8a941a6d..9851e08fe2e 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl @@ -17,9 +17,9 @@ in vec2 pos; void main() { - vec4 rect = calls_data[gl_InstanceID * 3]; - vec4 tex = calls_data[gl_InstanceID * 3 + 1]; - finalColor = calls_data[gl_InstanceID * 3 + 2]; + vec4 rect = multi_rect_data.calls_data[gl_InstanceID * 3]; + vec4 tex = multi_rect_data.calls_data[gl_InstanceID * 3 + 1]; + finalColor = multi_rect_data.calls_data[gl_InstanceID * 3 + 2]; /* Use pos to select the right swizzle (instead of gl_VertexID) * in order to workaround an OSX driver bug. */ diff --git a/source/blender/gpu/shaders/infos/gpu_interface_info.hh b/source/blender/gpu/shaders/infos/gpu_interface_info.hh index b53b60fa587..d5ad333638f 100644 --- a/source/blender/gpu/shaders/infos/gpu_interface_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_interface_info.hh @@ -31,3 +31,6 @@ GPU_SHADER_INTERFACE_INFO(smooth_color_iface, "").smooth(Type::VEC4, "finalColor GPU_SHADER_INTERFACE_INFO(smooth_tex_coord_interp_iface, "").smooth(Type::VEC2, "texCoord_interp"); GPU_SHADER_INTERFACE_INFO(smooth_radii_iface, "").smooth(Type::VEC2, "radii"); GPU_SHADER_INTERFACE_INFO(smooth_radii_outline_iface, "").smooth(Type::VEC4, "radii"); +GPU_SHADER_INTERFACE_INFO(flat_color_smooth_tex_coord_interp_iface, "") + .flat(Type::VEC4, "finalColor") + .smooth(Type::VEC2, "texCoord_interp"); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_multi_rect_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_multi_rect_color_info.hh new file mode 100644 index 00000000000..4b154a045ee --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_multi_rect_color_info.hh @@ -0,0 +1,13 @@ +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_multi_rect_color) + .vertex_in(0, Type::VEC2, "pos") + .vertex_out(flat_color_smooth_tex_coord_interp_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .uniform_buf(0, "MultiRectCallData", "multi_rect_data") + .sampler(0, ImageType::FLOAT_2D, "image") + .typedef_source("GPU_shader_shared.h") + .vertex_source("gpu_shader_2D_image_multi_rect_vert.glsl") + .fragment_source("gpu_shader_image_varying_color_frag.glsl") + .do_static_compilation(true); |