glsl: Change do_set_program_inouts' is_fragment_shader arg to shader_type.
authorPaul Berry <stereotype441@gmail.com>
Wed, 31 Jul 2013 03:49:56 +0000 (20:49 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 2 Aug 2013 03:18:42 +0000 (20:18 -0700)
This will allow us to add geometry shader support without having to
add another boolean argument.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
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 7ac291cf40e986db3d02e009e8eab6e9f66b540f..f5b4468ec2054e8e7b42917fcf091da982ed8dee 100644 (file)
@@ -2061,7 +2061,7 @@ ir_has_call(ir_instruction *ir);
 
 extern void
 do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
-                      bool is_fragment_shader);
+                      GLenum shader_type);
 
 extern char *
 prototype_string(const glsl_type *return_type, const char *name,
index 91a8b452683a81d1872bdd43eaadf799b4bdacca..ef95cbeaeb7345f1d5bd09a724482594b423a16d 100644 (file)
 
 class ir_set_program_inouts_visitor : public ir_hierarchical_visitor {
 public:
-   ir_set_program_inouts_visitor(struct gl_program *prog,
-                                 bool is_fragment_shader)
+   ir_set_program_inouts_visitor(struct gl_program *prog, GLenum shader_type)
    {
       this->prog = prog;
-      this->is_fragment_shader = is_fragment_shader;
+      this->shader_type = shader_type;
    }
    ~ir_set_program_inouts_visitor()
    {
@@ -61,7 +60,7 @@ public:
    virtual ir_visitor_status visit(ir_dereference_variable *);
 
    struct gl_program *prog;
-   bool is_fragment_shader;
+   GLenum shader_type;
 };
 
 static inline bool
@@ -114,10 +113,10 @@ ir_set_program_inouts_visitor::visit(ir_dereference_variable *ir)
    if (ir->type->is_array()) {
       mark(this->prog, ir->var, 0,
           ir->type->length * ir->type->fields.array->matrix_columns,
-           this->is_fragment_shader);
+           this->shader_type == GL_FRAGMENT_SHADER);
    } else {
       mark(this->prog, ir->var, 0, ir->type->matrix_columns,
-           this->is_fragment_shader);
+           this->shader_type == GL_FRAGMENT_SHADER);
    }
 
    return visit_continue;
@@ -144,7 +143,7 @@ ir_set_program_inouts_visitor::visit_enter(ir_dereference_array *ir)
       }
 
       mark(this->prog, var, index->value.i[0] * width, width,
-           this->is_fragment_shader);
+           this->shader_type == GL_FRAGMENT_SHADER);
       return visit_continue_with_parent;
    }
 
@@ -164,7 +163,8 @@ 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 (is_fragment_shader && ir->operation == ir_unop_dFdy) {
+   if (this->shader_type == GL_FRAGMENT_SHADER &&
+       ir->operation == ir_unop_dFdy) {
       gl_fragment_program *fprog = (gl_fragment_program *) prog;
       fprog->UsesDFdy = true;
    }
@@ -175,7 +175,7 @@ ir_visitor_status
 ir_set_program_inouts_visitor::visit_enter(ir_discard *)
 {
    /* discards are only allowed in fragment shaders. */
-   assert(is_fragment_shader);
+   assert(this->shader_type == GL_FRAGMENT_SHADER);
 
    gl_fragment_program *fprog = (gl_fragment_program *) prog;
    fprog->UsesKill = true;
@@ -185,14 +185,14 @@ ir_set_program_inouts_visitor::visit_enter(ir_discard *)
 
 void
 do_set_program_inouts(exec_list *instructions, struct gl_program *prog,
-                      bool is_fragment_shader)
+                      GLenum shader_type)
 {
-   ir_set_program_inouts_visitor v(prog, is_fragment_shader);
+   ir_set_program_inouts_visitor v(prog, shader_type);
 
    prog->InputsRead = 0;
    prog->OutputsWritten = 0;
    prog->SystemValuesRead = 0;
-   if (is_fragment_shader) {
+   if (shader_type == GL_FRAGMENT_SHADER) {
       gl_fragment_program *fprog = (gl_fragment_program *) prog;
       memset(fprog->InterpQualifier, 0, sizeof(fprog->InterpQualifier));
       fprog->IsCentroid = 0;
index 3322e805542eb7fec70fed7bf61ce84bd08045a0..418ea9b033158e8bed0676a3cd4c8a2d53419fd0 100644 (file)
@@ -236,8 +236,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 == GL_FRAGMENT_SHADER);
+      do_set_program_inouts(shader->ir, prog, shader->base.Type);
 
       prog->SamplersUsed = shader->base.active_samplers;
       _mesa_update_shader_textures_used(shProg, prog);
index f0fc1b9b155ad4b97ff7b42aa80621e3c23fd423..14f43f64e24e1264580bcdd2a93374aa17598357 100644 (file)
@@ -2961,7 +2961,7 @@ get_mesa_program(struct gl_context *ctx,
     */
    mesa_instructions = NULL;
 
-   do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER);
+   do_set_program_inouts(shader->ir, prog, shader->Type);
 
    prog->SamplersUsed = shader->active_samplers;
    prog->ShadowSamplers = shader->shadow_samplers;
index 3dfd5e5b33456a6ecd203c1a78e9405848535e11..69f860a0e083b9f1e5e6a10a964a7f34d8ac577b 100644 (file)
@@ -5121,7 +5121,7 @@ get_mesa_program(struct gl_context *ctx,
    prog->Instructions = NULL;
    prog->NumInstructions = 0;
 
-   do_set_program_inouts(shader->ir, prog, shader->Type == GL_FRAGMENT_SHADER);
+   do_set_program_inouts(shader->ir, prog, shader->Type);
    count_resources(v, prog);
 
    _mesa_reference_program(ctx, &shader->Program, prog);