GPU: Remove runtime sampler texture slot assignment

This avoid potential shader recompilation and is more in line
with vulkan design.
This commit is contained in:
Clément Foucault 2022-02-17 18:14:03 +01:00
parent 37fa1bc254
commit 8355ac97b4
5 changed files with 3 additions and 8 deletions

@ -1926,7 +1926,6 @@ static void sequencer_draw_display_buffer(const bContext *C,
if (!glsl_used) {
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
immUniform1i("image", 0);
}
immBegin(GPU_PRIM_TRI_FAN, 4);

@ -277,8 +277,6 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo
GPU_matrix_identity_set();
GPU_matrix_identity_projection_set();
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE);
immUniform1i("overlayTexture", 0);
immUniform1i("imageTexture", 1);
int settings = stereo_format->display_mode;
if (settings == S3D_DISPLAY_ANAGLYPH) {
switch (stereo_format->anaglyph_type) {
@ -432,8 +430,6 @@ static void gpu_viewport_draw_colormanaged(GPUViewport *viewport,
GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE);
GPU_batch_uniform_1i(batch, "overlay", do_overlay_merge);
GPU_batch_uniform_1i(batch, "display_transform", display_colorspace);
GPU_batch_uniform_1i(batch, "image_texture", 0);
GPU_batch_uniform_1i(batch, "overlays_texture", 1);
}
GPU_texture_bind(color, 0);

@ -16,6 +16,7 @@ GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge)
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")
.push_constant(Type::BOOL, "display_transform")
.push_constant(Type::BOOL, "overlay")
/* Sampler slots should match OCIO's. */
.sampler(0, ImageType::FLOAT_2D, "image_texture")
.sampler(1, ImageType::FLOAT_2D, "overlays_texture")
.vertex_source("gpu_shader_2D_image_vert.glsl")

@ -483,7 +483,6 @@ static void draw_display_buffer(PlayState *ps, ImBuf *ibuf)
if (!glsl_used) {
immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
immUniformColor3f(1.0f, 1.0f, 1.0f);
immUniform1i("image", 0);
}
immBegin(GPU_PRIM_TRI_FAN, 4);

@ -67,7 +67,7 @@ void wm_stereo3d_draw_sidebyside(wmWindow *win, int view)
const float halfx = GLA_PIXEL_OFS / sizex;
const float halfy = GLA_PIXEL_OFS / sizex;
immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */
/* Texture is already bound to GL_TEXTURE0 unit. */
immBegin(GPU_PRIM_TRI_FAN, 4);
@ -111,7 +111,7 @@ void wm_stereo3d_draw_topbottom(wmWindow *win, int view)
const float halfx = GLA_PIXEL_OFS / sizex;
const float halfy = GLA_PIXEL_OFS / sizex;
immUniform1i("image", 0); /* texture is already bound to GL_TEXTURE0 unit */
/* Texture is already bound to GL_TEXTURE0 unit. */
immBegin(GPU_PRIM_TRI_FAN, 4);