mesa: move ShaderCompilerOptions into gl_constants

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
This commit is contained in:
Marek Olšák
2014-08-03 04:31:56 +02:00
parent 5c69173907
commit 002211f9ee
19 changed files with 37 additions and 37 deletions

View File

@@ -1472,7 +1472,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
if (!state->error && !shader->ir->is_empty()) { if (!state->error && !shader->ir->is_empty()) {
struct gl_shader_compiler_options *options = struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[shader->Stage]; &ctx->Const.ShaderCompilerOptions[shader->Stage];
/* Do some optimization at compile time to reduce shader IR size /* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times * and reduce later work if the same shader is linked multiple times

View File

@@ -329,7 +329,7 @@ tfeedback_decl::init(struct gl_context *ctx, const void *mem_ctx,
* class must behave specially to account for the fact that gl_ClipDistance * class must behave specially to account for the fact that gl_ClipDistance
* is converted from a float[8] to a vec4[2]. * is converted from a float[8] to a vec4[2].
*/ */
if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance && if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].LowerClipDistance &&
strcmp(this->var_name, "gl_ClipDistance") == 0) { strcmp(this->var_name, "gl_ClipDistance") == 0) {
this->is_clip_distance_mesa = true; this->is_clip_distance_mesa = true;
} }

View File

@@ -2660,12 +2660,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (!prog->LinkStatus) if (!prog->LinkStatus)
goto done; goto done;
if (ctx->ShaderCompilerOptions[i].LowerClipDistance) { if (ctx->Const.ShaderCompilerOptions[i].LowerClipDistance) {
lower_clip_distance(prog->_LinkedShaders[i]); lower_clip_distance(prog->_LinkedShaders[i]);
} }
while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
&ctx->ShaderCompilerOptions[i], &ctx->Const.ShaderCompilerOptions[i],
ctx->Const.NativeIntegers)) ctx->Const.NativeIntegers))
; ;
} }

View File

@@ -164,5 +164,5 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
options.DefaultPragmas.Optimize = true; options.DefaultPragmas.Optimize = true;
for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh) for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
} }

View File

