<p dir="ltr">Why wouldn't you have surfaces for other shader types? Surface == image. I was thinking they would just use a fixed offset from the suinfobase which I repurposed for buffers.</p>
<p dir="ltr">Either way, why do you need to touch this now?</p>
<div class="gmail_quote">On Feb 27, 2016 9:02 AM, "Samuel Pitoiset" <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To not overwrite buffers and surfaces on Kepler, we need a different<br>
offset. This will be currently only used for compute because we have<br>
to bind both surfaces and buffers.<br>
<br>
Signed-off-by: Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com">samuel.pitoiset@gmail.com</a>><br>
---<br>
.../drivers/nouveau/codegen/nv50_ir_driver.h | 1 +<br>
.../nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 80 ++++++++++++++++------<br>
.../nouveau/codegen/nv50_ir_lowering_nvc0.h | 12 +++-<br>
src/gallium/drivers/nouveau/nvc0/nvc0_program.c | 8 ++-<br>
4 files changed, 73 insertions(+), 28 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h<br>
index 4504240..479e426 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_driver.h<br>
@@ -179,6 +179,7 @@ struct nv50_ir_prog_info<br>
uint8_t resInfoCBSlot; /* cX[] used for tex handles, surface info */<br>
uint16_t texBindBase; /* base address for tex handles (nve4) */<br>
uint16_t suInfoBase; /* base address for surface info (nve4) */<br>
+ uint16_t bufInfoBase; /* base address for buffer info */<br>
uint16_t sampleInfoBase; /* base address for sample positions */<br>
uint8_t msInfoCBSlot; /* cX[] used for multisample info */<br>
uint16_t msInfoBase; /* base address for multisample info */<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
index d181f15..8abdd93 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp<br>
@@ -1026,7 +1026,7 @@ bool<br>
NVC0LoweringPass::handleSUQ(Instruction *suq)<br>
{<br>
suq->op = OP_MOV;<br>
- suq->setSrc(0, loadResLength32(suq->getIndirect(0, 1),<br>
+ suq->setSrc(0, loadBufLength32(suq->getIndirect(0, 1),<br>
suq->getSrc(0)->reg.fileIndex * 16));<br>
suq->setIndirect(0, 0, NULL);<br>
suq->setIndirect(0, 1, NULL);<br>
@@ -1142,7 +1142,7 @@ NVC0LoweringPass::handleATOM(Instruction *atom)<br>
return true;<br>
default:<br>
assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);<br>
- base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);<br>
+ base = loadBufInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);<br>
assert(base->reg.size == 8);<br>
if (ptr)<br>
base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);<br>
@@ -1202,19 +1202,19 @@ NVC0LoweringPass::handleCasExch(Instruction *cas, bool needCctl)<br>
}<br>
<br>
inline Value *<br>
-NVC0LoweringPass::loadResInfo32(Value *ptr, uint32_t off)<br>
+NVC0LoweringPass::loadResInfo32(Value *ptr, uint32_t off, uint16_t base)<br>
{<br>
uint8_t b = prog->driver->io.resInfoCBSlot;<br>
- off += prog->driver->io.suInfoBase;<br>
+ off += base;<br>
return bld.<br>
mkLoadv(TYPE_U32, bld.mkSymbol(FILE_MEMORY_CONST, b, TYPE_U32, off), ptr);<br>
}<br>
<br>
inline Value *<br>
-NVC0LoweringPass::loadResInfo64(Value *ptr, uint32_t off)<br>
+NVC0LoweringPass::loadResInfo64(Value *ptr, uint32_t off, uint16_t base)<br>
{<br>
uint8_t b = prog->driver->io.resInfoCBSlot;<br>
- off += prog->driver->io.suInfoBase;<br>
+ off += base;<br>
<br>
if (ptr)<br>
ptr = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getScratch(), ptr, bld.mkImm(4));<br>
@@ -1224,10 +1224,10 @@ NVC0LoweringPass::loadResInfo64(Value *ptr, uint32_t off)<br>
}<br>
<br>
inline Value *<br>
-NVC0LoweringPass::loadResLength32(Value *ptr, uint32_t off)<br>
+NVC0LoweringPass::loadResLength32(Value *ptr, uint32_t off, uint16_t base)<br>
{<br>
uint8_t b = prog->driver->io.resInfoCBSlot;<br>
- off += prog->driver->io.suInfoBase;<br>
+ off += base;<br>
<br>
if (ptr)<br>
ptr = bld.mkOp2v(OP_SHL, TYPE_U32, bld.getScratch(), ptr, bld.mkImm(4));<br>
@@ -1237,6 +1237,42 @@ NVC0LoweringPass::loadResLength32(Value *ptr, uint32_t off)<br>
}<br>
<br>
inline Value *<br>
+NVC0LoweringPass::loadSufInfo32(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResInfo32(ptr, off, prog->driver->io.suInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
+NVC0LoweringPass::loadSufInfo64(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResInfo64(ptr, off, prog->driver->io.suInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
+NVC0LoweringPass::loadSufLength32(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResLength32(ptr, off, prog->driver->io.suInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
+NVC0LoweringPass::loadBufInfo32(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResInfo32(ptr, off, prog->driver->io.bufInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
+NVC0LoweringPass::loadBufInfo64(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResInfo64(ptr, off, prog->driver->io.bufInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
+NVC0LoweringPass::loadBufLength32(Value *ptr, uint32_t off)<br>
+{<br>
+ return loadResLength32(ptr, off, prog->driver->io.bufInfoBase);<br>
+}<br>
+<br>
+inline Value *<br>
NVC0LoweringPass::loadMsInfo32(Value *ptr, uint32_t off)<br>
{<br>
uint8_t b = prog->driver->io.msInfoCBSlot;<br>
@@ -1316,8 +1352,8 @@ NVC0LoweringPass::adjustCoordinatesMS(TexInstruction *tex)<br>
<br>
Value *tx = bld.getSSA(), *ty = bld.getSSA(), *ts = bld.getSSA();<br>
<br>
- Value *ms_x = loadResInfo32(NULL, base + NVE4_SU_INFO_MS(0));<br>
- Value *ms_y = loadResInfo32(NULL, base + NVE4_SU_INFO_MS(1));<br>
+ Value *ms_x = loadSufInfo32(NULL, base + NVE4_SU_INFO_MS(0));<br>
+ Value *ms_y = loadSufInfo32(NULL, base + NVE4_SU_INFO_MS(1));<br>
<br>
bld.mkOp2(OP_SHL, TYPE_U32, tx, x, ms_x);<br>
bld.mkOp2(OP_SHL, TYPE_U32, ty, y, ms_y);<br>
@@ -1370,9 +1406,9 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
for (c = 0; c < arg; ++c) {<br>
src[c] = bld.getScratch();<br>
if (c == 0 && raw)<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_RAW_X);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_RAW_X);<br>
else<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_DIM(c));<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_DIM(c));<br>
bld.mkOp3(OP_SUCLAMP, TYPE_S32, src[c], su->getSrc(c), v, zero)<br>
->subOp = getSuClampSubOp(su, c);<br>
}<br>
@@ -1394,16 +1430,16 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
bld.mkOp2(OP_AND, TYPE_U32, off, src[0], bld.loadImm(NULL, 0xffff));<br>
} else<br>
if (dim == 3) {<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_UNK1C);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_UNK1C);<br>
bld.mkOp3(OP_MADSP, TYPE_U32, off, src[2], v, src[1])<br>
->subOp = NV50_IR_SUBOP_MADSP(4,2,8); // u16l u16l u16l<br>
<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_PITCH);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_PITCH);<br>
bld.mkOp3(OP_MADSP, TYPE_U32, off, off, v, src[0])<br>
->subOp = NV50_IR_SUBOP_MADSP(0,2,8); // u32 u16l u16l<br>
} else {<br>
assert(dim == 2);<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_PITCH);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_PITCH);<br>
bld.mkOp3(OP_MADSP, TYPE_U32, off, src[1], v, src[0])<br>
->subOp = su->tex.target.isArray() ?<br>
NV50_IR_SUBOP_MADSP_SD : NV50_IR_SUBOP_MADSP(4,2,8); // u16l u16l u16l<br>
@@ -1414,7 +1450,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
if (raw) {<br>
bf = src[0];<br>
} else {<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_FMT);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_FMT);<br>
bld.mkOp3(OP_VSHL, TYPE_U32, bf, src[0], v, zero)<br>
->subOp = NV50_IR_SUBOP_V1(7,6,8|2);<br>
}<br>
@@ -1431,7 +1467,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
case 2:<br>
z = off;<br>
if (!su->tex.target.isArray()) {<br>
- z = loadResInfo32(NULL, base + NVE4_SU_INFO_UNK1C);<br>
+ z = loadSufInfo32(NULL, base + NVE4_SU_INFO_UNK1C);<br>
subOp = NV50_IR_SUBOP_SUBFM_3D;<br>
}<br>
break;<br>
@@ -1446,7 +1482,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
}<br>
<br>
// part 2<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_ADDR);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_ADDR);<br>
<br>
if (su->tex.target == TEX_TARGET_BUFFER) {<br>
eau = v;<br>
@@ -1455,7 +1491,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
}<br>
// add array layer offset<br>
if (su->tex.target.isArray()) {<br>
- v = loadResInfo32(NULL, base + NVE4_SU_INFO_ARRAY);<br>
+ v = loadSufInfo32(NULL, base + NVE4_SU_INFO_ARRAY);<br>
if (dim == 1)<br>
bld.mkOp3(OP_MADSP, TYPE_U32, eau, src[1], v, eau)<br>
->subOp = NV50_IR_SUBOP_MADSP(4,0,0); // u16 u24 u32<br>
@@ -1495,7 +1531,7 @@ NVC0LoweringPass::processSurfaceCoordsNVE4(TexInstruction *su)<br>
<br>
// let's just set it 0 for raw access and hope it works<br>
v = raw ?<br>
- bld.mkImm(0) : loadResInfo32(NULL, base + NVE4_SU_INFO_FMT);<br>
+ bld.mkImm(0) : loadSufInfo32(NULL, base + NVE4_SU_INFO_FMT);<br>
<br>
// get rid of old coordinate sources, make space for fmt info and predicate<br>
su->moveSources(arg, 3 - arg);<br>
@@ -1966,12 +2002,12 @@ NVC0LoweringPass::visit(Instruction *i)<br>
i->op = OP_VFETCH;<br>
} else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {<br>
Value *ind = i->getIndirect(0, 1);<br>
- Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);<br>
+ Value *ptr = loadBufInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);<br>
// XXX come up with a way not to do this for EVERY little access but<br>
// rather to batch these up somehow. Unfortunately we've lost the<br>
// information about the field width by the time we get here.<br>
Value *offset = bld.loadImm(NULL, i->getSrc(0)->reg.data.offset + typeSizeof(i->sType));<br>
- Value *length = loadResLength32(ind, i->getSrc(0)->reg.fileIndex * 16);<br>
+ Value *length = loadBufLength32(ind, i->getSrc(0)->reg.fileIndex * 16);<br>
Value *pred = new_LValue(func, FILE_PREDICATE);<br>
if (i->src(0).isIndirect(0)) {<br>
bld.mkOp2(OP_ADD, TYPE_U64, ptr, ptr, i->getIndirect(0, 0));<br>
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h<br>
index 6eb8aff..3872f52 100644<br>
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h<br>
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.h<br>
@@ -117,9 +117,15 @@ private:<br>
<br>
void readTessCoord(LValue *dst, int c);<br>
<br>
- Value *loadResInfo32(Value *ptr, uint32_t off);<br>
- Value *loadResInfo64(Value *ptr, uint32_t off);<br>
- Value *loadResLength32(Value *ptr, uint32_t off);<br>
+ Value *loadResInfo32(Value *ptr, uint32_t off, uint16_t base);<br>
+ Value *loadResInfo64(Value *ptr, uint32_t off, uint16_t base);<br>
+ Value *loadResLength32(Value *ptr, uint32_t off, uint16_t base);<br>
+ Value *loadSufInfo32(Value *ptr, uint32_t off);<br>
+ Value *loadSufInfo64(Value *ptr, uint32_t off);<br>
+ Value *loadSufLength32(Value *ptr, uint32_t off);<br>
+ Value *loadBufInfo32(Value *ptr, uint32_t off);<br>
+ Value *loadBufInfo64(Value *ptr, uint32_t off);<br>
+ Value *loadBufLength32(Value *ptr, uint32_t off);<br>
Value *loadMsInfo32(Value *ptr, uint32_t off);<br>
Value *loadTexHandle(Value *ptr, unsigned int slot);<br>
<br>
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c<br>
index 89a7f5c..d01de73 100644<br>
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_program.c<br>
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_program.c<br>
@@ -544,22 +544,24 @@ nvc0_program_translate(struct nvc0_program *prog, uint16_t chipset,<br>
info->io.texBindBase = NVE4_CP_INPUT_TEX(0);<br>
info->io.suInfoBase = NVE4_CP_INPUT_SUF(0);<br>
info->prop.cp.gridInfoBase = NVE4_CP_INPUT_GRID_INFO(0);<br>
+ info->io.bufInfoBase = 0; /* TODO */<br>
} else {<br>
info->io.resInfoCBSlot = 15;<br>
- info->io.suInfoBase = NVC0_CB_AUX_BUF_INFO(0);<br>
+ info->io.bufInfoBase = NVC0_CB_AUX_BUF_INFO(0);<br>
+ info->io.suInfoBase = 0; /* TODO */<br>
}<br>
info->io.msInfoCBSlot = 0;<br>
info->io.msInfoBase = NVE4_CP_INPUT_MS_OFFSETS;<br>
} else {<br>
if (chipset >= NVISA_GK104_CHIPSET) {<br>
info->io.texBindBase = NVC0_CB_AUX_TEX_INFO(0);<br>
- info->io.suInfoBase = 0; /* TODO */<br>
}<br>
info->io.resInfoCBSlot = 15;<br>
info->io.sampleInfoBase = NVC0_CB_AUX_SAMPLE_INFO;<br>
- info->io.suInfoBase = NVC0_CB_AUX_BUF_INFO(0);<br>
+ info->io.bufInfoBase = NVC0_CB_AUX_BUF_INFO(0);<br>
info->io.msInfoCBSlot = 15;<br>
info->io.msInfoBase = 0; /* TODO */<br>
+ info->io.suInfoBase = 0; /* TODO */<br>
}<br>
<br>
info->assignSlots = nvc0_program_assign_varying_slots;<br>
--<br>
2.7.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>