[Mesa-dev] [RFC PATCH 50/56] glsl: Add ir node for barrier
Chris Forbes
chrisf at ijw.co.nz
Sat Sep 20 18:41:30 PDT 2014
---
src/glsl/ir.h | 24 ++++++++++++++++++++++++
src/glsl/ir_hierarchical_visitor.cpp | 9 +++++++++
src/glsl/ir_hierarchical_visitor.h | 1 +
src/glsl/ir_hv_accept.cpp | 6 ++++++
src/glsl/ir_print_visitor.cpp | 5 +++++
src/glsl/ir_print_visitor.h | 1 +
src/glsl/ir_reader.cpp | 15 +++++++++++++++
src/glsl/ir_visitor.h | 2 ++
src/mesa/drivers/dri/i965/brw_fs.h | 1 +
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 ++++++
src/mesa/drivers/dri/i965/brw_vec4.h | 1 +
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 6 ++++++
src/mesa/program/ir_to_mesa.cpp | 7 +++++++
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 +++++++
14 files changed, 91 insertions(+)
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 94c330a..45f85da 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -78,6 +78,7 @@ enum ir_node_type {
ir_type_discard,
ir_type_emit_vertex,
ir_type_end_primitive,
+ ir_type_barrier,
ir_type_max, /**< maximum ir_type enum number, for validation */
ir_type_unset = ir_type_max
};
@@ -2263,6 +2264,29 @@ public:
ir_rvalue *stream;
};
+/**
+ * IR instruction for tessellation control shader barrier.
+ */
+class ir_barrier : public ir_instruction {
+public:
+ ir_barrier()
+ : ir_instruction(ir_type_barrier)
+ {
+ }
+
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
+ virtual ir_barrier *clone(void *mem_ctx, struct hash_table *) const
+ {
+ return new(mem_ctx) ir_barrier();
+ }
+
+ virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+};
+
/*@}*/
/**
diff --git a/src/glsl/ir_hierarchical_visitor.cpp b/src/glsl/ir_hierarchical_visitor.cpp
index adb6294..1d23a77 100644
--- a/src/glsl/ir_hierarchical_visitor.cpp
+++ b/src/glsl/ir_hierarchical_visitor.cpp
@@ -80,6 +80,15 @@ ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
}
ir_visitor_status
+ir_hierarchical_visitor::visit(ir_barrier *ir)
+{
+ if (this->callback_enter != NULL)
+ this->callback_enter(ir, this->data_enter);
+
+ return visit_continue;
+}
+
+ir_visitor_status
ir_hierarchical_visitor::visit_enter(ir_loop *ir)
{
if (this->callback_enter != NULL)
diff --git a/src/glsl/ir_hierarchical_visitor.h b/src/glsl/ir_hierarchical_visitor.h
index faa52fd..d667853 100644
--- a/src/glsl/ir_hierarchical_visitor.h
+++ b/src/glsl/ir_hierarchical_visitor.h
@@ -87,6 +87,7 @@ 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_barrier *);
/**
* ir_dereference_variable isn't technically a leaf, but it is treated as a
diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp
index be5b3ea..d3662cf 100644
--- a/src/glsl/ir_hv_accept.cpp
+++ b/src/glsl/ir_hv_accept.cpp
@@ -429,3 +429,9 @@ ir_end_primitive::accept(ir_hierarchical_visitor *v)
return (s == visit_stop) ? s : v->visit_leave(this);
}
+
+ir_visitor_status
+ir_barrier::accept(ir_hierarchical_visitor *v)
+{
+ return v->visit(this);
+}
diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
index 1cf28ea..edffe80 100644
--- a/src/glsl/ir_print_visitor.cpp
+++ b/src/glsl/ir_print_visitor.cpp
@@ -563,5 +563,10 @@ ir_print_visitor::visit(ir_end_primitive *ir)
fprintf(f, "(end-primitive ");
ir->stream->accept(this);
fprintf(f, ")\n");
+}
+void
+ir_print_visitor::visit(ir_barrier *ir)
+{
+ fprintf(f, "(barrier)\n");
}
diff --git a/src/glsl/ir_print_visitor.h b/src/glsl/ir_print_visitor.h
index 98f041d..965e63a 100644
--- a/src/glsl/ir_print_visitor.h
+++ b/src/glsl/ir_print_visitor.h
@@ -71,6 +71,7 @@ public:
virtual void visit(ir_loop_jump *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
private:
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 456dd4f..c8d061e 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -63,6 +63,7 @@ private:
ir_texture *read_texture(s_expression *);
ir_emit_vertex *read_emit_vertex(s_expression *);
ir_end_primitive *read_end_primitive(s_expression *);
+ ir_barrier *read_barrier(s_expression *);
ir_dereference *read_dereference(s_expression *);
ir_dereference_variable *read_var_ref(s_expression *);
@@ -375,6 +376,8 @@ ir_reader::read_instruction(s_expression *expr, ir_loop *loop_ctx)
inst = read_emit_vertex(list);
} else if (strcmp(tag->value(), "end-primitive") == 0) {
inst = read_end_primitive(list);
+ } else if (strcmp(tag->value(), "barrier") == 0) {
+ inst = read_barrier(list);
} else {
inst = read_rvalue(list);
if (inst == NULL)
@@ -1144,3 +1147,15 @@ ir_reader::read_end_primitive(s_expression *expr)
ir_read_error(NULL, "when reading end-primitive");
return NULL;
}
+
+ir_barrier *
+ir_reader::read_barrier(s_expression *expr)
+{
+ s_pattern pat[] = { "barrier" };
+
+ if (MATCH(expr, pat)) {
+ return new(mem_ctx) ir_barrier();
+ }
+ ir_read_error(NULL, "when reading barrier");
+ return NULL;
+}
diff --git a/src/glsl/ir_visitor.h b/src/glsl/ir_visitor.h
index 40f96ff..7c38481 100644
--- a/src/glsl/ir_visitor.h
+++ b/src/glsl/ir_visitor.h
@@ -65,6 +65,7 @@ public:
virtual void visit(class ir_loop_jump *) = 0;
virtual void visit(class ir_emit_vertex *) = 0;
virtual void visit(class ir_end_primitive *) = 0;
+ virtual void visit(class ir_barrier *) = 0;
/*@}*/
};
@@ -85,6 +86,7 @@ public:
virtual void visit(class ir_call *) {}
virtual void visit(class ir_emit_vertex *) {}
virtual void visit(class ir_end_primitive *) {}
+ virtual void visit(class ir_barrier *) {}
};
#endif /* __cplusplus */
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index d40a2e3..0f06361 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -240,6 +240,7 @@ public:
void visit(ir_function_signature *ir);
void visit(ir_emit_vertex *);
void visit(ir_end_primitive *);
+ void visit(ir_barrier *);
uint32_t gather_channel(ir_texture *ir, uint32_t sampler);
void swizzle_result(ir_texture *ir, fs_reg orig_val, uint32_t sampler);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
index 2d5318a..e45454d 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
@@ -2703,6 +2703,12 @@ fs_visitor::visit(ir_end_primitive *)
}
void
+fs_visitor::visit(ir_barrier *)
+{
+ unreachable("not reached");
+}
+
+void
fs_visitor::emit_untyped_atomic(unsigned atomic_op, unsigned surf_index,
fs_reg dst, fs_reg offset, fs_reg src0,
fs_reg src1)
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 69faa74..7488b54 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -346,6 +346,7 @@ public:
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
src_reg result;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index b913073..230673a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -2857,6 +2857,12 @@ vec4_visitor::visit(ir_end_primitive *)
}
void
+vec4_visitor::visit(ir_barrier *)
+{
+ unreachable("not reached");
+}
+
+void
vec4_visitor::emit_untyped_atomic(unsigned atomic_op, unsigned surf_index,
dst_reg dst, src_reg offset,
src_reg src0, src_reg src1)
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 95eecac..40be989 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -263,6 +263,7 @@ public:
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
src_reg result;
@@ -2196,6 +2197,12 @@ ir_to_mesa_visitor::visit(ir_end_primitive *)
assert(!"Geometry shaders not supported.");
}
+void
+ir_to_mesa_visitor::visit(ir_barrier *)
+{
+ assert(!"Tessellation shaders not supported.");
+}
+
ir_to_mesa_visitor::ir_to_mesa_visitor()
{
result.file = PROGRAM_UNDEFINED;
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 38aa567..f2e6907 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -375,6 +375,7 @@ public:
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
virtual void visit(ir_end_primitive *);
+ virtual void visit(ir_barrier *);
/*@}*/
st_src_reg result;
@@ -3153,6 +3154,12 @@ glsl_to_tgsi_visitor::visit(ir_end_primitive *ir)
emit(ir, TGSI_OPCODE_ENDPRIM, undef_dst, this->result);
}
+void
+glsl_to_tgsi_visitor::visit(ir_barrier *ir)
+{
+ assert(!"Not implemented");
+}
+
glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
{
result.file = PROGRAM_UNDEFINED;
--
2.1.0
More information about the mesa-dev
mailing list