<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 28, 2015 at 11:06 AM, Ilia Mirkin <span dir="ltr"><<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently any access params (coherent/volatile/restrict) are being lost<br>
when lowering to the ssbo load/store intrinsics. Keep track of the<br>
variable being used, and bake its access params in as the last arg of<br>
the load/store intrinsics.<br>
<br>
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>><br>
---<br>
<br>
This is RFC because there are still no users, but I'm working on that. Don't<br>
want to be going in the completely wrong direction though...<br>
<br>
src/glsl/lower_ubo_reference.cpp | 22 ++++++++++++++++++++++<br>
1 file changed, 22 insertions(+)<br>
<br>
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp<br>
index a172054..5b3f523 100644<br>
--- a/src/glsl/lower_ubo_reference.cpp<br>
+++ b/src/glsl/lower_ubo_reference.cpp<br>
@@ -104,6 +104,7 @@ public:<br>
<br>
struct gl_shader *shader;<br>
struct gl_uniform_buffer_variable *ubo_var;<br>
+ ir_variable *variable;<br>
ir_rvalue *uniform_block;<br>
bool progress;<br>
};<br>
@@ -317,6 +318,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)<br>
this->buffer_access_type =<br>
var->is_in_shader_storage_block() ?<br>
ssbo_load_access : ubo_load_access;<br>
+ this->variable = var;<br>
<br>
/* Compute the offset to the start if the dereference as well as other<br>
* information we need to configure the write<br>
@@ -370,6 +372,13 @@ shader_storage_buffer_object(const _mesa_glsl_parse_state *state)<br>
return state->ARB_shader_storage_buffer_object_enable;<br>
}<br>
<br>
+static uint32_t ssbo_access_params(const ir_variable *var)<br>
+{<br>
+ return (var->data.image_coherent << 0) |<br>
+ (var->data.image_volatile << 1) |<br>
+ (var->data.image_restrict << 2);<br></blockquote><div><br></div><div>Do 0, 1, and 2 have some special meaning I should know about? I suggest we add an enum to shader_enums.h.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+}<br>
+<br>
ir_call *<br>
lower_ubo_reference_visitor::ssbo_store(void *mem_ctx,<br>
ir_rvalue *deref,<br>
@@ -394,6 +403,10 @@ lower_ubo_reference_visitor::ssbo_store(void *mem_ctx,<br>
ir_variable(glsl_type::uint_type, "write_mask" , ir_var_function_in);<br>
sig_params.push_tail(writemask_ref);<br>
<br>
+ ir_variable *access_ref = new(mem_ctx)<br>
+ ir_variable(glsl_type::uint_type, "access" , ir_var_function_in);<br>
+ sig_params.push_tail(access_ref);<br>
+<br>
ir_function_signature *sig = new(mem_ctx)<br>
ir_function_signature(glsl_type::void_type, shader_storage_buffer_object);<br>
assert(sig);<br>
@@ -408,6 +421,7 @@ lower_ubo_reference_visitor::ssbo_store(void *mem_ctx,<br>
call_params.push_tail(offset->clone(mem_ctx, NULL));<br>
call_params.push_tail(deref->clone(mem_ctx, NULL));<br>
call_params.push_tail(new(mem_ctx) ir_constant(write_mask));<br>
+ call_params.push_tail(new(mem_ctx) ir_constant(ssbo_access_params(variable)));<br>
return new(mem_ctx) ir_call(sig, NULL, &call_params);<br>
}<br>
<br>
@@ -426,6 +440,10 @@ lower_ubo_reference_visitor::ssbo_load(void *mem_ctx,<br>
ir_variable(glsl_type::uint_type, "offset_ref" , ir_var_function_in);<br>
sig_params.push_tail(offset_ref);<br>
<br>
+ ir_variable *access_ref = new(mem_ctx)<br>
+ ir_variable(glsl_type::uint_type, "access" , ir_var_function_in);<br>
+ sig_params.push_tail(access_ref);<br>
+<br>
ir_function_signature *sig =<br>
new(mem_ctx) ir_function_signature(type, shader_storage_buffer_object);<br>
assert(sig);<br>
@@ -444,6 +462,7 @@ lower_ubo_reference_visitor::ssbo_load(void *mem_ctx,<br>
exec_list call_params;<br>
call_params.push_tail(this->uniform_block->clone(mem_ctx, NULL));<br>
call_params.push_tail(offset->clone(mem_ctx, NULL));<br>
+ call_params.push_tail(new(mem_ctx) ir_constant(ssbo_access_params(variable)));<br>
<br>
return new(mem_ctx) ir_call(sig, deref_result, &call_params);<br>
}<br>
@@ -499,6 +518,7 @@ lower_ubo_reference_visitor::write_to_memory(void *mem_ctx,<br>
unsigned packing = var->get_interface_type()->interface_packing;<br>
<br>
this->buffer_access_type = ssbo_store_access;<br>
+ this->variable = var;<br>
<br>
/* Compute the offset to the start if the dereference as well as other<br>
* information we need to configure the write<br>
@@ -678,6 +698,7 @@ lower_ubo_reference_visitor::process_ssbo_unsized_array_length(ir_rvalue **rvalu<br>
int unsized_array_stride = calculate_unsized_array_stride(deref, packing);<br>
<br>
this->buffer_access_type = ssbo_unsized_array_length_access;<br>
+ this->variable = var;<br>
<br>
/* Compute the offset to the start if the dereference as well as other<br>
* information we need to calculate the length.<br>
@@ -910,6 +931,7 @@ lower_ubo_reference_visitor::lower_ssbo_atomic_intrinsic(ir_call *ir)<br>
unsigned packing = var->get_interface_type()->interface_packing;<br>
<br>
this->buffer_access_type = ssbo_atomic_access;<br>
+ this->variable = var;<br>
<br>
setup_for_load_or_store(mem_ctx, var, deref,<br>
&offset, &const_offset,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.4.10<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>