<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 04/01/17 18:16, Jason Ekstrand
wrote:<br>
</div>
<blockquote
cite="mid:CAOFGe95_JMjdfGKT68OJdMhUQeHXWaFDdfjjkhwiTK5iGQdwJg@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="auto">
<div>
<div class="gmail_extra">
<div class="gmail_quote">On Jan 4, 2017 12:02, "Lionel
Landwerlin" <<a moz-do-not-send="true"
href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a>>
wrote:<br type="attribution">
<blockquote class="quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">v2:
Move relative push constant relative offset computation
down to<br>
_vtn_load_store_tail() (Jason)<br>
</blockquote>
</div>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">Hm... I may not have been particularly clear. I
meant, more or less, to have get_io_offset (is that what its
called?) return the offer in terms of base, offset, and range
like the push constant intrinsic expects and then, for
everything else, do an add to combine the base and indirect
parts. Does that make sense? There's even a comment in there
about how I was lazy and just trusted constant folding before.</div>
</div>
</blockquote>
<br>
I'm afraid I don't follow :(<br>
You would like to get this as a nir pass?<br>
<br>
<blockquote
cite="mid:CAOFGe95_JMjdfGKT68OJdMhUQeHXWaFDdfjjkhwiTK5iGQdwJg@mail.gmail.com"
type="cite">
<div dir="auto">
<div dir="auto"><br>
</div>
<div dir="auto">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="quoted-text"><br>
Signed-off-by: Lionel Landwerlin <<a
moz-do-not-send="true"
href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
---<br>
</div>
src/compiler/spirv/vtn_<wbr>variables.c |
78 ++++++++++++++++++++-----<br>
src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c |
1 -<br>
2 files changed, 65 insertions(+), 14 deletions(-)<br>
<br>
diff --git a/src/compiler/spirv/vtn_<wbr>variables.c
b/src/compiler/spirv/vtn_<wbr>variables.c<br>
index 040c65061c..e3845365bd 100644<br>
--- a/src/compiler/spirv/vtn_<wbr>variables.c<br>
+++ b/src/compiler/spirv/vtn_<wbr>variables.c<br>
@@ -434,8 +434,37 @@ vtn_type_block_size(struct vtn_type
*type)<br>
<div class="elided-text"> }<br>
<br>
static void<br>
+vtn_access_chain_get_offset_<wbr>size(struct
vtn_access_chain *chain,<br>
+ unsigned
*access_offset,<br>
+ unsigned
*access_size)<br>
+{<br>
+ /* Only valid for push constants accesses now. */<br>
+ assert(chain->var->mode ==
vtn_variable_mode_push_<wbr>constant);<br>
+<br>
+ struct vtn_type *type = chain->var->type;<br>
+<br>
+ *access_offset = 0;<br>
+<br>
+ for (unsigned i = 0; i < chain->length; i++)
{<br>
+ if (chain->link[i].mode !=
vtn_access_mode_literal)<br>
+ break;<br>
+<br>
+ if (glsl_type_is_struct(type-><wbr>type)) {<br>
+ *access_offset +=
type->offsets[chain->link[i].<wbr>id];<br>
+ type = type->members[chain->link[i].<wbr>id];<br>
+ } else {<br>
+ *access_offset += type->stride *
chain->link[i].id;<br>
+ type = type->array_element;<br>
+ }<br>
+ }<br>
+<br>
+ *access_size = vtn_type_block_size(type);<br>
+}<br>
+<br>
+static void<br>
_vtn_load_store_tail(struct vtn_builder *b,
nir_intrinsic_op op, bool load,<br>
nir_ssa_def *index, nir_ssa_def
*offset,<br>
</div>
<div class="quoted-text">+ unsigned
access_offset, unsigned access_size,<br>
</div>
<div class="quoted-text"> struct
vtn_ssa_value **inout, const struct glsl_type *type)<br>
</div>
<div class="quoted-text"> {<br>
nir_intrinsic_instr *instr =
nir_intrinsic_instr_create(b-><wbr>nb.shader, op);<br>
</div>
@@ -447,18 +476,25 @@ _vtn_load_store_tail(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> instr->src[src++] =
nir_src_for_ssa((*inout)->def)<wbr>;<br>
}<br>
<br>
- /* We set the base and size for push constant load
to the entire push<br>
- * constant block for now.<br>
- */<br>
if (op == nir_intrinsic_load_push_<wbr>constant) {<br>
- nir_intrinsic_set_base(instr, 0);<br>
- nir_intrinsic_set_range(instr, 128);<br>
+ assert(access_offset % 4 == 0);<br>
+<br>
+ nir_intrinsic_set_base(instr, access_offset);<br>
+ nir_intrinsic_set_range(instr, access_size);<br>
}<br>
<br>
if (index)<br>
</div>
instr->src[src++] = nir_src_for_ssa(index);<br>
<br>
- instr->src[src++] = nir_src_for_ssa(offset);<br>
+ if (op == nir_intrinsic_load_push_<wbr>constant) {<br>
<div class="quoted-text">+ /* We need to subtract
the offset from where the intrinsic will load the<br>
+ * data. */<br>
</div>
+ instr->src[src++] =<br>
+ nir_src_for_ssa(nir_isub(&b-><wbr>nb,
offset,<br>
+
nir_imm_int(&b->nb, access_offset)));<br>
+ } else {<br>
+ instr->src[src++] = nir_src_for_ssa(offset);<br>
+ }<br>
<br>
if (load) {<br>
nir_ssa_dest_init(&instr-><wbr>instr,
&instr->dest,<br>
@@ -476,6 +512,7 @@ _vtn_load_store_tail(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> static void<br>
_vtn_block_load_store(struct vtn_builder *b,
nir_intrinsic_op op, bool load,<br>
nir_ssa_def *index, nir_ssa_def
*offset,<br>
+ unsigned access_offset,
unsigned access_size,<br>
struct vtn_access_chain *chain,
unsigned chain_idx,<br>
struct vtn_type *type, struct
vtn_ssa_value **inout)<br>
{<br>
</div>
@@ -520,6 +557,7 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text">
nir_iadd(&b->nb, offset,<br>
nir_imm_int(&b->nb,
i * type->stride));<br>
</div>
<div class="quoted-text">
_vtn_load_store_tail(b, op, load, index, elem_offset,<br>
</div>
+ access_offset,
access_size,<br>
&(*inout)->elems[i],<br>
glsl_vector_type(base_type, vec_width));<br>
}<br>
@@ -541,8 +579,9 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
offset = nir_iadd(&b->nb, offset,
row_offset);<br>
<div class="quoted-text"> if (load)<br>
*inout = vtn_create_ssa_value(b,
glsl_scalar_type(base_type));<br>
</div>
<div class="quoted-text">-
_vtn_load_store_tail(b, op, load, index, offset,
inout,<br>
</div>
-
glsl_scalar_type(base_type));<br>
<div class="quoted-text">+
_vtn_load_store_tail(b, op, load, index, offset,<br>
</div>
+ access_offset,
access_size,<br>
+ inout,
glsl_scalar_type(base_type));<br>
<div class="quoted-text"> } else {<br>
/* Grabbing a column; picking one
element off each row */<br>
unsigned num_comps =
glsl_get_vector_elements(type-<wbr>>type);<br>
</div>
@@ -562,6 +601,7 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> }<br>
comp = &temp_val;<br>
_vtn_load_store_tail(b, op, load,
index, elem_offset,<br>
</div>
+ access_offset,
access_size,<br>
&comp,
glsl_scalar_type(base_type));<br>
<div class="quoted-text"> comps[i] =
comp->def;<br>
}<br>
</div>
@@ -580,20 +620,25 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> offset =
nir_iadd(&b->nb, offset, col_offset);<br>
<br>
_vtn_block_load_store(b, op, load, index,
offset,<br>
+ access_offset,
access_size,<br>
chain, chain_idx +
1,<br>
type->array_element, inout);<br>
}<br>
} else if (chain == NULL) {<br>
/* Single whole vector */<br>
assert(glsl_type_is_vector_or_<wbr>scalar(type->type));<br>
- _vtn_load_store_tail(b, op, load, index,
offset, inout, type->type);<br>
+ _vtn_load_store_tail(b, op, load, index,
offset,<br>
</div>
+ access_offset,
access_size,<br>
+ inout, type->type);<br>
<div class="quoted-text"> } else {<br>
/* Single component of a vector. Fall
through to array case. */<br>
nir_ssa_def *elem_offset =<br>
vtn_access_link_as_ssa(b,
chain->link[chain_idx], type->stride);<br>
offset = nir_iadd(&b->nb, offset,
elem_offset);<br>
<br>
- _vtn_block_load_store(b, op, load, index,
offset, NULL, 0,<br>
+ _vtn_block_load_store(b, op, load, index,
offset,<br>
+ access_offset,
access_size,<br>
+ NULL, 0,<br>
type->array_element, inout);<br>
}<br>
return;<br>
</div>
@@ -603,7 +648,9 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> for (unsigned i = 0; i
< elems; i++) {<br>
nir_ssa_def *elem_off =<br>
nir_iadd(&b->nb, offset,
nir_imm_int(&b->nb, i * type->stride));<br>
- _vtn_block_load_store(b, op, load, index,
elem_off, NULL, 0,<br>
+ _vtn_block_load_store(b, op, load, index,
elem_off,<br>
+ access_offset,
access_size,<br>
+ NULL, 0,<br>
type->array_element, &(*inout)->elems[i]);<br>
}<br>
return;<br>
</div>
@@ -614,7 +661,9 @@ _vtn_block_load_store(struct
vtn_builder *b, nir_intrinsic_op op, bool load,<br>
<div class="quoted-text"> for (unsigned i = 0; i
< elems; i++) {<br>
nir_ssa_def *elem_off =<br>
nir_iadd(&b->nb, offset,
nir_imm_int(&b->nb, type->offsets[i]));<br>
- _vtn_block_load_store(b, op, load, index,
elem_off, NULL, 0,<br>
+ _vtn_block_load_store(b, op, load, index,
elem_off,<br>
+ access_offset,
access_size,<br>
+ NULL, 0,<br>
type->members[i],
&(*inout)->elems[i]);<br>
}<br>
return;<br>
</div>
@@ -629,6 +678,7 @@ static struct vtn_ssa_value *<br>
<div class="quoted-text"> vtn_block_load(struct
vtn_builder *b, struct vtn_access_chain *src)<br>
{<br>
</div>
<div class="quoted-text"> nir_intrinsic_op op;<br>
+ unsigned access_offset = 0, access_size = 0;<br>
switch (src->var->mode) {<br>
case vtn_variable_mode_ubo:<br>
op = nir_intrinsic_load_ubo;<br>
</div>
@@ -638,6 +688,7 @@ vtn_block_load(struct vtn_builder
*b, struct vtn_access_chain *src)<br>
<div class="quoted-text"> break;<br>
case vtn_variable_mode_push_<wbr>constant:<br>
op = nir_intrinsic_load_push_<wbr>constant;<br>
+ vtn_access_chain_get_offset_<wbr>size(src,
&access_offset, &access_size);<br>
</div>
<div class="quoted-text"> break;<br>
default:<br>
assert(!"Invalid block variable mode");<br>
</div>
@@ -650,6 +701,7 @@ vtn_block_load(struct vtn_builder
*b, struct vtn_access_chain *src)<br>
<div class="quoted-text"><br>
struct vtn_ssa_value *value = NULL;<br>
_vtn_block_load_store(b, op, true, index, offset,<br>
+ access_offset, access_size,<br>
src, chain_idx, type,
&value);<br>
return value;<br>
}<br>
</div>
@@ -664,7 +716,7 @@ vtn_block_store(struct vtn_builder
*b, struct vtn_ssa_value *src,<br>
<div class="elided-text"> offset =
vtn_access_chain_to_offset(b, dst, &index,
&type, &chain_idx, true);<br>
<br>
_vtn_block_load_store(b, nir_intrinsic_store_ssbo,
false, index, offset,<br>
- dst, chain_idx, type,
&src);<br>
+ 0, 0, dst, chain_idx, type,
&src);<br>
}<br>
<br>
static bool<br>
diff --git a/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c
b/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
index 64c155372f..b66552825b 100644<br>
--- a/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
+++ b/src/intel/vulkan/anv_nir_<wbr>lower_push_constants.c<br>
@@ -42,7 +42,6 @@ anv_nir_lower_push_constants(<wbr>nir_shader
*shader)<br>
continue;<br>
<br>
assert(intrin->const_index[0] % 4 ==
0);<br>
- assert(intrin->const_index[1] == 128);<br>
<br>
/* We just turn them into uniform loads
*/<br>
intrin->intrinsic =
nir_intrinsic_load_uniform;<br>
--<br>
2.11.0<br>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
mesa-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>