[Mesa-dev] [PATCH 2/3] st/mesa: use PIPE_SHADER_CAP_OUTPUT_READ
Vadim Girlin
vadimgirlin at gmail.com
Tue Nov 15 07:57:21 PST 2011
Don't replace outputs with temps when the driver supports reading outputs.
Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0bf6766..4797795 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4826,6 +4826,8 @@ get_mesa_program(struct gl_context *ctx,
{
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
+ struct pipe_screen * screen = st_context(ctx)->pipe->screen;
+ unsigned pipe_shader_type;
GLenum target;
const char *target_string;
bool progress;
@@ -4836,14 +4838,17 @@ get_mesa_program(struct gl_context *ctx,
case GL_VERTEX_SHADER:
target = GL_VERTEX_PROGRAM_ARB;
target_string = "vertex";
+ pipe_shader_type = PIPE_SHADER_VERTEX;
break;
case GL_FRAGMENT_SHADER:
target = GL_FRAGMENT_PROGRAM_ARB;
target_string = "fragment";
+ pipe_shader_type = PIPE_SHADER_FRAGMENT;
break;
case GL_GEOMETRY_SHADER:
target = GL_GEOMETRY_PROGRAM_NV;
target_string = "geometry";
+ pipe_shader_type = PIPE_SHADER_GEOMETRY;
break;
default:
assert(!"should not be reached");
@@ -4912,10 +4917,13 @@ get_mesa_program(struct gl_context *ctx,
}
#endif
- /* Remove reads to output registers, and to varyings in vertex shaders. */
- v->remove_output_reads(PROGRAM_OUTPUT);
- if (target == GL_VERTEX_PROGRAM_ARB)
- v->remove_output_reads(PROGRAM_VARYING);
+ if (!screen->get_shader_param(screen, pipe_shader_type,
+ PIPE_SHADER_CAP_OUTPUT_READ)) {
+ /* Remove reads to output registers, and to varyings in vertex shaders. */
+ v->remove_output_reads(PROGRAM_OUTPUT);
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ v->remove_output_reads(PROGRAM_VARYING);
+ }
/* Perform optimizations on the instructions in the glsl_to_tgsi_visitor. */
v->simplify_cmp();
--
1.7.7.1
More information about the mesa-dev
mailing list