<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On 26 Jan. 2018 09:09, "Roland Scheidegger" <<a href="mailto:sroland@vmware.com">sroland@vmware.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="quoted-text">Am 25.01.2018 um 01:40 schrieb Dave Airlie:<br>
> From: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
><br>
> This uses a different shader than radeonsi, as we can't address non-256<br>
> aligned ssbos, which the radeonsi code does. This passes some extra<br>
> offsets into the shader.<br>
</div>Couldn't you just require the query buffers to have sufficient alignment<br>
in the first place, hence simplifying this? ssbo's need to have 256B<br>
alignment as well, as do UBOs.<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">The compute shader is used to write results at various dword locations inside the ssbo, so the buffer is aligned but one run of this shader needs to write results at non zero offsets into the buffer.</div><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">
Albeit I can't really see what GL would require, buffer object alignment<br>
is quite a mystery to me in general...<br>
<div class="quoted-text"><br>
><br>
> It also contains a set of u64 instruction implementation that may<br>
> or may not be complete (at least the u64div is definitely not something<br>
> that works outside this use-case). If r600 grows 64-bit integers,<br>
> it will use the GLSL lowering for divmod.<br>
><br>
> Signed-off-by: Dave Airlie <<a href="mailto:airlied@redhat.com">airlied@redhat.com</a>><br>
> ---<br>
<br>
<br>
<br>
</div>...<br>
<div class="elided-text">> +static int emit_u64add(struct r600_shader_ctx *ctx, int op,<br>
> +                    int treg,<br>
> +                    int src0_sel, int src0_chan,<br>
> +                    int src1_sel, int src1_chan)<br>
> +{<br>
> +     struct r600_bytecode_alu alu;<br>
> +     int r;<br>
> +     int opc;<br>
> +<br>
> +     if (op == ALU_OP2_ADD_INT)<br>
> +             opc = ALU_OP2_ADDC_UINT;<br>
> +     else<br>
> +             opc = ALU_OP2_SUBB_UINT;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;            ;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 0;<br>
> +     alu.dst.write = 1;<br>
> +     alu.src[0].sel = src0_sel;<br>
> +     alu.src[0].chan = src0_chan + 0;<br>
> +     alu.src[1].sel = src1_sel;<br>
> +     alu.src[1].chan = src1_chan + 0;<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 1;<br>
> +     alu.dst.write = 1;<br>
> +     alu.src[0].sel = src0_sel;<br>
> +     alu.src[0].chan = src0_chan + 1;<br>
> +     alu.src[1].sel = src1_sel;<br>
> +     alu.src[1].chan = src1_chan + 1;<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = opc;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 2;<br>
> +     alu.dst.write = 1;<br>
> +     alu.last = 1;<br>
> +     alu.src[0].sel = src0_sel;<br>
> +     alu.src[0].chan = src0_chan + 0;<br>
> +     alu.src[1].sel = src1_sel;<br>
> +     alu.src[1].chan = src1_chan + 0;<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 1;<br>
> +     alu.dst.write = 1;<br>
> +     alu.src[0].sel = treg;<br>
> +     alu.src[0].chan = 1;<br>
> +     alu.src[1].sel = treg;<br>
> +     alu.src[1].chan = 2;<br>
> +     alu.last = 1;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +     return 0;<br>
> +}<br>
> +<br>
> +static int egcm_u64add(struct r600_shader_ctx *ctx)<br>
</div>Couldn't you call into emit_u64add for performing the actual add?<br>
Or maybe it wouldn't really be simpler...<br>
<div class="elided-text"></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Unfortunately not, since it takes srcs from a tgsi inst, i could probably make it call in here later.</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="elided-text">
> +{<br>
> +     struct tgsi_full_instruction *inst = &ctx->parse.FullToken.<wbr>FullInstruction;<br>
> +     struct r600_bytecode_alu alu;<br>
> +     int r;<br>
> +     int treg = ctx->temp_reg;<br>
> +     int op = ALU_OP2_ADD_INT, opc = ALU_OP2_ADDC_UINT;<br>
> +<br>
> +     if (ctx->src[1].neg) {<br>
> +             op = ALU_OP2_SUB_INT;<br>
> +             opc = ALU_OP2_SUBB_UINT;<br>
> +     }<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;            ;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 0;<br>
> +     alu.dst.write = 1;<br>
> +     r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);<br>
> +     r600_bytecode_src(&alu.src[1], &ctx->src[1], 0);<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 1;<br>
> +     alu.dst.write = 1;<br>
> +     r600_bytecode_src(&alu.src[0], &ctx->src[0], 1);<br>
> +     r600_bytecode_src(&alu.src[1], &ctx->src[1], 1);<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = opc              ;<br>
> +     alu.dst.sel = treg;<br>
> +     alu.dst.chan = 2;<br>
> +     alu.dst.write = 1;<br>
> +     alu.last = 1;<br>
> +     r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);<br>
> +     r600_bytecode_src(&alu.src[1], &ctx->src[1], 0);<br>
> +     alu.src[1].neg = 0;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = op;<br>
> +     tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);<br>
> +     alu.src[0].sel = treg;<br>
> +     alu.src[0].chan = 1;<br>
> +     alu.src[1].sel = treg;<br>
> +     alu.src[1].chan = 2;<br>
> +     alu.last = 1;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +     memset(&alu, 0, sizeof(struct r600_bytecode_alu));<br>
> +     alu.op = ALU_OP1_MOV;<br>
> +     tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);<br>
> +     alu.src[0].sel = treg;<br>
> +     alu.src[0].chan = 0;<br>
> +     alu.last = 1;<br>
> +     r = r600_bytecode_add_alu(ctx->bc, &alu);<br>
> +     if (r)<br>
> +             return r;<br>
> +     return 0;<br>
> +}<br>
<br>
</div>But in any case, looks great to me (albeit I didn't check the math<br>
really - that udiv is complex...)<br></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Dave.</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">
<br>
For the series:<br>
Reviewed-by: Roland Scheidegger <<a href="mailto:sroland@vmware.com">sroland@vmware.com</a>><br>
</blockquote></div><br></div></div></div>