<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-04-19 0:15 GMT+02:00 Rob Clark <span dir="ltr"><<a href="mailto:robdclark@gmail.com" target="_blank">robdclark@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sync to the same files from freedreno.git to correct decoding of ldgb/<br>
stgb instructions.<br>
<br>
Signed-off-by: Rob Clark <<a href="mailto:robdclark@gmail.com">robdclark@gmail.com</a>><br>
---<br>
src/gallium/drivers/freedreno/<wbr>a2xx/disasm-a2xx.c | 2 +-<br>
src/gallium/drivers/freedreno/<wbr>disasm.h | 3 +<br>
src/gallium/drivers/freedreno/<wbr>ir3/disasm-a3xx.c | 83 +++++++++++++++++++++---<br>
src/gallium/drivers/freedreno/<wbr>ir3/instr-a3xx.h | 77 ++++++++++++++++++++--<br>
src/gallium/drivers/freedreno/<wbr>ir3/ir3.h | 2 +-<br>
src/gallium/drivers/freedreno/<wbr>ir3/ir3_nir.c | 4 +-<br>
src/gallium/drivers/freedreno/<wbr>ir3/ir3_shader.c | 10 ++-<br>
7 files changed, 161 insertions(+), 20 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/a2xx/disasm-a2xx.c b/src/gallium/drivers/<wbr>freedreno/a2xx/disasm-a2xx.c<br>
index fc309e8..c380450 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/a2xx/disasm-a2xx.c<br>
+++ b/src/gallium/drivers/<wbr>freedreno/a2xx/disasm-a2xx.c<br>
@@ -111,7 +111,7 @@ static void print_export_comment(uint32_t num, enum shader_t type)<br>
case 0: name = "gl_FragColor"; break;<br>
}<br>
break;<br>
- case SHADER_COMPUTE:<br>
+ default:<br>
unreachable("not reached");<br>
}<br>
/* if we had a symbol table here, we could look<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/disasm.h b/src/gallium/drivers/<wbr>freedreno/disasm.h<br>
index e81dd1c..bac1215 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/disasm.h<br>
+++ b/src/gallium/drivers/<wbr>freedreno/disasm.h<br>
@@ -26,6 +26,9 @@<br>
<br>
enum shader_t {<br>
SHADER_VERTEX,<br>
+ SHADER_TCS,<br>
+ SHADER_TES,<br>
+ SHADER_GEOM,<br>
SHADER_FRAGMENT,<br>
SHADER_COMPUTE,<br>
};<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/disasm-a3xx.c b/src/gallium/drivers/<wbr>freedreno/ir3/disasm-a3xx.c<br>
index e29d156..4685ed6 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/disasm-a3xx.c<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/disasm-a3xx.c<br>
@@ -159,16 +159,16 @@ static void print_instr_cat0(instr_t *instr)<br>
break;<br>
case OPC_BR:<br>
printf(" %sp0.%c, #%d", cat0->inv ? "!" : "",<br>
- component[cat0->comp], cat0->a3xx.immed);<br>
+ component[cat0->comp], cat0->a5xx.immed);<br>
break;<br>
case OPC_JUMP:<br>
case OPC_CALL:<br>
- printf(" #%d", cat0->a3xx.immed);<br>
+ printf(" #%d", cat0->a5xx.immed);<br>
break;<br>
}<br>
<br>
- if ((debug & PRINT_VERBOSE) && (cat0->a3xx.dummy1|cat0-><wbr>dummy2|cat0->dummy3|cat0-><wbr>dummy4))<br>
- printf("\t{0: %x,%x,%x,%x}", cat0->a3xx.dummy1, cat0->dummy2, cat0->dummy3, cat0->dummy4);<br>
+ if ((debug & PRINT_VERBOSE) && (cat0->dummy2|cat0->dummy3|<wbr>cat0->dummy4))<br>
+ printf("\t{0: %x,%x,%x}", cat0->dummy2, cat0->dummy3, cat0->dummy4);<br>
}<br>
<br>
static void print_instr_cat1(instr_t *instr)<br>
@@ -506,7 +506,6 @@ static void print_instr_cat6(instr_t *instr)<br>
case OPC_STP:<br>
case OPC_STI:<br>
case OPC_STLW:<br>
- case OPC_STGB_4D_4:<br>
case OPC_STIB:<br>
dst.full = true;<br>
src1.full = type_size(cat6->type) == 32;<br>
@@ -523,6 +522,18 @@ static void print_instr_cat6(instr_t *instr)<br>
case OPC_PREFETCH:<br>
case OPC_RESINFO:<br>
break;<br>
+ case OPC_LDGB:<br>
+ printf(".%s", cat6->ldgb.typed ? "typed" : "untyped");<br>
+ printf(".%dd", cat6->ldgb.d + 1);<br>
+ printf(".%s", type[cat6->type]);<br>
+ printf(".%d", cat6->ldgb.type_size + 1);<br>
+ break;<br>
+ case OPC_STGB:<br>
+ printf(".%s", cat6->stgb.typed ? "typed" : "untyped");<br>
+ printf(".%dd", cat6->stgb.d + 1);<br>
+ printf(".%s", type[cat6->type]);<br>
+ printf(".%d", cat6->stgb.type_size + 1);<br>
+ break;<br>
case OPC_ATOMIC_ADD:<br>
case OPC_ATOMIC_SUB:<br>
case OPC_ATOMIC_XCHG:<br>
@@ -558,6 +569,7 @@ static void print_instr_cat6(instr_t *instr)<br>
break;<br>
<br>
case OPC_LDG:<br>
+ case OPC_LDC:<br>
ss = 'g';<br>
break;<br>
case OPC_LDP:<br>
@@ -589,6 +601,61 @@ static void print_instr_cat6(instr_t *instr)<br>
break;<br>
}<br>
<br>
+ if (_OPC(6, cat6->opc) == OPC_STGB) {<br>
+ struct reginfo src3;<br>
+<br>
+ memset(&src3, 0, sizeof(src3));<br>
+<br>
+ src1.reg = (reg_t)(cat6->stgb.src1);<br>
+ src2.reg = (reg_t)(cat6->stgb.src2);<br>
+ <a href="http://src2.im" rel="noreferrer" target="_blank">src2.im</a> = cat6->stgb.src2_im;<br>
+ src3.reg = (reg_t)(cat6->stgb.src3);<br>
+ <a href="http://src3.im" rel="noreferrer" target="_blank">src3.im</a> = cat6->stgb.src3_im;<br>
+ src3.full = true;<br>
+<br>
+ printf("g[%u], ", cat6->stgb.dst_ssbo);<br>
+ print_src(&src1);<br>
+ printf(", ");<br>
+ print_src(&src2);<br>
+ printf(", ");<br>
+ print_src(&src3);<br>
+<br>
+ if (debug & PRINT_VERBOSE)<br>
+ printf(" (pad0=%x, pad3=%x)", cat6->stgb.pad0, cat6->stgb.pad3);<br>
+<br>
+ return;<br>
+ }<br>
+<br>
+ if ((_OPC(6, cat6->opc) == OPC_LDGB) || is_atomic(_OPC(6, cat6->opc))) {<br>
+<br>
+ src1.reg = (reg_t)(cat6->ldgb.src1);<br>
+ <a href="http://src1.im" rel="noreferrer" target="_blank">src1.im</a> = cat6->ldgb.src1_im;<br>
+ src2.reg = (reg_t)(cat6->ldgb.src2);<br>
+ <a href="http://src2.im" rel="noreferrer" target="_blank">src2.im</a> = cat6->ldgb.src2_im;<br>
+ dst.reg = (reg_t)(cat6->ldgb.dst);<br>
+<br>
+ print_src(&dst);<br>
+ printf(", ");<br>
+ printf("g[%u], ", cat6->ldgb.src_ssbo);<br>
+ print_src(&src1);<br>
+ printf(", ");<br>
+ print_src(&src2);<br>
+<br>
+ if (is_atomic(_OPC(6, cat6->opc))) {<br>
+ struct reginfo src3;<br>
+ memset(&src3, 0, sizeof(src3));<br>
+ src3.reg = (reg_t)(cat6->ldgb.src3);<br>
+ src3.full = true;<br>
+<br>
+ printf(", ");<br>
+ print_src(&src3);<br>
+ }<br>
+<br>
+ if (debug & PRINT_VERBOSE)<br>
+ printf(" (pad0=%x, pad3=%x, mustbe0=%x)", cat6->ldgb.pad0, cat6->ldgb.pad3, cat6->ldgb.mustbe0);<br>
+<br>
+ return;<br>
+ }<br>
if (cat6->dst_off) {<br>
dst.reg = (reg_t)(cat6->c.dst);<br>
dstoff = cat6->c.off;<br>
@@ -806,10 +873,10 @@ static const struct opc_info {<br>
OPC(6, OPC_ATOMIC_AND, atomic.and),<br>
OPC(6, OPC_ATOMIC_OR, atomic.or),<br>
OPC(6, OPC_ATOMIC_XOR, atomic.xor),<br>
- OPC(6, OPC_LDGB_TYPED_4D, ldgb.typed.3d),<br>
- OPC(6, OPC_STGB_4D_4, stgb.4d.4),<br>
+ OPC(6, OPC_LDGB, ldgb),<br>
+ OPC(6, OPC_STGB, stgb),<br>
OPC(6, OPC_STIB, stib),<br>
- OPC(6, OPC_LDC_4, ldc.4),<br>
+ OPC(6, OPC_LDC, ldc),<br>
OPC(6, OPC_LDLV, ldlv),<br>
<br>
<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/instr-a3xx.h b/src/gallium/drivers/<wbr>freedreno/ir3/instr-a3xx.h<br>
index 0d369b6..b429b3b 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/instr-a3xx.h<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/instr-a3xx.h<br>
@@ -189,10 +189,10 @@ typedef enum {<br>
OPC_ATOMIC_AND = _OPC(6, 24),<br>
OPC_ATOMIC_OR = _OPC(6, 25),<br>
OPC_ATOMIC_XOR = _OPC(6, 26),<br>
- OPC_LDGB_TYPED_4D = _OPC(6, 27),<br>
- OPC_STGB_4D_4 = _OPC(6, 28),<br>
+ OPC_LDGB = _OPC(6, 27),<br>
+ OPC_STGB = _OPC(6, 28),<br>
OPC_STIB = _OPC(6, 29),<br>
- OPC_LDC_4 = _OPC(6, 30),<br>
+ OPC_LDC = _OPC(6, 30),<br>
OPC_LDLV = _OPC(6, 31),<br>
<br>
/* meta instructions (category -1): */<br>
@@ -639,18 +639,63 @@ typedef struct PACKED {<br>
<br>
uint32_t dst : 8;<br>
uint32_t mustbe0 : 1;<br>
- uint32_t pad0 : 23;<br>
+ uint32_t idx : 8;<br>
+ uint32_t pad0 : 15;<br>
} instr_cat6d_t;<br>
<br>
-/* I think some of the other cat6 instructions use additional<br>
- * sub-encodings..<br>
+/* ldgb and atomics.. atomics use 3rd src and pad0=1, pad3=3. For<br>
+ * ldgb pad0=0, pad3=2<br>
*/<br>
+typedef struct PACKED {<br>
+ /* dword0: */<br>
+ uint32_t pad0 : 1;<br>
+ uint32_t src3 : 8;<br>
+ uint32_t d : 2;<br>
+ uint32_t typed : 1;<br>
+ uint32_t type_size : 2;<br>
+ uint32_t src1 : 8;<br>
+ uint32_t src1_im : 1;<br>
+ uint32_t src2_im : 1;<br>
+ uint32_t src2 : 8;<br>
+<br>
+ /* dword1: */<br>
+ uint32_t dst : 8;<br>
+ uint32_t mustbe0 : 1;<br>
+ uint32_t src_ssbo : 8;<br>
+ uint32_t pad2 : 3; // type<br>
+ uint32_t pad3 : 2;<br>
+ uint32_t pad4 : 10; // opc/jmp_tgt/sync/opc_cat<br>
+} instr_cat6ldgb_t;<br>
+<br>
+/* stgb, pad0=0, pad3=2<br>
+ */<br>
+typedef struct PACKED {<br>
+ /* dword0: */<br>
+ uint32_t mustbe1 : 1; // ???<br>
+ uint32_t src1 : 8;<br>
+ uint32_t d : 2;<br>
+ uint32_t typed : 1;<br>
+ uint32_t type_size : 2;<br>
+ uint32_t pad0 : 9;<br>
+ uint32_t src2_im : 1;<br>
+ uint32_t src2 : 8;<br>
+<br>
+ /* dword1: */<br>
+ uint32_t src3 : 8;<br>
+ uint32_t src3_im : 1;<br>
+ uint32_t dst_ssbo : 8;<br>
+ uint32_t pad2 : 3; // type<br>
+ uint32_t pad3 : 2;<br>
+ uint32_t pad4 : 10; // opc/jmp_tgt/sync/opc_cat<br>
+} instr_cat6stgb_t;<br>
<br>
typedef union PACKED {<br>
instr_cat6a_t a;<br>
instr_cat6b_t b;<br>
instr_cat6c_t c;<br>
instr_cat6d_t d;<br>
+ instr_cat6ldgb_t ldgb;<br>
+ instr_cat6stgb_t stgb;<br>
struct PACKED {<br>
/* dword0: */<br>
uint32_t src_off : 1;<br>
@@ -733,4 +778,24 @@ static inline bool is_madsh(opc_t opc)<br>
}<br>
}<br>
<br></blockquote><div>Hi Rob,<br><br>I suggest to put function name on a new line..<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+static inline bool is_atomic(opc_t opc)<br>
+{<br>
+ switch (opc) {<br>
+ case OPC_ATOMIC_ADD:<br>
+ case OPC_ATOMIC_SUB:<br>
+ case OPC_ATOMIC_XCHG:<br>
+ case OPC_ATOMIC_INC:<br>
+ case OPC_ATOMIC_DEC:<br>
+ case OPC_ATOMIC_CMPXCHG:<br>
+ case OPC_ATOMIC_MIN:<br>
+ case OPC_ATOMIC_MAX:<br>
+ case OPC_ATOMIC_AND:<br>
+ case OPC_ATOMIC_OR:<br>
+ case OPC_ATOMIC_XOR:<br>
+ return true;<br>
+ default:<br>
+ return false;<br>
+ }<br>
+}<br>
+<br>
#endif /* INSTR_A3XX_H_ */<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/ir3.h b/src/gallium/drivers/<wbr>freedreno/ir3/ir3.h<br>
index bbe903d..8d75ec1 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/ir3.h<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/ir3.h<br>
@@ -621,7 +621,7 @@ static inline bool is_load(struct ir3_instruction *instr)<br>
case OPC_LDP:<br>
case OPC_L2G:<br>
case OPC_LDLW:<br>
- case OPC_LDC_4:<br>
+ case OPC_LDC:<br>
case OPC_LDLV:<br>
/* probably some others too.. */<br>
return true;<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
index 336fa95..d0083d8 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_nir.c<br>
@@ -114,7 +114,6 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,<br>
if (key) {<br>
switch (shader->type) {<br>
case SHADER_FRAGMENT:<br>
- case SHADER_COMPUTE:<br>
tex_options.saturate_s = key->fsaturate_s;<br>
tex_options.saturate_t = key->fsaturate_t;<br>
tex_options.saturate_r = key->fsaturate_r;<br>
@@ -124,6 +123,9 @@ ir3_optimize_nir(struct ir3_shader *shader, nir_shader *s,<br>
tex_options.saturate_t = key->vsaturate_t;<br>
tex_options.saturate_r = key->vsaturate_r;<br>
break;<br>
+ default:<br>
+ /* TODO */<br>
+ break;<br></blockquote><div>how about assert?<br></div><div>With or without these changes LGTM.<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
}<br>
<br>
diff --git a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_shader.c b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_shader.c<br>
index 1d54d53..9133317 100644<br>
--- a/src/gallium/drivers/<wbr>freedreno/ir3/ir3_shader.c<br>
+++ b/src/gallium/drivers/<wbr>freedreno/ir3/ir3_shader.c<br>
@@ -223,7 +223,6 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,<br>
*/<br>
switch (shader->type) {<br>
case SHADER_FRAGMENT:<br>
- case SHADER_COMPUTE:<br>
key.binning_pass = false;<br>
if (key.has_per_samp) {<br>
key.vsaturate_s = 0;<br>
@@ -243,6 +242,9 @@ ir3_shader_variant(struct ir3_shader *shader, struct ir3_shader_key key,<br>
key.fastc_srgb = 0;<br>
}<br>
break;<br>
+ default:<br>
+ /* TODO */<br>
+ break;<br>
}<br>
<br>
for (v = shader->variants; v; v = v->next)<br>
@@ -418,7 +420,8 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin)<br>
}<br>
debug_printf("\n");<br>
break;<br>
- case SHADER_COMPUTE:<br>
+ default:<br>
+ /* TODO */<br>
break;<br>
}<br>
<br>
@@ -462,7 +465,8 @@ ir3_shader_disasm(struct ir3_shader_variant *so, uint32_t *bin)<br>
if (so->frag_face)<br>
debug_printf("; fragface: hr0.x\n");<br>
break;<br>
- case SHADER_COMPUTE:<br>
+ default:<br>
+ /* TODO */<br>
break;<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.9.3<br>
<br>
</font></span></blockquote></div><br></div></div>