diff options
author | Iago Toral Quiroga <[email protected]> | 2014-06-20 10:38:53 +0200 |
---|---|---|
committer | Iago Toral Quiroga <[email protected]> | 2014-06-30 08:08:50 +0200 |
commit | 4b3fc21032a63f483d381c36c8e41bf3540ebfcc (patch) | |
tree | 0f01cb04873f5eb0510713e37af1d200d3dcac09 /src | |
parent | 8639effefeb8c06beedbfcc294694b6bb72db882 (diff) |
glsl: Modify ir_end_primitive to have a stream.
This will be necessary to implement EndStreamPrimitive().
EndPrimitive() will produce an ir_end_primitive with the default stream 0.
Reviewed-by: Chris Forbes <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/builtin_functions.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir.h | 17 | ||||
-rw-r--r-- | src/glsl/ir_hierarchical_visitor.cpp | 25 | ||||
-rw-r--r-- | src/glsl/ir_hierarchical_visitor.h | 3 | ||||
-rw-r--r-- | src/glsl/ir_hv_accept.cpp | 10 | ||||
-rw-r--r-- | src/glsl/ir_rvalue_visitor.cpp | 19 | ||||
-rw-r--r-- | src/glsl/ir_rvalue_visitor.h | 3 |
7 files changed, 64 insertions, 16 deletions
diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp index 33b8843928e..eadc20c6c1d 100644 --- a/src/glsl/builtin_functions.cpp +++ b/src/glsl/builtin_functions.cpp @@ -3883,7 +3883,8 @@ builtin_builder::_EndPrimitive() { MAKE_SIG(glsl_type::void_type, gs_only, 0); - body.emit(new(mem_ctx) ir_end_primitive()); + ir_rvalue *stream = new(mem_ctx) ir_constant(0, 1); + body.emit(new(mem_ctx) ir_end_primitive(stream)); return sig; } diff --git a/src/glsl/ir.h b/src/glsl/ir.h index fa22190d6fa..d5239d4de1b 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -2192,9 +2192,11 @@ public: */ class ir_end_primitive : public ir_instruction { public: - ir_end_primitive() - : ir_instruction(ir_type_end_primitive) + ir_end_primitive(ir_rvalue *stream) + : ir_instruction(ir_type_end_primitive), + stream(stream) { + assert(stream); } virtual void accept(ir_visitor *v) @@ -2202,12 +2204,19 @@ public: v->visit(this); } - virtual ir_end_primitive *clone(void *mem_ctx, struct hash_table *) const + virtual ir_end_primitive *clone(void *mem_ctx, struct hash_table *ht) const { - return new(mem_ctx) ir_end_primitive(); + return new(mem_ctx) ir_end_primitive(this->stream->clone(mem_ctx, ht)); } virtual ir_visitor_status accept(ir_hierarchical_visitor *); + + int stream_id() const + { + return stream->as_constant()->value.i[0]; + } + + ir_rvalue *stream; }; /*@}*/ diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp index 78ae2df1d3d..d3c00ecdb76 100644 --- a/src/glsl/ir_hierarchical_visitor.cpp +++ b/src/glsl/ir_hierarchical_visitor.cpp @@ -69,15 +69,6 @@ ir_hierarchical_visitor::visit(ir_loop_jump *ir) } ir_visitor_status -ir_hierarchical_visitor::visit(ir_end_primitive *ir) -{ - if (this->callback != NULL) - this->callback(ir, this->data); - - return visit_continue; -} - -ir_visitor_status ir_hierarchical_visitor::visit(ir_dereference_variable *ir) { if (this->callback != NULL) @@ -310,6 +301,22 @@ ir_hierarchical_visitor::visit_leave(ir_emit_vertex *ir) return visit_continue; } +ir_visitor_status +ir_hierarchical_visitor::visit_enter(ir_end_primitive *ir) +{ + if (this->callback != NULL) + this->callback(ir, this->data); + + return visit_continue; +} + +ir_visitor_status +ir_hierarchical_visitor::visit_leave(ir_end_primitive *ir) +{ + (void) ir; + return visit_continue; +} + void ir_hierarchical_visitor::run(exec_list *instructions) { diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h index 1679e0a0822..bc89a04d8c9 100644 --- a/src/glsl/ir_hierarchical_visitor.h +++ b/src/glsl/ir_hierarchical_visitor.h @@ -87,7 +87,6 @@ public: virtual ir_visitor_status visit(class ir_variable *); virtual ir_visitor_status visit(class ir_constant *); virtual ir_visitor_status visit(class ir_loop_jump *); - virtual ir_visitor_status visit(class ir_end_primitive *); /** * ir_dereference_variable isn't technically a leaf, but it is treated as a @@ -138,6 +137,8 @@ public: virtual ir_visitor_status visit_leave(class ir_if *); virtual ir_visitor_status visit_enter(class ir_emit_vertex *); virtual ir_visitor_status visit_leave(class ir_emit_vertex *); + virtual ir_visitor_status visit_enter(class ir_end_primitive *); + virtual ir_visitor_status visit_leave(class ir_end_primitive *); /*@}*/ diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index f6332836b1c..3ca7a58871a 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -420,5 +420,13 @@ ir_emit_vertex::accept(ir_hierarchical_visitor *v) ir_visitor_status ir_end_primitive::accept(ir_hierarchical_visitor *v) { - return v->visit(this); + ir_visitor_status s = v->visit_enter(this); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + s = this->stream->accept(v); + if (s != visit_continue) + return (s == visit_continue_with_parent) ? visit_continue : s; + + return (s == visit_stop) ? s : v->visit_leave(this); } diff --git a/src/glsl/ir_rvalue_visitor.cpp b/src/glsl/ir_rvalue_visitor.cpp index eb6691ea1d9..0370170b3bf 100644 --- a/src/glsl/ir_rvalue_visitor.cpp +++ b/src/glsl/ir_rvalue_visitor.cpp @@ -157,6 +157,13 @@ ir_rvalue_base_visitor::rvalue_visit(ir_emit_vertex *ir) } ir_visitor_status +ir_rvalue_base_visitor::rvalue_visit(ir_end_primitive *ir) +{ + handle_rvalue(&ir->stream); + return visit_continue; +} + +ir_visitor_status ir_rvalue_visitor::visit_leave(ir_expression *ir) { return rvalue_visit(ir); @@ -217,6 +224,12 @@ ir_rvalue_visitor::visit_leave(ir_emit_vertex *ir) } ir_visitor_status +ir_rvalue_visitor::visit_leave(ir_end_primitive *ir) +{ + return rvalue_visit(ir); +} + +ir_visitor_status ir_rvalue_enter_visitor::visit_enter(ir_expression *ir) { return rvalue_visit(ir); @@ -275,3 +288,9 @@ ir_rvalue_enter_visitor::visit_enter(ir_emit_vertex *ir) { return rvalue_visit(ir); } + +ir_visitor_status +ir_rvalue_enter_visitor::visit_enter(ir_end_primitive *ir) +{ + return rvalue_visit(ir); +} diff --git a/src/glsl/ir_rvalue_visitor.h b/src/glsl/ir_rvalue_visitor.h index ad1694168a0..04ec0fa398c 100644 --- a/src/glsl/ir_rvalue_visitor.h +++ b/src/glsl/ir_rvalue_visitor.h @@ -42,6 +42,7 @@ public: ir_visitor_status rvalue_visit(ir_swizzle *); ir_visitor_status rvalue_visit(ir_texture *); ir_visitor_status rvalue_visit(ir_emit_vertex *); + ir_visitor_status rvalue_visit(ir_end_primitive *); virtual void handle_rvalue(ir_rvalue **rvalue) = 0; }; @@ -59,6 +60,7 @@ public: virtual ir_visitor_status visit_leave(ir_swizzle *); virtual ir_visitor_status visit_leave(ir_texture *); virtual ir_visitor_status visit_leave(ir_emit_vertex *); + virtual ir_visitor_status visit_leave(ir_end_primitive *); }; class ir_rvalue_enter_visitor : public ir_rvalue_base_visitor { @@ -74,4 +76,5 @@ public: virtual ir_visitor_status visit_enter(ir_swizzle *); virtual ir_visitor_status visit_enter(ir_texture *); virtual ir_visitor_status visit_enter(ir_emit_vertex *); + virtual ir_visitor_status visit_enter(ir_end_primitive *); }; |