[Mesa-dev] [PATCH 04/12] mesa: move ShaderCompilerOptions into gl_constants
Marek Olšák
maraeo at gmail.com
Sun Aug 3 08:18:27 PDT 2014
From: Marek Olšák <marek.olsak at amd.com>
---
src/glsl/glsl_parser_extras.cpp | 2 +-
src/glsl/link_varyings.cpp | 2 +-
src/glsl/linker.cpp | 4 ++--
src/glsl/standalone_scaffolding.cpp | 2 +-
src/glsl/test_optpass.cpp | 2 +-
src/mesa/drivers/dri/i915/i915_context.c | 4 ++--
src/mesa/drivers/dri/i965/brw_context.c | 22 +++++++++++-----------
src/mesa/drivers/dri/i965/brw_shader.cpp | 2 +-
src/mesa/drivers/dri/r200/r200_context.c | 2 +-
src/mesa/drivers/dri/radeon/radeon_context.c | 2 +-
src/mesa/main/ff_fragment_shader.cpp | 2 +-
src/mesa/main/ffvertex_prog.c | 2 +-
src/mesa/main/mtypes.h | 4 ++--
src/mesa/main/shaderapi.c | 4 ++--
src/mesa/program/ir_to_mesa.cpp | 4 ++--
src/mesa/program/programopt.c | 2 +-
src/mesa/state_tracker/st_context.c | 2 +-
src/mesa/state_tracker/st_extensions.c | 6 +++---
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 ++--
19 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 890123a..badb38b 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1472,7 +1472,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
if (!state->error && !shader->ir->is_empty()) {
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
* and reduce later work if the same shader is linked multiple times
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index a3fc2ae..e803de1 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -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
* 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) {
this->is_clip_distance_mesa = true;
}
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index d588bc6..7a661fd 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -2659,12 +2659,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (!prog->LinkStatus)
goto done;
- if (ctx->ShaderCompilerOptions[i].LowerClipDistance) {
+ if (ctx->Const.ShaderCompilerOptions[i].LowerClipDistance) {
lower_clip_distance(prog->_LinkedShaders[i]);
}
while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false,
- &ctx->ShaderCompilerOptions[i],
+ &ctx->Const.ShaderCompilerOptions[i],
ctx->Const.NativeIntegers))
;
}
diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
index 809732c..809043d 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -164,5 +164,5 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
options.DefaultPragmas.Optimize = true;
for (int sh = 0; sh < MESA_SHADER_STAGES; ++sh)
- memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options));
+ memcpy(&ctx->Const.ShaderCompilerOptions[sh], &options, sizeof(options));
}
diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
index e4878bf..24c06f1 100644
--- a/src/glsl/test_optpass.cpp
+++ b/src/glsl/test_optpass.cpp
@@ -242,7 +242,7 @@ int test_optpass(int argc, char **argv)
if (!state->error) {
GLboolean progress;
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 {
progress = do_optimization_passes(shader->ir, &argv[optind],
argc - optind, quiet != 0, options);
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 44b0d8b..507f6a1 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -253,10 +253,10 @@ i915CreateContext(int api,
/* FINISHME: Are there other options that should be enabled for software
* 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 =
- & ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
+ & ctx->Const.ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
fs_options->MaxIfDepth = 0;
fs_options->EmitNoNoise = true;
fs_options->EmitNoPow = true;
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 89f5df5..b8d37ae 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -481,21 +481,21 @@ brw_initialize_context_constants(struct brw_context *brw)
/* We want the GLSL compiler to emit code that uses condition codes */
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
- ctx->ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX;
- ctx->ShaderCompilerOptions[i].EmitCondCodes = true;
- ctx->ShaderCompilerOptions[i].EmitNoNoise = true;
- ctx->ShaderCompilerOptions[i].EmitNoMainReturn = true;
- ctx->ShaderCompilerOptions[i].EmitNoIndirectInput = true;
- ctx->ShaderCompilerOptions[i].EmitNoIndirectOutput =
+ ctx->Const.ShaderCompilerOptions[i].MaxIfDepth = brw->gen < 6 ? 16 : UINT_MAX;
+ ctx->Const.ShaderCompilerOptions[i].EmitCondCodes = true;
+ ctx->Const.ShaderCompilerOptions[i].EmitNoNoise = true;
+ ctx->Const.ShaderCompilerOptions[i].EmitNoMainReturn = true;
+ ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectInput = true;
+ ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectOutput =
(i == MESA_SHADER_FRAGMENT);
- ctx->ShaderCompilerOptions[i].EmitNoIndirectTemp =
+ ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectTemp =
(i == MESA_SHADER_FRAGMENT);
- ctx->ShaderCompilerOptions[i].EmitNoIndirectUniform = false;
- ctx->ShaderCompilerOptions[i].LowerClipDistance = true;
+ ctx->Const.ShaderCompilerOptions[i].EmitNoIndirectUniform = false;
+ ctx->Const.ShaderCompilerOptions[i].LowerClipDistance = true;
}
- ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
- ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY].OptimizeForAOS = true;
+ ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
+ ctx->Const.ShaderCompilerOptions[MESA_SHADER_GEOMETRY].OptimizeForAOS = true;
/* ARB_viewport_array */
if (brw->gen >= 7 && ctx->API == API_OPENGL_CORE) {
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index f56ea68..0033135 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -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++) {
const struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[stage];
+ &ctx->Const.ShaderCompilerOptions[stage];
struct brw_shader *shader =
(struct brw_shader *)shProg->_LinkedShaders[stage];
diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c
index d5749f3..7815c4e 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -340,7 +340,7 @@ GLboolean r200CreateContext( gl_api api,
ctx->Const.MaxDrawBuffers = 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:
*/
diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c
index edd94e2..f717660 100644
--- a/src/mesa/drivers/dri/radeon/radeon_context.c
+++ b/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -303,7 +303,7 @@ r100CreateContext( gl_api api,
ctx->Const.MaxColorAttachments = 1;
ctx->Const.MaxRenderbufferSize = 2048;
- ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
+ ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = true;
/* Install the customized pipeline:
*/
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 8758b5e..9bb706c 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1252,7 +1252,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
validate_ir_tree(p.shader->ir);
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,
ctx->Const.NativeIntegers))
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 728cf96..d5afc3d 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -1676,7 +1676,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
return NULL;
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 );
#if 0
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3f60a55..c9a8e9a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3508,6 +3508,8 @@ struct gl_constants
GLfloat MaxFragmentInterpolationOffset;
GLboolean FakeSWMSAA;
+
+ struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
};
@@ -4150,8 +4152,6 @@ struct gl_context
*/
struct gl_pipeline_object *_Shader;
- struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
-
struct gl_query_state Query; /**< occlusion, timer queries */
struct gl_transform_feedback_state TransformFeedback;
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2bbef35..6d0dcdd 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -119,7 +119,7 @@ _mesa_init_shader_state(struct gl_context *ctx)
options.DefaultPragmas.Optimize = GL_TRUE;
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();
@@ -826,7 +826,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (!sh)
return;
- options = &ctx->ShaderCompilerOptions[sh->Stage];
+ options = &ctx->Const.ShaderCompilerOptions[sh->Stage];
/* set default pragma state for shader */
sh->Pragmas = options->DefaultPragmas;
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 2a82e9d..fa25cac 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2795,7 +2795,7 @@ get_mesa_program(struct gl_context *ctx,
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
const char *target_string = _mesa_shader_stage_to_string(shader->Stage);
struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[shader->Stage];
+ &ctx->Const.ShaderCompilerOptions[shader->Stage];
validate_ir_tree(shader->ir);
@@ -2980,7 +2980,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
const struct gl_shader_compiler_options *options =
- &ctx->ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage];
+ &ctx->Const.ShaderCompilerOptions[prog->_LinkedShaders[i]->Stage];
do {
progress = false;
diff --git a/src/mesa/program/programopt.c b/src/mesa/program/programopt.c
index 92a8831..b654b1d 100644
--- a/src/mesa/program/programopt.c
+++ b/src/mesa/program/programopt.c
@@ -218,7 +218,7 @@ _mesa_insert_mvp_mad_code(struct gl_context *ctx, struct gl_vertex_program *vpro
void
_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 );
else
_mesa_insert_mvp_mad_code( ctx, vprog );
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 5f83e52..270e245 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -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.
*/
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);
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 6901b51..110a079 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -158,15 +158,15 @@ void st_init_limits(struct st_context *st)
switch (sh) {
case PIPE_SHADER_FRAGMENT:
pc = &c->Program[MESA_SHADER_FRAGMENT];
- options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
+ options = &c->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
break;
case PIPE_SHADER_VERTEX:
pc = &c->Program[MESA_SHADER_VERTEX];
- options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX];
+ options = &c->ShaderCompilerOptions[MESA_SHADER_VERTEX];
break;
case PIPE_SHADER_GEOMETRY:
pc = &c->Program[MESA_SHADER_GEOMETRY];
- options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
+ options = &c->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
break;
default:
/* compute shader, etc. */
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 27e4615..3a4ff1a 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5228,7 +5228,7 @@ get_mesa_program(struct gl_context *ctx,
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
bool progress;
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;
unsigned ptarget = shader_stage_to_ptarget(shader->Stage);
@@ -5417,7 +5417,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
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
* cannot handle, perform the lowering pass.
--
1.9.1
More information about the mesa-dev
mailing list