[Mesa-dev] [PATCH v3 18/24] nvc0/ir: add indirect support for images on Kepler
Ilia Mirkin
imirkin at alum.mit.edu
Tue Apr 26 16:56:29 UTC 2016
Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
On Tue, Apr 26, 2016 at 12:53 PM, Samuel Pitoiset
<samuel.pitoiset at gmail.com> wrote:
> This fixes arb_shader_image_load_store-indexing and
> arb_shader_image_load_store-max-images.
>
> v2: - do not set r to 0xff that's just useless
> - use an assert to make sure tex.r == 0
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu> (v1)
> ---
> .../nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 40 +++++++++++++++-------
> 1 file changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
> index 6a3c7e9..0408ad8 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
> @@ -1575,9 +1575,17 @@ NVC0LoweringPass::adjustCoordinatesMS(TexInstruction *tex)
> Value *s = tex->getSrc(arg - 1);
>
> Value *tx = bld.getSSA(), *ty = bld.getSSA(), *ts = bld.getSSA();
> + Value *ind = NULL;
>
> - Value *ms_x = loadSuInfo32(NULL, base + NVE4_SU_INFO_MS(0));
> - Value *ms_y = loadSuInfo32(NULL, base + NVE4_SU_INFO_MS(1));
> + if (tex->tex.rIndirectSrc >= 0) {
> + assert(tex->tex.r == 0);
> + // FIXME: out of bounds
> + ind = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
> + tex->getIndirectR(), bld.mkImm(6));
> + }
> +
> + Value *ms_x = loadSuInfo32(ind, base + NVE4_SU_INFO_MS(0));
> + Value *ms_y = loadSuInfo32(ind, base + NVE4_SU_INFO_MS(1));
>
> bld.mkOp2(OP_SHL, TYPE_U32, tx, x, ms_x);
> bld.mkOp2(OP_SHL, TYPE_U32, ty, y, ms_y);
> @@ -1616,6 +1624,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> Value *src[3];
> Value *bf, *eau, *off;
> Value *addr, *pred;
> + Value *ind = NULL;
>
> off = bld.getScratch(4);
> bf = bld.getScratch(4);
> @@ -1626,6 +1635,13 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
>
> adjustCoordinatesMS(su);
>
> + if (su->tex.rIndirectSrc >= 0) {
> + // FIXME: out of bounds
> + assert(su->tex.r == 0);
> + ind = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
> + su->getIndirectR(), bld.mkImm(6));
> + }
> +
> // calculate clamped coordinates
> for (c = 0; c < arg; ++c) {
> int dimc = c;
> @@ -1637,9 +1653,9 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
>
> src[c] = bld.getScratch();
> if (c == 0 && raw)
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_RAW_X);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_RAW_X);
> else
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_DIM(dimc));
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_DIM(dimc));
> bld.mkOp3(OP_SUCLAMP, TYPE_S32, src[c], su->getSrc(c), v, zero)
> ->subOp = getSuClampSubOp(su, dimc);
> }
> @@ -1661,16 +1677,16 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> bld.mkOp2(OP_AND, TYPE_U32, off, src[0], bld.loadImm(NULL, 0xffff));
> } else
> if (dim == 3) {
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_UNK1C);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_UNK1C);
> bld.mkOp3(OP_MADSP, TYPE_U32, off, src[2], v, src[1])
> ->subOp = NV50_IR_SUBOP_MADSP(4,2,8); // u16l u16l u16l
>
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_PITCH);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_PITCH);
> bld.mkOp3(OP_MADSP, TYPE_U32, off, off, v, src[0])
> ->subOp = NV50_IR_SUBOP_MADSP(0,2,8); // u32 u16l u16l
> } else {
> assert(dim == 2);
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_PITCH);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_PITCH);
> bld.mkOp3(OP_MADSP, TYPE_U32, off, src[1], v, src[0])
> ->subOp = (su->tex.target.isArray() || su->tex.target.isCube()) ?
> NV50_IR_SUBOP_MADSP_SD : NV50_IR_SUBOP_MADSP(4,2,8); // u16l u16l u16l
> @@ -1681,7 +1697,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> if (raw) {
> bf = src[0];
> } else {
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_FMT);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_FMT);
> bld.mkOp3(OP_VSHL, TYPE_U32, bf, src[0], v, zero)
> ->subOp = NV50_IR_SUBOP_V1(7,6,8|2);
> }
> @@ -1698,7 +1714,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> case 2:
> z = off;
> if (!su->tex.target.isArray() && !su->tex.target.isCube()) {
> - z = loadSuInfo32(NULL, base + NVE4_SU_INFO_UNK1C);
> + z = loadSuInfo32(ind, base + NVE4_SU_INFO_UNK1C);
> subOp = NV50_IR_SUBOP_SUBFM_3D;
> }
> break;
> @@ -1713,7 +1729,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> }
>
> // part 2
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_ADDR);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_ADDR);
>
> if (su->tex.target == TEX_TARGET_BUFFER) {
> eau = v;
> @@ -1722,7 +1738,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
> }
> // add array layer offset
> if (su->tex.target.isArray() || su->tex.target.isCube()) {
> - v = loadSuInfo32(NULL, base + NVE4_SU_INFO_ARRAY);
> + v = loadSuInfo32(ind, base + NVE4_SU_INFO_ARRAY);
> if (dim == 1)
> bld.mkOp3(OP_MADSP, TYPE_U32, eau, src[1], v, eau)
> ->subOp = NV50_IR_SUBOP_MADSP(4,0,0); // u16 u24 u32
> @@ -1762,7 +1778,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
>
> // let's just set it 0 for raw access and hope it works
> v = raw ?
> - bld.mkImm(0) : loadSuInfo32(NULL, base + NVE4_SU_INFO_FMT);
> + bld.mkImm(0) : loadSuInfo32(ind, base + NVE4_SU_INFO_FMT);
>
> // get rid of old coordinate sources, make space for fmt info and predicate
> su->moveSources(arg, 3 - arg);
> --
> 2.8.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list