[Mesa-dev] [PATCH 2/3] glsl_to_tgsi: follow SHADER_CAP_INTEGERS with per-stage granularity
Marek Olšák
maraeo at gmail.com
Tue Jul 3 17:35:38 PDT 2012
Some drivers support integers only in vertex shaders (e.g. those which use
Draw).
Const.NativeIntegers is now useless for Gallium.
---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b6abe84..9fa298f 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4742,6 +4742,22 @@ out:
}
/* ----------------------------- End TGSI code ------------------------------ */
+static unsigned
+gl_shader_to_pipe_shader(unsigned gl_shader)
+{
+ switch (gl_shader) {
+ case GL_VERTEX_SHADER:
+ return PIPE_SHADER_VERTEX;
+ case GL_GEOMETRY_SHADER:
+ return PIPE_SHADER_GEOMETRY;
+ case GL_FRAGMENT_SHADER:
+ return PIPE_SHADER_FRAGMENT;
+ default:
+ assert(!"should not be reached");
+ return 0;
+ }
+}
+
/**
* Convert a shader's GLSL IR into a Mesa gl_program, although without
* generating Mesa IR.
@@ -4751,6 +4767,7 @@ get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
struct gl_shader *shader)
{
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
glsl_to_tgsi_visitor* v = new glsl_to_tgsi_visitor();
struct gl_program *prog;
GLenum target;
@@ -4788,7 +4805,10 @@ get_mesa_program(struct gl_context *ctx,
v->shader_program = shader_program;
v->options = options;
v->glsl_version = ctx->Const.GLSLVersion;
- v->native_integers = ctx->Const.NativeIntegers;
+ v->native_integers =
+ screen->get_shader_param(screen,
+ gl_shader_to_pipe_shader(shader->Type),
+ PIPE_SHADER_CAP_INTEGERS);
_mesa_generate_parameters_list_for_uniforms(shader_program, shader,
prog->Parameters);
@@ -4951,6 +4971,7 @@ st_new_shader_program(struct gl_context *ctx, GLuint name)
GLboolean
st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
{
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
assert(prog->LinkStatus);
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
@@ -4967,7 +4988,10 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
EXP_TO_EXP2 | LOG_TO_LOG2;
if (options->EmitNoPow)
what_to_lower |= POW_TO_EXP2;
- if (!ctx->Const.NativeIntegers)
+
+ if (!screen->get_shader_param(screen,
+ gl_shader_to_pipe_shader(prog->_LinkedShaders[i]->Type),
+ PIPE_SHADER_CAP_INTEGERS))
what_to_lower |= INT_DIV_TO_MUL_RCP;
progress = false;
--
1.7.4.1
More information about the mesa-dev
mailing list