meta: Push into desktop GL mode when doing meta operations.

This lets us simplify our shaders, and rely on GLES-prohibited
functionality (like ARB_texture_multisample) when writing these
driver-internal functions.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Eric Anholt 2014-02-11 12:10:59 -08:00
parent b3dcce65c9
commit 4e4a537ad5
2 changed files with 19 additions and 23 deletions

View file

@ -204,9 +204,6 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
fs_source = ralloc_asprintf(mem_ctx, fs_source = ralloc_asprintf(mem_ctx,
"#extension GL_EXT_texture_array : enable\n" "#extension GL_EXT_texture_array : enable\n"
"#extension GL_ARB_texture_cube_map_array: enable\n" "#extension GL_ARB_texture_cube_map_array: enable\n"
"#ifdef GL_ES\n"
"precision highp float;\n"
"#endif\n"
"uniform %s texSampler;\n" "uniform %s texSampler;\n"
"varying vec4 texCoords;\n" "varying vec4 texCoords;\n"
"void main()\n" "void main()\n"
@ -219,7 +216,7 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
} }
else { else {
vs_source = ralloc_asprintf(mem_ctx, vs_source = ralloc_asprintf(mem_ctx,
"#version %s\n" "#version 130\n"
"in vec2 position;\n" "in vec2 position;\n"
"in vec4 textureCoords;\n" "in vec4 textureCoords;\n"
"out vec4 texCoords;\n" "out vec4 texCoords;\n"
@ -227,14 +224,10 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
"{\n" "{\n"
" texCoords = textureCoords;\n" " texCoords = textureCoords;\n"
" gl_Position = vec4(position, 0.0, 1.0);\n" " gl_Position = vec4(position, 0.0, 1.0);\n"
"}\n", "}\n");
_mesa_is_desktop_gl(ctx) ? "130" : "300 es");
fs_source = ralloc_asprintf(mem_ctx, fs_source = ralloc_asprintf(mem_ctx,
"#version %s\n" "#version 130\n"
"#extension GL_ARB_texture_cube_map_array: enable\n" "#extension GL_ARB_texture_cube_map_array: enable\n"
"#ifdef GL_ES\n"
"precision highp float;\n"
"#endif\n"
"uniform %s texSampler;\n" "uniform %s texSampler;\n"
"in vec4 texCoords;\n" "in vec4 texCoords;\n"
"out vec4 out_color;\n" "out vec4 out_color;\n"
@ -244,7 +237,6 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx,
" out_color = texture(texSampler, %s);\n" " out_color = texture(texSampler, %s);\n"
" gl_FragDepth = out_color.x;\n" " gl_FragDepth = out_color.x;\n"
"}\n", "}\n",
_mesa_is_desktop_gl(ctx) ? "130" : "300 es",
shader->type, shader->type,
shader->texcoords); shader->texcoords);
} }
@ -401,6 +393,13 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
memset(save, 0, sizeof(*save)); memset(save, 0, sizeof(*save));
save->SavedState = state; save->SavedState = state;
/* We always push into desktop GL mode and pop out at the end. No sense in
* writing our shaders varying based on the user's context choice, when
* Mesa can handle either.
*/
save->API = ctx->API;
ctx->API = API_OPENGL_COMPAT;
/* Pausing transform feedback needs to be done early, or else we won't be /* Pausing transform feedback needs to be done early, or else we won't be
* able to change other state. * able to change other state.
*/ */
@ -753,6 +752,8 @@ _mesa_meta_end(struct gl_context *ctx)
const GLbitfield state = save->SavedState; const GLbitfield state = save->SavedState;
int i; int i;
ctx->API = save->API;
/* After starting a new occlusion query, initialize the results to the /* After starting a new occlusion query, initialize the results to the
* values saved previously. The driver will then continue to increment * values saved previously. The driver will then continue to increment
* these values. * these values.
@ -1482,9 +1483,6 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
" }\n" " }\n"
"}\n"; "}\n";
const char *fs_source = const char *fs_source =
"#ifdef GL_ES\n"
"precision highp float;\n"
"#endif\n"
"uniform vec4 color;\n" "uniform vec4 color;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
@ -1536,27 +1534,22 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear)
void *shader_source_mem_ctx = ralloc_context(NULL); void *shader_source_mem_ctx = ralloc_context(NULL);
const char *vs_int_source = const char *vs_int_source =
ralloc_asprintf(shader_source_mem_ctx, ralloc_asprintf(shader_source_mem_ctx,
"#version %s\n" "#version 130\n"
"in vec4 position;\n" "in vec4 position;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" gl_Position = position;\n" " gl_Position = position;\n"
"}\n", "}\n");
_mesa_is_desktop_gl(ctx) ? "130" : "300 es");
const char *fs_int_source = const char *fs_int_source =
ralloc_asprintf(shader_source_mem_ctx, ralloc_asprintf(shader_source_mem_ctx,
"#version %s\n" "#version 130\n"
"#ifdef GL_ES\n"
"precision highp float;\n"
"#endif\n"
"uniform ivec4 color;\n" "uniform ivec4 color;\n"
"out ivec4 out_color;\n" "out ivec4 out_color;\n"
"\n" "\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" out_color = color;\n" " out_color = color;\n"
"}\n", "}\n");
_mesa_is_desktop_gl(ctx) ? "130" : "300 es");
vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER,
vs_int_source); vs_int_source);

View file

@ -68,6 +68,9 @@ struct save_state
{ {
GLbitfield SavedState; /**< bitmask of MESA_META_* flags */ GLbitfield SavedState; /**< bitmask of MESA_META_* flags */
/* Always saved/restored with meta. */
gl_api API;
/** MESA_META_CLEAR (and others?) */ /** MESA_META_CLEAR (and others?) */
struct gl_query_object *CurrentOcclusionObject; struct gl_query_object *CurrentOcclusionObject;