Draw: Remove unused shader.

tile images aren't a special case anymore for the image engine.
This commit is contained in:
Jeroen Bakker 2022-01-28 10:47:52 +01:00
parent e1be275878
commit 49b9b0251b
4 changed files with 13 additions and 16 deletions

View File

@ -90,7 +90,7 @@ template<typename TextureMethod> class ScreenSpaceDrawingMode : public AbstractD
void add_shgroups(const IMAGE_InstanceData *instance_data) const
{
const ShaderParameters &sh_params = instance_data->sh_params;
GPUShader *shader = IMAGE_shader_image_get(false);
GPUShader *shader = IMAGE_shader_image_get();
DRWShadingGroup *shgrp = DRW_shgroup_create(shader, instance_data->passes.image_pass);
DRW_shgroup_uniform_vec2_copy(shgrp, "farNearDistances", sh_params.far_near);

View File

@ -72,7 +72,7 @@ class AbstractDrawingMode {
};
/* image_shader.c */
GPUShader *IMAGE_shader_image_get(bool is_tiled_image);
GPUShader *IMAGE_shader_image_get();
void IMAGE_shader_library_ensure();
void IMAGE_shader_free();

View File

@ -41,13 +41,13 @@ extern char datatoc_engine_image_vert_glsl[];
namespace blender::draw::image_engine {
struct IMAGE_Shaders {
GPUShader *image_sh[2];
GPUShader *image_sh;
};
static struct {
IMAGE_Shaders shaders;
DRWShaderLibrary *lib;
} e_data = {{{nullptr}}}; /* Engine data */
} e_data = {{nullptr}}; /* Engine data */
void IMAGE_shader_library_ensure()
{
@ -60,19 +60,17 @@ void IMAGE_shader_library_ensure()
}
}
GPUShader *IMAGE_shader_image_get(bool is_tiled_image)
GPUShader *IMAGE_shader_image_get()
{
const int index = is_tiled_image ? 1 : 0;
IMAGE_Shaders *sh_data = &e_data.shaders;
if (sh_data->image_sh[index] == nullptr) {
sh_data->image_sh[index] = DRW_shader_create_with_shaderlib(
datatoc_engine_image_vert_glsl,
nullptr,
datatoc_engine_image_frag_glsl,
e_data.lib,
is_tiled_image ? "#define TILED_IMAGE\n" : nullptr);
if (sh_data->image_sh == nullptr) {
sh_data->image_sh = DRW_shader_create_with_shaderlib(datatoc_engine_image_vert_glsl,
nullptr,
datatoc_engine_image_frag_glsl,
e_data.lib,
nullptr);
}
return sh_data->image_sh[index];
return sh_data->image_sh;
}
void IMAGE_shader_free()

View File

@ -185,8 +185,7 @@ static void test_image_glsl_shaders()
{
IMAGE_shader_library_ensure();
EXPECT_NE(IMAGE_shader_image_get(false), nullptr);
EXPECT_NE(IMAGE_shader_image_get(true), nullptr);
EXPECT_NE(IMAGE_shader_image_get(), nullptr);
IMAGE_shader_free();
}