diff options
-rw-r--r-- | src/compiler/glsl/glsl_to_nir.cpp | 10 | ||||
-rw-r--r-- | src/compiler/glsl/ir.h | 23 | ||||
-rw-r--r-- | src/compiler/glsl/ir_clone.cpp | 6 | ||||
-rw-r--r-- | src/compiler/glsl/ir_hierarchical_visitor.cpp | 18 | ||||
-rw-r--r-- | src/compiler/glsl/ir_hierarchical_visitor.h | 2 | ||||
-rw-r--r-- | src/compiler/glsl/ir_hv_accept.cpp | 12 | ||||
-rw-r--r-- | src/compiler/glsl/ir_print_visitor.cpp | 7 | ||||
-rw-r--r-- | src/compiler/glsl/ir_print_visitor.h | 1 | ||||
-rw-r--r-- | src/compiler/glsl/ir_visitor.h | 2 | ||||
-rw-r--r-- | src/mesa/program/ir_to_mesa.cpp | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 |
11 files changed, 95 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 1e096a66c20..883cfb57601 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -63,6 +63,7 @@ public: virtual void visit(ir_loop *); virtual void visit(ir_if *); virtual void visit(ir_discard *); + virtual void visit(ir_demote *); virtual void visit(ir_loop_jump *); virtual void visit(ir_return *); virtual void visit(ir_call *); @@ -776,6 +777,15 @@ nir_visitor::visit(ir_discard *ir) } void +nir_visitor::visit(ir_demote *ir) +{ + nir_intrinsic_instr *demote = + nir_intrinsic_instr_create(this->shader, nir_intrinsic_demote); + + nir_builder_instr_insert(&b, &demote->instr); +} + +void nir_visitor::visit(ir_emit_vertex *ir) { nir_intrinsic_instr *instr = diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h index ba831f2c1ed..e3c28bbb2b8 100644 --- a/src/compiler/glsl/ir.h +++ b/src/compiler/glsl/ir.h @@ -74,6 +74,7 @@ enum ir_node_type { ir_type_loop_jump, ir_type_return, ir_type_discard, + ir_type_demote, ir_type_emit_vertex, ir_type_end_primitive, ir_type_barrier, @@ -1805,6 +1806,28 @@ public: /** + * IR instruction representing demote statements from + * GL_EXT_demote_to_helper_invocation. + */ +class ir_demote : public ir_instruction { +public: + ir_demote() + : ir_instruction(ir_type_demote) + { + } + + virtual ir_demote *clone(void *mem_ctx, struct hash_table *ht) const; + + virtual void accept(ir_visitor *v) + { + v->visit(this); + } + + virtual ir_visitor_status accept(ir_hierarchical_visitor *); +}; + + +/** * Texture sampling opcodes used in ir_texture */ enum ir_texture_opcode { diff --git a/src/compiler/glsl/ir_clone.cpp b/src/compiler/glsl/ir_clone.cpp index c492fdbb3d0..eb24ffe9be2 100644 --- a/src/compiler/glsl/ir_clone.cpp +++ b/src/compiler/glsl/ir_clone.cpp @@ -102,6 +102,12 @@ ir_discard::clone(void *mem_ctx, struct hash_table *ht) const return new(mem_ctx) ir_discard(new_condition); } +ir_demote * +ir_demote::clone(void *mem_ctx, struct hash_table *ht) const +{ + return new(mem_ctx) ir_demote(); +} + ir_loop_jump * ir_loop_jump::clone(void *mem_ctx, struct hash_table *ht) const { diff --git a/src/compiler/glsl/ir_hierarchical_visitor.cpp b/src/compiler/glsl/ir_hierarchical_visitor.cpp index 1d23a776643..8fcf48e2bb4 100644 --- a/src/compiler/glsl/ir_hierarchical_visitor.cpp +++ b/src/compiler/glsl/ir_hierarchical_visitor.cpp @@ -305,6 +305,24 @@ ir_hierarchical_visitor::visit_leave(ir_discard *ir) } ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_demote *ir) +{ + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_demote *ir) +{ + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + + return visit_continue; +} + +ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_if *ir) { if (this->callback_enter != NULL) diff --git a/src/compiler/glsl/ir_hierarchical_visitor.h b/src/compiler/glsl/ir_hierarchical_visitor.h index 5f5acd041b8..e10bb7c60db 100644 --- a/src/compiler/glsl/ir_hierarchical_visitor.h +++ b/src/compiler/glsl/ir_hierarchical_visitor.h @@ -133,6 +133,8 @@ public: virtual ir_visitor_status visit_leave(class ir_return *); virtual ir_visitor_status visit_enter(class ir_discard *); virtual ir_visitor_status visit_leave(class ir_discard *); + virtual ir_visitor_status visit_enter(class ir_demote *); + virtual ir_visitor_status visit_leave(class ir_demote *); virtual ir_visitor_status visit_enter(class ir_if *); virtual ir_visitor_status visit_leave(class ir_if *); virtual ir_visitor_status visit_enter(class ir_emit_vertex *); diff --git a/src/compiler/glsl/ir_hv_accept.cpp b/src/compiler/glsl/ir_hv_accept.cpp index f04a5b6fd19..6e5e25378e1 100644 --- a/src/compiler/glsl/ir_hv_accept.cpp +++ b/src/compiler/glsl/ir_hv_accept.cpp @@ -379,6 +379,18 @@ ir_discard::accept(ir_hierarchical_visitor *v) ir_visitor_status +ir_demote::accept(ir_hierarchical_visitor *v) +{ + ir_visitor_status s = v->visit_enter(this); + + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + return v->visit_leave(this); +} + + +ir_visitor_status ir_if::accept(ir_hierarchical_visitor *v) { ir_visitor_status s = v->visit_enter(this); diff --git a/src/compiler/glsl/ir_print_visitor.cpp b/src/compiler/glsl/ir_print_visitor.cpp index b3a62ce38bd..2eaebb21d47 100644 --- a/src/compiler/glsl/ir_print_visitor.cpp +++ b/src/compiler/glsl/ir_print_visitor.cpp @@ -565,6 +565,13 @@ ir_print_visitor::visit(ir_discard *ir) void +ir_print_visitor::visit(ir_demote *ir) +{ + fprintf(f, "(demote)"); +} + + +void ir_print_visitor::visit(ir_if *ir) { fprintf(f, "(if "); diff --git a/src/compiler/glsl/ir_print_visitor.h b/src/compiler/glsl/ir_print_visitor.h index 652cd90bc00..a71e1aba886 100644 --- a/src/compiler/glsl/ir_print_visitor.h +++ b/src/compiler/glsl/ir_print_visitor.h @@ -63,6 +63,7 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_discard *); + virtual void visit(ir_demote *); virtual void visit(ir_if *); virtual void visit(ir_loop *); virtual void visit(ir_loop_jump *); diff --git a/src/compiler/glsl/ir_visitor.h b/src/compiler/glsl/ir_visitor.h index 117b5bc6ae8..b06e310ffd7 100644 --- a/src/compiler/glsl/ir_visitor.h +++ b/src/compiler/glsl/ir_visitor.h @@ -59,6 +59,7 @@ public: virtual void visit(class ir_call *) = 0; virtual void visit(class ir_return *) = 0; virtual void visit(class ir_discard *) = 0; + virtual void visit(class ir_demote *) = 0; virtual void visit(class ir_if *) = 0; virtual void visit(class ir_loop *) = 0; virtual void visit(class ir_loop_jump *) = 0; @@ -83,6 +84,7 @@ public: virtual void visit(class ir_assignment *) {} virtual void visit(class ir_constant *) {} virtual void visit(class ir_call *) {} + virtual void visit(class ir_demote *) {} virtual void visit(class ir_emit_vertex *) {} virtual void visit(class ir_end_primitive *) {} virtual void visit(class ir_barrier *) {} diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 777fd168c7e..679b46ba7ee 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -252,6 +252,7 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_discard *); + virtual void visit(ir_demote *); virtual void visit(ir_texture *); virtual void visit(ir_if *); virtual void visit(ir_emit_vertex *); @@ -2202,6 +2203,12 @@ ir_to_mesa_visitor::visit(ir_discard *ir) } void +ir_to_mesa_visitor::visit(ir_demote *ir) +{ + assert(!"demote statement unsupported"); +} + +void ir_to_mesa_visitor::visit(ir_if *ir) { ir_to_mesa_instruction *if_inst; diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 9b982569490..b0afe2d2385 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -284,6 +284,7 @@ public: virtual void visit(ir_call *); virtual void visit(ir_return *); virtual void visit(ir_discard *); + virtual void visit(ir_demote *); virtual void visit(ir_texture *); virtual void visit(ir_if *); virtual void visit(ir_emit_vertex *); @@ -4627,6 +4628,12 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) } void +glsl_to_tgsi_visitor::visit(ir_demote *ir) +{ + assert(!"demote statement unsupported"); +} + +void glsl_to_tgsi_visitor::visit(ir_if *ir) { enum tgsi_opcode if_opcode; |