@@ -242,7 +242,7 @@ int test_optpass(int argc, char **argv)
if (!state->error) { if (!state->error) {
GLboolean progress; GLboolean progress;
const struct gl_shader_compiler_options *options = const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader_type)]; &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader_type)];
do { do {
progress = do_optimization_passes(shader->ir, &argv[optind], progress = do_optimization_passes(shader->ir, &argv[optind],
argc - optind, quiet != 0, options); argc - optind, quiet != 0, options);

View File

@@ -253,10 +253,10 @@ i915CreateContext(int api,
/* FINISHME: Are there other options that should be enabled for software /* FINISHME: Are there other options that should be enabled for software
* FINISHME: vertex shaders? * FINISHME: vertex shaders?
*/ */
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = true; ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = true;
struct gl_shader_compiler_options *const fs_options = struct gl_shader_compiler_options *const fs_options =
& ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
fs_options->MaxIfDepth = 0; fs_options->MaxIfDepth = 0;
fs_options->EmitNoNoise = true; fs_options->EmitNoNoise = true;
fs_options->EmitNoPow = true; fs_options->EmitNoPow = true;

View File

@@ -482,21 +482,21 @@ brw_initialize_context_constants(struct brw_context *brw)
/* We want the GLSL compiler to emit code that uses condition codes */ /* We want the GLSL compiler to emit code that uses condition codes */
for (int i = 0; i < MESA_SHADER_STAGES; i++) { for (int i = 0; i < MESA_SHADER_STAGES; i++) {
ctx->ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX; ctx->Const.ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX;
ctx->ShaderCompilerOptions[i].EmitCondCodes = true; ctx->Const.ShaderCompilerOptions[i].EmitCondCodes = true;
ctx->ShaderCompilerOptions[i].EmitNoNoise = true; ctx->Const.ShaderCompilerOptions[i].EmitNoNoise = true;
ctx->ShaderCompilerOptions[i].EmitNoMainReturn = true; ctx->Const.ShaderCompilerOptions[i].EmitNoMainReturn = true;
ctx->ShaderCompilerOptions[i].EmitNoIndirectInput = true; ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectInput = true;
ctx->ShaderCompilerOptions[i].EmitNoIndirectOutput = ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectOutput =
(i == MESA_SHADER_FRAGMENT); (i == MESA_SHADER_FRAGMENT);
ctx->ShaderCompilerOptions[i].EmitNoIndirectTemp = ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectTemp =
(i == MESA_SHADER_FRAGMENT); (i == MESA_SHADER_FRAGMENT);
ctx->ShaderCompilerOptions[i].EmitNoIndirectUniform = false; ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectUniform = false;
ctx->ShaderCompilerOptions[i].LowerClipDistance = true; ctx->Const.ShaderCompilerOptions[i].LowerClipDistance = true;
} }
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true; ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY].OptimizeForAOS = true; ctx->Const.ShaderCompilerOptions[MESA_SHADER_GEOMETRY].OptimizeForAOS = true;
/* ARB_viewport_array */ /* ARB_viewport_array */
if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) { if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) {

View File

@@ -122,7 +122,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) { for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
const struct gl_shader_compiler_options *options = const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[stage]; &ctx->Const.ShaderCompilerOptions[stage];
struct brw_shader *shader = struct brw_shader *shader =
(struct brw_shader *)shProg->_LinkedShaders[stage]; (struct brw_shader *)shProg->_LinkedShaders[stage];

View File

@@ -340,7 +340,7 @@ GLboolean r200CreateContext( gl_api api,
ctx->Const.MaxDrawBuffers = 1; ctx->Const.MaxDrawBuffers = 1;
ctx->Const.MaxColorAttachments = 1; ctx->Const.MaxColorAttachments = 1;
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE; ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE;
/* Install the customized pipeline: /* Install the customized pipeline:
*/ */

View File

@@ -303,7 +303,7 @@ r100CreateContext( gl_api api,
ctx->Const.MaxColorAttachments = 1; ctx->Const.MaxColorAttachments = 1;
ctx->Const.MaxRenderbufferSize = 2048; ctx->Const.MaxRenderbufferSize = 2048;
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true; ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
/* Install the customized pipeline: /* Install the customized pipeline:
*/ */

View File

@@ -1252,7 +1252,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
validate_ir_tree(p.shader->ir); validate_ir_tree(p.shader->ir);
const struct gl_shader_compiler_options *options = const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; &ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
while (do_common_optimization(p.shader->ir, false, false, options, while (do_common_optimization(p.shader->ir, false, false, options,
ctx->Const.NativeIntegers)) ctx->Const.NativeIntegers))

View File

@@ -1676,7 +1676,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
return NULL; return NULL;
create_new_program( &key, prog, create_new_program( &key, prog,
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS, ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS,
ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps ); ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
#if 0 #if 0

View File

@@ -3529,6 +3529,8 @@ struct gl_constants
GLfloat MaxFragmentInterpolationOffset; GLfloat MaxFragmentInterpolationOffset;
GLboolean FakeSWMSAA; GLboolean FakeSWMSAA;
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
}; };
@@ -4172,8 +4174,6 @@ struct gl_context
*/ */
struct gl_pipeline_object *_Shader; struct gl_pipeline_object *_Shader;
struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
struct gl_query_state Query; /**< occlusion, timer queries */ struct gl_query_state Query; /**< occlusion, timer queries */
struct gl_transform_feedback_state TransformFeedback; struct gl_transform_feedback_state TransformFeedback;

View File

@@ -119,7 +119,7 @@ _mesa_init_shader_state(struct gl_context *ctx)
options.DefaultPragmas.Optimize = GL_TRUE; options.DefaultPragmas.Optimize = GL_TRUE;
for (sh = 0; sh < MESA_SHADER_STAGES; ++sh) for (sh = 0; sh < MESA_SHADER_STAGES; ++sh)
memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
ctx->Shader.Flags = _mesa_get_shader_flags(); ctx->Shader.Flags = _mesa_get_shader_flags();
@@ -826,7 +826,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (!sh) if (!sh)
return; return;
options = &ctx->ShaderCompilerOptions[sh->Stage]; options = &ctx->Const.ShaderCompilerOptions[sh->Stage];
/* set default pragma state for shader */ /* set default pragma state for shader */
sh->Pragmas = options->DefaultPragmas; sh->Pragmas = options->DefaultPragmas;

View File

@@ -2795,7 +2795,7 @@ get_mesa_program(struct gl_context *ctx,
GLenum target = _mesa_shader_stage_to_program(shader->Stage); GLenum target = _mesa_shader_stage_to_program(shader->Stage);
const char *target_string = _mesa_shader_stage_to_string(shader->Stage); const char *target_string = _mesa_shader_stage_to_string(shader->Stage);
struct gl_shader_compiler_options *options = struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[shader->Stage]; &ctx->Const.ShaderCompilerOptions[shader->Stage];
validate_ir_tree(shader->ir); validate_ir_tree(shader->ir);
@@ -2980,7 +2980,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
bool progress; bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir; exec_list *ir = prog->_LinkedShaders[i]->ir;
const struct gl_shader_compiler_options *options = const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage]; &ctx->Const.ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage];
do { do {
progress = false; progress = false;

View File

@@ -218,7 +218,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vpro
void void
_mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog) _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_vertex_program *vprog)
{ {
if (ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS) if (ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS)
_mesa_insert_mvp_dp4_code( ctx, vprog ); _mesa_insert_mvp_dp4_code( ctx, vprog );
else else
_mesa_insert_mvp_mad_code( ctx, vprog ); _mesa_insert_mvp_mad_code( ctx, vprog );

View File

@@ -268,7 +268,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
* driver prefers DP4 or MUL/MAD for vertex transformation. * driver prefers DP4 or MUL/MAD for vertex transformation.
*/ */
if (debug_get_option_mesa_mvp_dp4()) if (debug_get_option_mesa_mvp_dp4())
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE; ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE;
return st_create_context_priv(ctx, pipe, options); return st_create_context_priv(ctx, pipe, options);
} }

View File

@@ -158,15 +158,15 @@ void st_init_limits(struct st_context *st)
switch (sh) { switch (sh) {
case PIPE_SHADER_FRAGMENT: case PIPE_SHADER_FRAGMENT:
pc = &c->Program[MESA_SHADER_FRAGMENT]; pc = &c->Program[MESA_SHADER_FRAGMENT];
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; options = &c->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
break; break;
case PIPE_SHADER_VERTEX: case PIPE_SHADER_VERTEX:
pc = &c->Program[MESA_SHADER_VERTEX]; pc = &c->Program[MESA_SHADER_VERTEX];
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX]; options = &c->ShaderCompilerOptions[MESA_SHADER_VERTEX];
break; break;
case PIPE_SHADER_GEOMETRY: case PIPE_SHADER_GEOMETRY:
pc = &c->Program[MESA_SHADER_GEOMETRY]; pc = &c->Program[MESA_SHADER_GEOMETRY];
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; options = &c->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
break; break;
default: default:
/* compute shader, etc. */ /* compute shader, etc. */

View File

@@ -5176,7 +5176,7 @@ get_mesa_program(struct gl_context *ctx,
GLenum target = _mesa_shader_stage_to_program(shader->Stage); GLenum target = _mesa_shader_stage_to_program(shader->Stage);
bool progress; bool progress;
struct gl_shader_compiler_options *options = struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)]; &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)];
struct pipe_screen *pscreen = ctx->st->pipe->screen; struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = shader_stage_to_ptarget(shader->Stage); unsigned ptarget = shader_stage_to_ptarget(shader->Stage);
@@ -5365,7 +5365,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
bool progress; bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir; exec_list *ir = prog->_LinkedShaders[i]->ir;
const struct gl_shader_compiler_options *options = const struct gl_shader_compiler_options *options =
&ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)]; &ctx->Const.ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)];
/* If there are forms of indirect addressing that the driver /* If there are forms of indirect addressing that the driver
* cannot handle, perform the lowering pass. * cannot handle, perform the lowering pass.