From f0a36599007d2c5185d040202b84775ae1343785 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 5 Sep 2022 19:01:02 -0300 Subject: GPU: remove 'GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR' The only difference between `GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR` and `GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR` is that in the vertex shader the 2D version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses `vec4(pos, 1.0)`. But VBOs with 2D attributes work perfectly in shaders that use 3D attributes. Components not specified are filled with components from `vec4(0.0, 0.0, 0.0, 1.0)`. So there is no real benefit to having two different shader versions. --- .../gpu_shader_2D_line_dashed_uniform_color_vert.glsl | 13 ------------- .../gpu_shader_3D_line_dashed_uniform_color_info.hh | 18 ------------------ .../infos/gpu_shader_line_dashed_uniform_color_info.hh | 15 +++------------ 3 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl delete mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh (limited to 'source/blender/gpu/shaders') diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl deleted file mode 100644 index 7878dc18362..00000000000 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl +++ /dev/null @@ -1,13 +0,0 @@ - -/* - * Vertex Shader for dashed lines with 2D coordinates, - * with uniform multi-colors or uniform single-color, and unary thickness. - * - * Dashed is performed in screen space. - */ - -void main() -{ - gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); - stipple_start = stipple_pos = viewport_size * 0.5 * (gl_Position.xy / gl_Position.w); -} diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh deleted file mode 100644 index 2987077ffba..00000000000 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later - * Copyright 2022 Blender Foundation. All rights reserved. */ - -/** \file - * \ingroup gpu - */ - -#include "gpu_interface_info.hh" -#include "gpu_shader_create_info.hh" - -/* TODO(jbakker): Skipped as data doesn't fit as push constant. */ -GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) - .vertex_in(0, Type::VEC3, "pos") - .vertex_out(flat_color_iface) - .push_constant(Type::MAT4, "ModelViewProjectionMatrix") - .vertex_source("gpu_shader_3D_line_dashed_uniform_color_vert.glsl") - .fragment_source("gpu_shader_2D_line_dashed_frag.glsl") - .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh index 57cb02c8484..a2ac08c689b 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh @@ -13,7 +13,8 @@ GPU_SHADER_INTERFACE_INFO(gpu_shader_line_dashed_interface, "") .no_perspective(Type::VEC2, "stipple_start") /* In screen space */ .flat(Type::VEC2, "stipple_pos"); /* In screen space */ -GPU_SHADER_CREATE_INFO(gpu_shader_line_dashed) +GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) + .vertex_in(0, Type::VEC3, "pos") .vertex_out(flat_color_iface) .push_constant(Type::MAT4, "ModelViewProjectionMatrix") .push_constant(Type::VEC2, "viewport_size") @@ -25,18 +26,8 @@ GPU_SHADER_CREATE_INFO(gpu_shader_line_dashed) .push_constant(Type::VEC4, "color2") .vertex_out(gpu_shader_line_dashed_interface) .fragment_out(0, Type::VEC4, "fragColor") - .fragment_source("gpu_shader_2D_line_dashed_frag.glsl"); - -GPU_SHADER_CREATE_INFO(gpu_shader_2D_line_dashed_uniform_color) - .vertex_in(0, Type::VEC2, "pos") - .vertex_source("gpu_shader_2D_line_dashed_uniform_color_vert.glsl") - .additional_info("gpu_shader_line_dashed") - .do_static_compilation(true); - -GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) - .vertex_in(0, Type::VEC3, "pos") .vertex_source("gpu_shader_3D_line_dashed_uniform_color_vert.glsl") - .additional_info("gpu_shader_line_dashed") + .fragment_source("gpu_shader_2D_line_dashed_frag.glsl") .do_static_compilation(true); GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color_clipped) -- cgit v1.2.3