mesa: add a UniformBooleanTrue option

Drivers supporting native integers set UniformBooleanTrue to the integer value
that should be used for true when uploading uniform booleans.  This is ~0 for
Gallium and 1 for i965.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
Bryan Cain
2011-09-05 14:54:37 -05:00
parent f9b7d3bd4a
commit 4e64cfbb4e
4 changed files with 14 additions and 2 deletions

View File

@@ -253,8 +253,10 @@ GLboolean brwCreateContext( int api,
/* If we're using the new shader backend, we require integer uniforms /* If we're using the new shader backend, we require integer uniforms
* stored as actual integers. * stored as actual integers.
*/ */
if (brw->new_vs_backend) if (brw->new_vs_backend) {
ctx->Const.NativeIntegers = true; ctx->Const.NativeIntegers = true;
ctx->Const.UniformBooleanTrue = 1;
}
return GL_TRUE; return GL_TRUE;
} }

View File

@@ -2722,6 +2722,12 @@ struct gl_constants
*/ */
GLboolean NativeIntegers; GLboolean NativeIntegers;
/**
* If the driver supports real 32-bit integers, what integer value should be
* used for boolean true in uniform uploads? (Usually 1 or ~0.)
*/
GLuint UniformBooleanTrue;
/** Which texture units support GL_ATI_envmap_bumpmap as targets */ /** Which texture units support GL_ATI_envmap_bumpmap as targets */
GLbitfield SupportedBumpUnits; GLbitfield SupportedBumpUnits;

View File

@@ -802,7 +802,10 @@ set_program_uniform(struct gl_context *ctx, struct gl_program *program,
else else
uniformVal[i].b = uniformVal[i].u ? 1 : 0; uniformVal[i].b = uniformVal[i].u ? 1 : 0;
if (!ctx->Const.NativeIntegers) if (ctx->Const.NativeIntegers)
uniformVal[i].u =
uniformVal[i].b ? ctx->Const.UniformBooleanTrue : 0;
else
uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f; uniformVal[i].f = uniformVal[i].b ? 1.0f : 0.0f;
} }
} }

View File

@@ -207,6 +207,7 @@ void st_init_limits(struct st_context *st)
c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET); c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
c->GLSLVersion = 120; c->GLSLVersion = 120;
c->UniformBooleanTrue = ~0;
} }
} }