<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 11, 2019 at 10:46 PM Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com">tarceri@itsqueeze.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">---<br>
src/gallium/drivers/radeonsi/si_shader_nir.c | 32 ++++++++++++++------<br>
1 file changed, 22 insertions(+), 10 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c<br>
index 55a950a675c..c547f5f1c30 100644<br>
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c<br>
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c<br>
@@ -687,10 +687,15 @@ void si_nir_scan_shader(const struct nir_shader *nir,<br>
<br>
struct set *ubo_set = _mesa_set_create(NULL, _mesa_hash_pointer,<br>
_mesa_key_pointer_equal);<br>
+ struct set *ssbo_set = _mesa_set_create(NULL, _mesa_hash_pointer,<br>
+ _mesa_key_pointer_equal);<br>
<br>
/* Intialise const_file_max[0] */<br>
info->const_file_max[0] = -1;<br>
<br>
+ /* The first 8 are reserved for atomic counters using ssbo */<br>
+ unsigned ssbo_idx = 8;<br>
+<br>
unsigned ubo_idx = 1;<br>
nir_foreach_variable(variable, &nir->uniforms) {<br>
const struct glsl_type *type = variable->type;<br>
@@ -705,12 +710,16 @@ void si_nir_scan_shader(const struct nir_shader *nir,<br>
*/<br>
if (variable->interface_type != NULL) {<br>
if (variable->data.mode == nir_var_uniform ||<br>
- variable->data.mode == nir_var_mem_ubo) {<br>
+ variable->data.mode == nir_var_mem_ubo ||<br>
+ variable->data.mode == nir_var_mem_ssbo) {<br>
+<br>
+ struct set *buf_set = variable->data.mode == nir_var_mem_ssbo ?<br>
+ ssbo_set : ubo_set;<br>
<br>
unsigned block_count;<br>
if (base_type != GLSL_TYPE_INTERFACE) {<br>
struct set_entry *entry =<br>
- _mesa_set_search(ubo_set, variable->interface_type);<br>
+ _mesa_set_search(buf_set, variable->interface_type);<br>
<br>
/* Check if we have already processed<br>
* a member from this ubo.<br>
@@ -723,16 +732,18 @@ void si_nir_scan_shader(const struct nir_shader *nir,<br>
block_count = aoa_size;<br>
}<br>
<br>
- info->const_buffers_declared |= u_bit_consecutive(ubo_idx, block_count);<br>
- ubo_idx += block_count;<br>
+ if (variable->data.mode == nir_var_uniform ||<br>
+ variable->data.mode == nir_var_mem_ubo) {<br>
+ info->const_buffers_declared |= u_bit_consecutive(ubo_idx, block_count);<br>
+ ubo_idx += block_count;<br>
+ } else {<br>
+ assert(variable->data.mode == nir_var_mem_ssbo);<br>
<br>
- _mesa_set_add(ubo_set, variable->interface_type);<br>
- }<br>
+ info->shader_buffers_declared |= u_bit_consecutive(ssbo_idx, block_count);<br>
+ ssbo_idx += block_count;<br>
+ }<br>
<br>
- if (variable->data.mode == nir_var_mem_ssbo) {<br>
- /* TODO: make this more accurate */<br>
- info->shader_buffers_declared =<br>
- u_bit_consecutive(0, SI_NUM_SHADER_BUFFERS);<br>
+ _mesa_set_add(buf_set, variable->interface_type);<br>
}<br>
<br>
continue;<br>
@@ -776,6 +787,7 @@ void si_nir_scan_shader(const struct nir_shader *nir,<br>
}<br>
<br>
_mesa_set_destroy(ubo_set, NULL);<br>
+ _mesa_set_destroy(ssbo_set, NULL);<br>
<br>
info->num_written_clipdistance = nir->info.clip_distance_array_size;<br>
info->num_written_culldistance = nir->info.cull_distance_array_size;<br>
-- <br>
2.20.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>