summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/dri/i915/i915_context.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c7
-rw-r--r--src/mesa/drivers/dri/r600/r600_context.c8
-rw-r--r--src/mesa/main/mtypes.h15
-rw-r--r--src/mesa/main/nvprogram.c4
-rw-r--r--src/mesa/main/shaderapi.c31
-rw-r--r--src/mesa/program/ir_to_mesa.cpp12
-rw-r--r--src/mesa/state_tracker/st_extensions.c6
8 files changed, 64 insertions, 25 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index d8715cf026d..845ec2c3c4a 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -174,7 +174,11 @@ i915CreateContext(int api,
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
- ctx->Shader.EmitNoIfs = GL_TRUE;
+ /* FINISHME: Are there other options that should be enabled for software
+ * FINISHME: vertex shaders?
+ */
+ ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].EmitCondCodes = GL_TRUE;
+ ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT].EmitNoIfs = GL_TRUE;
ctx->Const.MaxDrawBuffers = 1;
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index d2b20165f9d..daa281ece46 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -66,6 +66,7 @@ GLboolean brwCreateContext( int api,
struct brw_context *brw = (struct brw_context *) CALLOC_STRUCT(brw_context);
struct intel_context *intel = &brw->intel;
GLcontext *ctx = &intel->ctx;
+ unsigned i;
if (!brw) {
printf("%s: failed to alloc context\n", __FUNCTION__);
@@ -110,8 +111,10 @@ GLboolean brwCreateContext( int api,
ctx->Const.MaxPointSizeAA = 255.0;
/* We want the GLSL compiler to emit code that uses condition codes */
- ctx->Shader.EmitCondCodes = GL_TRUE;
- ctx->Shader.EmitNVTempInitialization = GL_TRUE;
+ for (i = 0; i <= MESA_SHADER_FRAGMENT; i++) {
+ ctx->ShaderCompilerOptions[i].EmitCondCodes = GL_TRUE;
+ ctx->ShaderCompilerOptions[i].EmitNVTempInitialization = GL_TRUE;
+ }
ctx->Const.VertexProgram.MaxNativeInstructions = (16 * 1024);
ctx->Const.VertexProgram.MaxAluInstructions = 0;
diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c
index bb959e7d2d9..b0a79c7b598 100644
--- a/src/mesa/drivers/dri/r600/r600_context.c
+++ b/src/mesa/drivers/dri/r600/r600_context.c
@@ -337,6 +337,9 @@ static void r600ParseOptions(context_t *r600, radeonScreenPtr screen)
static void r600InitGLExtensions(GLcontext *ctx)
{
context_t *r600 = R700_CONTEXT(ctx);
+#ifdef R600_ENABLE_GLSL_TEST
+ unsigned i;
+#endif
driInitExtensions(ctx, card_extensions, GL_TRUE);
if (r600->radeon.radeonScreen->kernel_mm)
@@ -346,8 +349,9 @@ static void r600InitGLExtensions(GLcontext *ctx)
driInitExtensions(ctx, gl_20_extension, GL_TRUE);
_mesa_enable_2_0_extensions(ctx);
- /* glsl compiler has problem if this is not GL_TRUE */
- ctx->Shader.EmitCondCodes = GL_TRUE;
+ /* glsl compiler has problem if this is not GL_TRUE */
+ for (i = 0; i <= MESA_SHADER_FRAGMENT; i++)
+ ctx->ShaderCompilerOptions[i].EmitCondCodes = GL_TRUE;
#endif /* R600_ENABLE_GLSL_TEST */
if (driQueryOptionb
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7d5ce7040b2..61cd93c364c 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2175,6 +2175,16 @@ struct gl_shader_program
struct gl_shader_state
{
struct gl_shader_program *CurrentProgram; /**< The user-bound program */
+ void *MemPool;
+
+ GLbitfield Flags; /**< Mask of GLSL_x flags */
+};
+
+/**
+ * Compiler options for a single GLSL shaders type
+ */
+struct gl_shader_compiler_options
+{
/** Driver-selectable options: */
GLboolean EmitHighLevelInstructions; /**< IF/ELSE/ENDIF vs. BRA, etc. */
GLboolean EmitContReturn; /**< Emit CONT/RET opcodes? */
@@ -2186,12 +2196,10 @@ struct gl_shader_state
* support control flow.
*/
GLboolean EmitNoIfs;
- void *MemPool;
- GLbitfield Flags; /**< Mask of GLSL_x flags */
+
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
};
-
/**
* Transform feedback object state
*/
@@ -3212,6 +3220,7 @@ struct __GLcontextRec
struct gl_ati_fragment_shader_state ATIFragmentShader;
struct gl_shader_state Shader; /**< GLSL shader object state */
+ struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES];
struct gl_query_state Query; /**< occlusion, timer queries */
diff --git a/src/mesa/main/nvprogram.c b/src/mesa/main/nvprogram.c
index 100ff2c4ab8..3a570b7dda6 100644
--- a/src/mesa/main/nvprogram.c
+++ b/src/mesa/main/nvprogram.c
@@ -516,8 +516,10 @@ _mesa_emit_nv_temp_initialization(GLcontext *ctx,
{
struct prog_instruction *inst;
GLuint i;
+ struct gl_shader_compiler_options* options =
+ &ctx->ShaderCompilerOptions[_mesa_program_target_to_index(program->Target)];
- if (!ctx->Shader.EmitNVTempInitialization)
+ if (!options->EmitNVTempInitialization)
return;
/* We'll swizzle up a zero temporary so we can use it for the
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index cc350c93b97..2977a29ab74 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -94,18 +94,24 @@ _mesa_init_shader_state(GLcontext *ctx)
/* Device drivers may override these to control what kind of instructions
* are generated by the GLSL compiler.
*/
- ctx->Shader.EmitHighLevelInstructions = GL_TRUE;
- ctx->Shader.EmitContReturn = GL_TRUE;
- ctx->Shader.EmitCondCodes = GL_FALSE;
- ctx->Shader.EmitComments = GL_FALSE;
- ctx->Shader.EmitNoIfs = GL_FALSE;
- ctx->Shader.Flags = get_shader_flags();
+ struct gl_shader_compiler_options options;
+ GLuint i;
+ options.EmitHighLevelInstructions = GL_TRUE;
+ options.EmitContReturn = GL_TRUE;
+ options.EmitCondCodes = GL_FALSE;
+ options.EmitComments = GL_FALSE;
+ options.EmitNoIfs = GL_FALSE;
/* Default pragma settings */
- ctx->Shader.DefaultPragmas.IgnoreOptimize = GL_FALSE;
- ctx->Shader.DefaultPragmas.IgnoreDebug = GL_FALSE;
- ctx->Shader.DefaultPragmas.Optimize = GL_TRUE;
- ctx->Shader.DefaultPragmas.Debug = GL_FALSE;
+ options.DefaultPragmas.IgnoreOptimize = GL_FALSE;
+ options.DefaultPragmas.IgnoreDebug = GL_FALSE;
+ options.DefaultPragmas.Optimize = GL_TRUE;
+ options.DefaultPragmas.Debug = GL_FALSE;
+
+ for(i = 0; i < MESA_SHADER_TYPES; ++i)
+ memcpy(&ctx->ShaderCompilerOptions[i], &options, sizeof(options));
+
+ ctx->Shader.Flags = get_shader_flags();
}
@@ -789,13 +795,16 @@ static void
compile_shader(GLcontext *ctx, GLuint shaderObj)
{
struct gl_shader *sh;
+ struct gl_shader_compiler_options *options;
sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader");
if (!sh)
return;
+ options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];
+
/* set default pragma state for shader */
- sh->Pragmas = ctx->Shader.DefaultPragmas;
+ sh->Pragmas = options->DefaultPragmas;
/* this call will set the sh->CompileStatus field to indicate if
* compilation was successful.
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index cb4fbb60c1c..b3641032fb0 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -186,6 +186,7 @@ public:
GLcontext *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
+ struct gl_shader_compiler_options *options;
int next_temp;
@@ -2096,7 +2097,7 @@ ir_to_mesa_visitor::visit(ir_if *ir)
ir->condition->accept(this);
assert(this->result.file != PROGRAM_UNDEFINED);
- if (ctx->Shader.EmitCondCodes) {
+ if (this->options->EmitCondCodes) {
cond_inst = (ir_to_mesa_instruction *)this->instructions.get_tail();
/* See if we actually generated any instruction for generating
@@ -2526,6 +2527,8 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
GLenum target;
const char *target_string;
GLboolean progress;
+ struct gl_shader_compiler_options *options =
+ &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)];
switch (shader->Type) {
case GL_VERTEX_SHADER:
@@ -2552,6 +2555,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
v.ctx = ctx;
v.prog = prog;
v.shader_program = shader_program;
+ v.options = options;
add_uniforms_to_parameters_list(shader_program, shader, prog);
@@ -2629,7 +2633,7 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
if (mesa_inst->SrcReg[src].RelAddr)
prog->IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File;
- if (ctx->Shader.EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) {
+ if (options->EmitNoIfs && mesa_inst->Opcode == OPCODE_IF) {
fail_link(shader_program, "Couldn't flatten if statement\n");
}
@@ -2703,6 +2707,8 @@ _mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
for (unsigned i = 0; i < prog->_NumLinkedShaders; i++) {
bool progress;
exec_list *ir = prog->_LinkedShaders[i]->ir;
+ struct gl_shader_compiler_options *options =
+ &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)];
do {
progress = false;
@@ -2715,7 +2721,7 @@ _mesa_ir_link_shader(GLcontext *ctx, struct gl_shader_program *prog)
progress = do_common_optimization(ir, true) || progress;
- if (ctx->Shader.EmitNoIfs)
+ if (options->EmitNoIfs)
progress = do_if_to_cond_assign(ir) || progress;
progress = do_vec_index_to_cond_assign(ir) || progress;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index acb9526c01c..82be1494338 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -68,6 +68,7 @@ void st_init_limits(struct st_context *st)
struct pipe_screen *screen = st->pipe->screen;
struct gl_constants *c = &st->ctx->Const;
struct gl_program_constants *pc;
+ unsigned i;
c->MaxTextureLevels
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
@@ -136,8 +137,9 @@ void st_init_limits(struct st_context *st)
/* Is TGSI_OPCODE_CONT supported? */
/* XXX separate query for early function return? */
- st->ctx->Shader.EmitContReturn =
- screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
+ for(i = 0; i < MESA_SHADER_TYPES; ++i)
+ st->ctx->ShaderCompilerOptions[i].EmitContReturn =
+ screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED);
/* Quads always follow GL provoking rules. */
c->QuadsFollowProvokingVertexConvention = GL_FALSE;