[Mesa-dev] [PATCH v2 18/24] nvc0/ir: add indirect support for images on Kepler

Samuel Pitoiset samuel.pitoiset at gmail.com
Tue Apr 26 16:09:56 UTC 2016



On 04/26/2016 03:22 AM, Ilia Mirkin wrote:
> On Mon, Apr 25, 2016 at 4:15 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.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>> ---
>>  .../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 1f26a03..d2bd970 100644
>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp
>> @@ -1576,9 +1576,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) {
>> +      // FIXME: out of bounds
>> +      ind = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
>> +                       tex->getIndirectR(), bld.mkImm(6));
>
> Probably not the only place, but I guess you're kind of assuming that
> r == 0 here? I think in practice it will be, but nothing guarantees
> it. Either fix it up, or add an assert?

Yeah, this was my guess, but adding an assert is more secure.

>
> Also, why are you setting r to 0xff here?

No ideas, I thought that setting r to 0xff was needed but after a second 
look at the code, it's just useless. I have removed it.

>
>> +      tex->tex.r = 0xff;
>> +   }
>> +
>> +   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);
>> @@ -1617,6 +1625,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);
>> @@ -1627,6 +1636,13 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)
>>
>>     adjustCoordinatesMS(su);
>>
>> +   if (su->tex.rIndirectSrc >= 0) {
>> +      // FIXME: out of bounds
>> +      ind = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getSSA(),
>> +                       su->getIndirectR(), bld.mkImm(6));
>> +      su->tex.r = 0xff;
>> +   }
>> +
>>     // calculate clamped coordinates
>>     for (c = 0; c < arg; ++c) {
>>        int dimc = c;
>> @@ -1638,9 +1654,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);
>>     }
>> @@ -1662,16 +1678,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
>> @@ -1682,7 +1698,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);
>>        }
>> @@ -1699,7 +1715,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;
>> @@ -1714,7 +1730,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;
>> @@ -1723,7 +1739,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
>> @@ -1763,7 +1779,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

-- 
-Samuel


More information about the mesa-dev mailing list