glsl: Make more use of gl_shader_stage enum in ir_set_program_inouts.cpp.
authorPaul Berry <stereotype441@gmail.com>
Tue, 7 Jan 2014 19:23:34 +0000 (11:23 -0800)
committerPaul Berry <stereotype441@gmail.com>
Wed, 8 Jan 2014 15:32:01 +0000 (07:32 -0800)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/glsl/ir.h
src/glsl/ir_set_program_inouts.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index 4d863854bc647a5134c036a78f5fa3c65cb15671..aff679826e3e9f47f694591900354bab13fc7a9f 100644 (file)
@@ -2351,7 +2351,7 @@ ir_has_call(ir_instruction *ir);
 
 extern void
 do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
-                      GLenum shader_type);
+                      gl_shader_stage shader_stage);
 
 extern char *
 prototype_string(const glsl_type *return_type, const char *name,
index 0b49eb2b673f757fe356b6e4ce15cac584a852da..5163eb215df6471de79320b07b1d316ec0d7950c 100644 (file)
@@ -46,10 +46,11 @@ namespace {
 
 class ir_set_program_inouts_visitor : public ir_hierarchical_visitor {
 public:
-   ir_set_program_inouts_visitor(struct gl_program *prog, GLenum shader_type)
+   ir_set_program_inouts_visitor(struct gl_program *prog,
+                                 gl_shader_stage shader_stage)
    {
       this->prog = prog;
-      this->shader_type = shader_type;
+      this->shader_stage = shader_stage;
    }
    ~ir_set_program_inouts_visitor()
    {
@@ -67,7 +68,7 @@ private:
    bool try_mark_partial_variable(ir_variable *var, ir_rvalue *index);
 
    struct gl_program *prog;
-   GLenum shader_type;
+   gl_shader_stage shader_stage;
 };
 
 } /* anonymous namespace */
@@ -124,13 +125,13 @@ void
 ir_set_program_inouts_visitor::mark_whole_variable(ir_variable *var)
 {
    const glsl_type *type = var->type;
-   if (this->shader_type == GL_GEOMETRY_SHADER &&
+   if (this->shader_stage == MESA_SHADER_GEOMETRY &&
        var->data.mode == ir_var_shader_in && type->is_array()) {
       type = type->fields.array;
    }
 
    mark(this->prog, var, 0, type->count_attribute_slots(),
-        this->shader_type == GL_FRAGMENT_SHADER);
+        this->shader_stage == MESA_SHADER_FRAGMENT);
 }
 
 /* Default handler: Mark all the locations in the variable as used. */
@@ -163,7 +164,7 @@ ir_set_program_inouts_visitor::try_mark_partial_variable(ir_variable *var,
 {
    const glsl_type *type = var->type;
 
-   if (this->shader_type == GL_GEOMETRY_SHADER &&
+   if (this->shader_stage == MESA_SHADER_GEOMETRY &&
        var->data.mode == ir_var_shader_in) {
       /* The only geometry shader input that is not an array is
        * gl_PrimitiveIDIn, and in that case, this code will never be reached,
@@ -227,7 +228,7 @@ ir_set_program_inouts_visitor::try_mark_partial_variable(ir_variable *var,
    }
 
    mark(this->prog, var, index_as_constant->value.u[0] * elem_width,
-        elem_width, this->shader_type == GL_FRAGMENT_SHADER);
+        elem_width, this->shader_stage == MESA_SHADER_FRAGMENT);
    return true;
 }
 
@@ -245,7 +246,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
        */
       if (ir_dereference_variable * const deref_var =
           inner_array->array->as_dereference_variable()) {
-         if (this->shader_type == GL_GEOMETRY_SHADER &&
+         if (this->shader_stage == MESA_SHADER_GEOMETRY &&
              deref_var->var->data.mode == ir_var_shader_in) {
             /* foo is a geometry shader input, so i is the vertex, and j the
              * part of the input we're accessing.
@@ -264,7 +265,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
    } else if (ir_dereference_variable * const deref_var =
               ir->array->as_dereference_variable()) {
       /* ir => foo[i], where foo is a variable. */
-      if (this->shader_type == GL_GEOMETRY_SHADER &&
+      if (this->shader_stage == MESA_SHADER_GEOMETRY &&
           deref_var->var->data.mode == ir_var_shader_in) {
          /* foo is a geometry shader input, so i is the vertex, and we're
           * accessing the entire input.
@@ -304,7 +305,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_function_signature *ir)
 ir_visitor_status
 ir_set_program_inouts_visitor::visit_enter(ir_expression *ir)
 {
-   if (this->shader_type == GL_FRAGMENT_SHADER &&
+   if (this->shader_stage == MESA_SHADER_FRAGMENT &&
        ir->operation == ir_unop_dFdy) {
       gl_fragment_program *fprog = (gl_fragment_program *) prog;
       fprog->UsesDFdy = true;
@@ -316,7 +317,7 @@ ir_visitor_status
 ir_set_program_inouts_visitor::visit_enter(ir_discard *)
 {
    /* discards are only allowed in fragment shaders. */
-   assert(this->shader_type == GL_FRAGMENT_SHADER);
+   assert(this->shader_stage == MESA_SHADER_FRAGMENT);
 
    gl_fragment_program *fprog = (gl_fragment_program *) prog;
    fprog->UsesKill = true;
@@ -334,14 +335,14 @@ ir_set_program_inouts_visitor::visit_enter(ir_texture *ir)
 
 void
 do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
-                      GLenum shader_type)
+                      gl_shader_stage shader_stage)
 {
-   ir_set_program_inouts_visitor v(prog, shader_type);
+   ir_set_program_inouts_visitor v(prog, shader_stage);
 
    prog->InputsRead = 0;
    prog->OutputsWritten = 0;
    prog->SystemValuesRead = 0;
-   if (shader_type == GL_FRAGMENT_SHADER) {
+   if (shader_stage == MESA_SHADER_FRAGMENT) {
       gl_fragment_program *fprog = (gl_fragment_program *) prog;
       memset(fprog->InterpQualifier, 0, sizeof(fprog->InterpQualifier));
       fprog->IsCentroid = 0;
index 33197ebf105a2621f418df6bba73c82665c15072..cf9ca4bbf91cd142f3e17bf897704b7215381b1e 100644 (file)
@@ -242,7 +242,7 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
       reparent_ir(shader->ir, shader->ir);
       ralloc_free(mem_ctx);
 
-      do_set_program_inouts(shader->ir, prog, shader->base.Type);
+      do_set_program_inouts(shader->ir, prog, shader->base.Stage);
 
       prog->SamplersUsed = shader->base.active_samplers;
       _mesa_update_shader_textures_used(shProg, prog);
index 88e94fa014ef0991304a96cc011da38af4bddf98..7988248bb83883c42989d6762afc2428ce0b2a78 100644 (file)
@@ -2951,7 +2951,7 @@ get_mesa_program(struct gl_context *ctx,
     */
    mesa_instructions = NULL;
 
-   do_set_program_inouts(shader->ir, prog, shader->Type);
+   do_set_program_inouts(shader->ir, prog, shader->Stage);
 
    prog->SamplersUsed = shader->active_samplers;
    prog->ShadowSamplers = shader->shadow_samplers;
index bd4eb5e3f205a4b087c598cc10d8cb560abeb5f0..9cb97a0352b151107cc7e3ddb0a5caf030dfc511 100644 (file)
@@ -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);