diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_sampler.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_texture.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 26 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 57 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c | 2 |
5 files changed, 50 insertions, 49 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_sampler.c b/mesalib/src/mesa/state_tracker/st_atom_sampler.c index 57670ce25..cb5369bed 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_sampler.c +++ b/mesalib/src/mesa/state_tracker/st_atom_sampler.c @@ -279,14 +279,14 @@ update_samplers(struct st_context *st) update_shader_samplers(st, PIPE_SHADER_FRAGMENT, &ctx->FragmentProgram._Current->Base, - ctx->Const.FragmentProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, st->state.samplers[PIPE_SHADER_FRAGMENT], &st->state.num_samplers[PIPE_SHADER_FRAGMENT]); update_shader_samplers(st, PIPE_SHADER_VERTEX, &ctx->VertexProgram._Current->Base, - ctx->Const.VertexProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits, st->state.samplers[PIPE_SHADER_VERTEX], &st->state.num_samplers[PIPE_SHADER_VERTEX]); @@ -294,7 +294,7 @@ update_samplers(struct st_context *st) update_shader_samplers(st, PIPE_SHADER_GEOMETRY, &ctx->GeometryProgram._Current->Base, - ctx->Const.GeometryProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits, st->state.samplers[PIPE_SHADER_GEOMETRY], &st->state.num_samplers[PIPE_SHADER_GEOMETRY]); } diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index bd0a22dde..7604202ba 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -326,11 +326,11 @@ update_vertex_textures(struct st_context *st) { const struct gl_context *ctx = st->ctx; - if (ctx->Const.VertexProgram.MaxTextureImageUnits > 0) { + if (ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits > 0) { update_textures(st, PIPE_SHADER_VERTEX, &ctx->VertexProgram._Current->Base, - ctx->Const.VertexProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits, st->state.sampler_views[PIPE_SHADER_VERTEX], &st->state.num_sampler_views[PIPE_SHADER_VERTEX]); } @@ -345,7 +345,7 @@ update_fragment_textures(struct st_context *st) update_textures(st, PIPE_SHADER_FRAGMENT, &ctx->FragmentProgram._Current->Base, - ctx->Const.FragmentProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, st->state.sampler_views[PIPE_SHADER_FRAGMENT], &st->state.num_sampler_views[PIPE_SHADER_FRAGMENT]); } @@ -360,7 +360,7 @@ update_geometry_textures(struct st_context *st) update_textures(st, PIPE_SHADER_GEOMETRY, &ctx->GeometryProgram._Current->Base, - ctx->Const.FragmentProgram.MaxTextureImageUnits, + ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, st->state.sampler_views[PIPE_SHADER_GEOMETRY], &st->state.num_sampler_views[PIPE_SHADER_GEOMETRY]); } diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 5e4a3b398..c17601a90 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -155,15 +155,15 @@ void st_init_limits(struct st_context *st) switch (sh) { case PIPE_SHADER_FRAGMENT: - pc = &c->FragmentProgram; + pc = &c->Program[MESA_SHADER_FRAGMENT]; options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT]; break; case PIPE_SHADER_VERTEX: - pc = &c->VertexProgram; + pc = &c->Program[MESA_SHADER_VERTEX]; options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX]; break; case PIPE_SHADER_GEOMETRY: - pc = &c->GeometryProgram; + pc = &c->Program[MESA_SHADER_GEOMETRY]; options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY]; break; default: @@ -245,21 +245,21 @@ void st_init_limits(struct st_context *st) /* This depends on program constants. */ c->MaxTextureCoordUnits - = _min(c->FragmentProgram.MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); + = _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, MAX_TEXTURE_COORD_UNITS); - c->MaxTextureUnits = _min(c->FragmentProgram.MaxTextureImageUnits, c->MaxTextureCoordUnits); + c->MaxTextureUnits = _min(c->Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits, c->MaxTextureCoordUnits); - c->VertexProgram.MaxAttribs = MIN2(c->VertexProgram.MaxAttribs, 16); + c->Program[MESA_SHADER_VERTEX].MaxAttribs = MIN2(c->Program[MESA_SHADER_VERTEX].MaxAttribs, 16); /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number * of inputs. It's always 2 colors + N generic inputs. */ c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS); c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING); - c->FragmentProgram.MaxInputComponents = c->MaxVarying * 4; - c->VertexProgram.MaxOutputComponents = c->MaxVarying * 4; - c->GeometryProgram.MaxInputComponents = c->MaxVarying * 4; - c->GeometryProgram.MaxOutputComponents = c->MaxVarying * 4; + c->Program[MESA_SHADER_FRAGMENT].MaxInputComponents = c->MaxVarying * 4; + c->Program[MESA_SHADER_VERTEX].MaxOutputComponents = c->MaxVarying * 4; + c->Program[MESA_SHADER_GEOMETRY].MaxInputComponents = c->MaxVarying * 4; + c->Program[MESA_SHADER_GEOMETRY].MaxOutputComponents = c->MaxVarying * 4; c->MinProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET); c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET); @@ -284,9 +284,9 @@ void st_init_limits(struct st_context *st) c->UniformBufferOffsetAlignment = screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT); c->MaxCombinedUniformBlocks = c->MaxUniformBufferBindings = - c->VertexProgram.MaxUniformBlocks + - c->GeometryProgram.MaxUniformBlocks + - c->FragmentProgram.MaxUniformBlocks; + c->Program[MESA_SHADER_VERTEX].MaxUniformBlocks + + c->Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks + + c->Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks; assert(c->MaxCombinedUniformBlocks <= MAX_COMBINED_UNIFORM_BUFFERS); } } diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index eb12426a5..73c39eb77 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -4970,7 +4970,7 @@ st_translate_program( assert(i == program->num_immediates); /* texture samplers */ - for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) { + for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) { if (program->samplers_used & (1 << i)) { t->samplers[i] = ureg_DECL_sampler(ureg, i); } @@ -4996,7 +4996,7 @@ st_translate_program( * prog->ParameterValues to get reallocated (e.g., anything that adds a * program constant) has to happen before creating this linkage. */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (program->shader_program->_LinkedShaders[i] == NULL) continue; @@ -5023,6 +5023,24 @@ out: } /* ----------------------------- End TGSI code ------------------------------ */ + +static unsigned +shader_stage_to_ptarget(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return PIPE_SHADER_VERTEX; + case MESA_SHADER_FRAGMENT: + return PIPE_SHADER_FRAGMENT; + case MESA_SHADER_GEOMETRY: + return PIPE_SHADER_GEOMETRY; + } + + assert(!"should not be reached"); + return PIPE_SHADER_VERTEX; +} + + /** * Convert a shader's GLSL IR into a Mesa gl_program, although without * generating Mesa IR. @@ -5034,30 +5052,12 @@ get_mesa_program(struct gl_context *ctx, { glsl_to_tgsi_visitor* v; struct gl_program *prog; - GLenum target; + GLenum target = _mesa_shader_stage_to_program(shader->Stage); bool progress; struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; + &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)]; struct pipe_screen *pscreen = ctx->st->pipe->screen; - unsigned ptarget; - - switch (shader->Type) { - case GL_VERTEX_SHADER: - target = GL_VERTEX_PROGRAM_ARB; - ptarget = PIPE_SHADER_VERTEX; - break; - case GL_FRAGMENT_SHADER: - target = GL_FRAGMENT_PROGRAM_ARB; - ptarget = PIPE_SHADER_FRAGMENT; - break; - case GL_GEOMETRY_SHADER: - target = GL_GEOMETRY_PROGRAM_NV; - ptarget = PIPE_SHADER_GEOMETRY; - break; - default: - assert(!"should not be reached"); - return NULL; - } + unsigned ptarget = shader_stage_to_ptarget(shader->Stage); validate_ir_tree(shader->ir); @@ -5143,7 +5143,7 @@ get_mesa_program(struct gl_context *ctx, if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", - _mesa_shader_enum_to_string(shader->Type), + _mesa_shader_stage_to_string(shader->Stage), shader_program->Name); _mesa_print_ir(shader->ir, NULL); printf("\n"); @@ -5154,7 +5154,7 @@ get_mesa_program(struct gl_context *ctx, prog->Instructions = NULL; prog->NumInstructions = 0; - do_set_program_inouts(shader->ir, prog, shader->Type); + do_set_program_inouts(shader->ir, prog, shader->Stage); count_resources(v, prog); _mesa_reference_program(ctx, &shader->Program, prog); @@ -5207,6 +5207,7 @@ st_new_shader(struct gl_context *ctx, GLuint name, GLuint type) shader = rzalloc(NULL, struct gl_shader); if (shader) { shader->Type = type; + shader->Stage = _mesa_shader_enum_to_shader_stage(type); shader->Name = name; _mesa_init_shader(ctx, shader); } @@ -5236,14 +5237,14 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { assert(prog->LinkStatus); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; bool progress; exec_list *ir = prog->_LinkedShaders[i]->ir; const struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; + &ctx->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. @@ -5306,7 +5307,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(ir); } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; if (prog->_LinkedShaders[i] == NULL) diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 1c2abc122..aa9ec1359 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -1225,7 +1225,7 @@ st_translate_mesa_program( } /* texture samplers */ - for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) { + for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) { if (program->SamplersUsed & (1 << i)) { t->samplers[i] = ureg_DECL_sampler( ureg, i ); } |