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;
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__);
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;
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)
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
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? */
* 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
*/
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 */
{
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
/* 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();
}
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.
GLcontext *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
+ struct gl_shader_compiler_options *options;
int next_temp;
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
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:
v.ctx = ctx;
v.prog = prog;
v.shader_program = shader_program;
+ v.options = options;
add_uniforms_to_parameters_list(shader_program, shader, prog);
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");
}
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;
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;
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),
/* 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;