[Mesa-dev] [PATCH 02/22] i965/meta: Small refactor to eliminate duplicated code
Ian Romanick
idr at freedesktop.org
Thu Feb 18 01:57:55 UTC 2016
From: Ian Romanick <ian.d.romanick at intel.com>
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_meta_fast_clear.c | 37 ++++++++++++-------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
index 00c59f3..37dffb9 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c
@@ -124,31 +124,28 @@ brw_bind_rep_write_shader(struct brw_context *brw, float *color)
" gl_FragColor = color;\n"
"}\n";
- GLuint vs, fs;
struct brw_fast_clear_state *clear = brw->fast_clear_state;
struct gl_context *ctx = &brw->ctx;
- if (clear->shader_prog) {
- _mesa_UseProgram(clear->shader_prog);
- _mesa_Uniform4fv(clear->color_location, 1, color);
- return;
+ if (clear->shader_prog == 0) {
+ GLuint vs =
+ _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
+ GLuint fs =
+ _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
+
+ clear->shader_prog = _mesa_CreateProgram();
+ _mesa_AttachShader(clear->shader_prog, fs);
+ _mesa_DeleteShader(fs);
+ _mesa_AttachShader(clear->shader_prog, vs);
+ _mesa_DeleteShader(vs);
+ _mesa_BindAttribLocation(clear->shader_prog, 0, "position");
+ _mesa_ObjectLabel(GL_PROGRAM, clear->shader_prog, -1, "meta repclear");
+ _mesa_LinkProgram(clear->shader_prog);
+
+ clear->color_location =
+ _mesa_GetUniformLocation(clear->shader_prog, "color");
}
- vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source);
- fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source);
-
- clear->shader_prog = _mesa_CreateProgram();
- _mesa_AttachShader(clear->shader_prog, fs);
- _mesa_DeleteShader(fs);
- _mesa_AttachShader(clear->shader_prog, vs);
- _mesa_DeleteShader(vs);
- _mesa_BindAttribLocation(clear->shader_prog, 0, "position");
- _mesa_ObjectLabel(GL_PROGRAM, clear->shader_prog, -1, "meta repclear");
- _mesa_LinkProgram(clear->shader_prog);
-
- clear->color_location =
- _mesa_GetUniformLocation(clear->shader_prog, "color");
-
_mesa_UseProgram(clear->shader_prog);
_mesa_Uniform4fv(clear->color_location, 1, color);
}
--
2.5.0
More information about the mesa-dev
mailing list