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:
@@ -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
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -2660,12 +2660,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))
|
||||
;
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -482,21 +482,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) {
|
||||
|
@@ -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];
|
||||
|
||||
|
@@ -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:
|
||||
*/
|
||||
|
@@ -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:
|
||||
*/
|
||||
|
@@ -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))
|
||||
|
@@ -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
|
||||
|
@@ -3529,6 +3529,8 @@ struct gl_constants
|
||||
GLfloat MaxFragmentInterpolationOffset;
|
||||
|
||||
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_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
|
||||
|
||||
struct gl_query_state Query; /**< occlusion, timer queries */
|
||||
|
||||
struct gl_transform_feedback_state TransformFeedback;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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 );
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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. */
|
||||
|
@@ -5176,7 +5176,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);
|
||||
|
||||
@@ -5365,7 +5365,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.
|
||||
|
Reference in New Issue
Block a user