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:
authorJeroen Bakker <jeroen@blender.org>2022-01-18 15:13:23 +0300
committerJeroen Bakker <jeroen@blender.org>2022-01-18 15:17:04 +0300
commit08d008a5085bf57ba43c7aa76d51ea60b732a11a (patch)
tree0e2f86d5f9ab3b4ee74c14deccbde76c249aef49 /source/blender/gpu/shaders
parent2486346f6f0418d90b714119466921ac1da477e4 (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/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_2D_image_multi_rect_vert.glsl6
-rw-r--r--source/blender/gpu/shaders/infos/gpu_interface_info.hh3
-rw-r--r--source/blender/gpu/shaders/infos/gpu_shader_2D_image_multi_rect_color_info.hh13
3 files changed, 19 insertions, 3 deletions
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);