diff options
author | Paul Berry <[email protected]> | 2014-01-08 11:09:58 -0800 |
---|---|---|
committer | Paul Berry <[email protected]> | 2014-01-09 09:31:27 -0800 |
commit | 8668eaaa007a1a0b23a4bc39469d6dba293b7da9 (patch) | |
tree | 33b9067a26c4e2a5d7b9a8f83fba9fa74939b9f5 /src/mesa/state_tracker | |
parent | e654216ac7ec2d254685d0ff5f437917747c9bd3 (diff) |
mesa: Use functions to convert gl_shader_stage to PROGRAM enum or pipe target.
Suggested-by: Brian Paul <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
v2: Improve assert message.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 4b6fd2d4bae..73c39eb77d6 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -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_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); |