mesa: Only validate shaders that can exist in the context
On Bay Trail-D using Fedora 20 compile flags (-m64 -O2 -mtune=generic for 64-bit and -m32 -march=i686 -mtune=atom for 32-bit), affects Gl32Batch7: 32-bit: Difference at 95.0% confidence 0.495267% +/- 0.202063% (n=40) 64-bit: Difference at 95.0% confidence 3.57576% +/- 0.288175% (n=40) Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
parent
14aadbe827
commit
d6c6b186cf
|
@ -1912,48 +1912,68 @@ shader_linked_or_absent(struct gl_context *ctx,
|
||||||
GLboolean
|
GLboolean
|
||||||
_mesa_valid_to_render(struct gl_context *ctx, const char *where)
|
_mesa_valid_to_render(struct gl_context *ctx, const char *where)
|
||||||
{
|
{
|
||||||
bool from_glsl_shader[MESA_SHADER_COMPUTE] = { false };
|
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* This depends on having up to date derived state (shaders) */
|
/* This depends on having up to date derived state (shaders) */
|
||||||
if (ctx->NewState)
|
if (ctx->NewState)
|
||||||
_mesa_update_state(ctx);
|
_mesa_update_state(ctx);
|
||||||
|
|
||||||
for (i = 0; i < MESA_SHADER_COMPUTE; i++) {
|
if (ctx->API == API_OPENGL_CORE || ctx->API == API_OPENGLES2) {
|
||||||
if (!shader_linked_or_absent(ctx, ctx->_Shader->CurrentProgram[i],
|
bool from_glsl_shader[MESA_SHADER_COMPUTE] = { false };
|
||||||
&from_glsl_shader[i], where))
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Any shader stages that are not supplied by the GLSL shader and have
|
for (i = 0; i < MESA_SHADER_COMPUTE; i++) {
|
||||||
* assembly shaders enabled must now be validated.
|
if (!shader_linked_or_absent(ctx, ctx->_Shader->CurrentProgram[i],
|
||||||
*/
|
&from_glsl_shader[i], where))
|
||||||
if (!from_glsl_shader[MESA_SHADER_VERTEX]
|
return GL_FALSE;
|
||||||
&& ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) {
|
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
|
||||||
"%s(vertex program not valid)", where);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FINISHME: If GL_NV_geometry_program4 is ever supported, the current
|
|
||||||
* FINISHME: geometry program should validated here.
|
|
||||||
*/
|
|
||||||
(void) from_glsl_shader[MESA_SHADER_GEOMETRY];
|
|
||||||
|
|
||||||
if (!from_glsl_shader[MESA_SHADER_FRAGMENT]) {
|
|
||||||
if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
|
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
|
||||||
"%s(fragment program not valid)", where);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If drawing to integer-valued color buffers, there must be an
|
/* In OpenGL Core Profile and OpenGL ES 2.0 / 3.0, there are no assembly
|
||||||
* active fragment shader (GL_EXT_texture_integer).
|
* shaders. Don't check state related to those.
|
||||||
*/
|
*/
|
||||||
if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) {
|
} else {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
bool has_vertex_shader = false;
|
||||||
"%s(integer format but no fragment shader)", where);
|
bool has_fragment_shader = false;
|
||||||
|
|
||||||
|
/* In OpenGL Compatibility Profile, there is only vertex shader and
|
||||||
|
* fragment shader. We take this path also for API_OPENGLES because
|
||||||
|
* optimizing that path would make the other (more common) paths
|
||||||
|
* slightly slower.
|
||||||
|
*/
|
||||||
|
if (!shader_linked_or_absent(ctx,
|
||||||
|
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX],
|
||||||
|
&has_vertex_shader, where))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
|
if (!shader_linked_or_absent(ctx,
|
||||||
|
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT],
|
||||||
|
&has_fragment_shader, where))
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
|
/* Any shader stages that are not supplied by the GLSL shader and have
|
||||||
|
* assembly shaders enabled must now be validated.
|
||||||
|
*/
|
||||||
|
if (!has_vertex_shader
|
||||||
|
&& ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"%s(vertex program not valid)", where);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!has_fragment_shader) {
|
||||||
|
if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"%s(fragment program not valid)", where);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If drawing to integer-valued color buffers, there must be an
|
||||||
|
* active fragment shader (GL_EXT_texture_integer).
|
||||||
|
*/
|
||||||
|
if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) {
|
||||||
|
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||||
|
"%s(integer format but no fragment shader)", where);
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue