Skip to contentSkip to conversation

nouveau: codegen: Use FILE_MEMORY_BUFFER for buffers

PATCH In review Hans de Goede 4 participants 9 messages Mar 17, 2016 – Apr 20, 2016 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 nouveau: codegen: Use FILE_MEMORY_BUFFER for buffers

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

---
Changes in v2:
-New patch in v2 of patch-set to re-enable support for global opencl buffers

---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
 src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8 +++++---
 src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
 src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5 ++++-
 src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
 6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
    FILE_MEMORY_CONST,
    FILE_SHADER_INPUT,
    FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
    FILE_MEMORY_GLOBAL,
    FILE_MEMORY_SHARED,
    FILE_MEMORY_LOCAL,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
index baa2e30..7ae0cb2 100644
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
    case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
    case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
    case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
    case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
    case TGSI_FILE_SAMPLER:
    case TGSI_FILE_NULL:
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +5 -3
index d0936d8..628deb7 100644
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
       handleSharedATOM(atom);
       return true;
    default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
       base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
       assert(base->reg.size == 8);
       if (ptr)
          base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
       assert(base->reg.size == 8);
       atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
       return true;
    }
    base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
       } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
          assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
          i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
          Value *ind = i->getIndirect(0, 1);
          Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);
          // XXX come up with a way not to do this for EVERY little access but
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
          }
          i->setIndirect(0, 1, NULL);
          i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
          bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset, length);
          i->setPredicate(CC_NOT_P, pred);
          if (i->defExists(0)) {
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
       break;
    case OP_ATOM:
    {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
       handleATOM(i);
       handleCasExch(i, cctl);
    }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
index cfa85ec..870b36e 100644
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
    case FILE_MEMORY_CONST:  c = 'c'; break;
    case FILE_SHADER_INPUT:  c = 'a'; break;
    case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before lowering
    case FILE_MEMORY_GLOBAL: c = 'g'; break;
    case FILE_MEMORY_SHARED: c = 's'; break;
    case FILE_MEMORY_LOCAL:  c = 'l'; break;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +4 -1
index 2c4d7f5..2af1715 100644
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
    case FILE_MEMORY_CONST:  return 65536;
    case FILE_SHADER_INPUT:  return 0x200;
    case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
    case FILE_MEMORY_GLOBAL: return 0xffffffff;
    case FILE_MEMORY_SHARED: return 16 << 10;
    case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file, DataType ty) const
    if (ty == TYPE_B96 || ty == TYPE_NONE)
       return false;
    if (typeSizeof(ty) > 4)
-      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL);
+      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL) ||
+             (file == FILE_MEMORY_BUFFER);
    return true;
 }
 
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i) const
       switch (i->src(0).getFile()) {
       case FILE_MEMORY_LOCAL:
       case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
          return 100; // really 400 to 800
       default:
          return 22;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
index a03afa8..9e1e7bf 100644
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
    case FILE_MEMORY_CONST:  return 65536;
    case FILE_SHADER_INPUT:  return 0x400;
    case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
    case FILE_MEMORY_GLOBAL: return 0xffffffff;
    case FILE_MEMORY_SHARED: return 16 << 10;
    case FILE_MEMORY_LOCAL:  return 48 << 10;
Signature · 6 lines
2.7.3

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1458230823-25213-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH v2 2/2 nouveau: codegen: Add support for OpenCL global memory buffers

Add support for OpenCL global memory buffers, note this has only been tested with regular load and stores and likely needs more work for e.g. atomic ops.

---
Changes in v2:
-Redo on top of new "Use FILE_MEMORY_BUFFER for buffers" patch

---
 src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +10 -2
index 7ae0cb2..a7a1d54 100644
@@ -1286,7 +1286,9 @@ bool Source::scanInstruction(const struct tgsi_full_instruction *inst)
          if (dst.isIndirect(0))
             indirectTempArrays.insert(dst.getArrayId());
       } else
-      if (dst.getFile() == TGSI_FILE_BUFFER) {
+      if (dst.getFile() == TGSI_FILE_BUFFER ||
+          (dst.getFile() == TGSI_FILE_MEMORY &&
+           memoryFiles[dst.getIndex(0)].mem_type == TGSI_MEMORY_TYPE_GLOBAL)) {
          info->io.globalAccess |= 0x2;
       }
    }
@@ -1297,7 +1299,9 @@ bool Source::scanInstruction(const struct tgsi_full_instruction *inst)
          if (src.isIndirect(0))
             indirectTempArrays.insert(src.getArrayId());
       } else
-      if (src.getFile() == TGSI_FILE_BUFFER) {
+      if (src.getFile() == TGSI_FILE_BUFFER ||
+          (src.getFile() == TGSI_FILE_MEMORY &&
+           memoryFiles[src.getIndex(0)].mem_type == TGSI_MEMORY_TYPE_GLOBAL)) {
          info->io.globalAccess |= (insn.getOpcode() == TGSI_OPCODE_LOAD) ?
                0x1 : 0x2;
       } else
@@ -1531,6 +1535,10 @@ Converter::makeSym(uint tgsiFile, int fileIdx, int idx, int c, uint32_t address)
 
    if (tgsiFile == TGSI_FILE_MEMORY) {
       switch (code->memoryFiles[fileIdx].mem_type) {
+      case TGSI_MEMORY_TYPE_GLOBAL:
+         /* No-op this is the default for TGSI_FILE_MEMORY */
+         sym->setFile(FILE_MEMORY_GLOBAL);
+         break;
       case TGSI_MEMORY_TYPE_SHARED:
          sym->setFile(FILE_MEMORY_SHARED);
          break;
Signature · 6 lines
2.7.3

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#3 lore raw
In reply to a message not in the archive

Hi,

Quoted 11 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Quoted 8 lines

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Ping, any chance I can get a review of these 2 patches ?

Thanks,

Hans

Quoted 131 lines

---
Changes in v2:

(quoted diff) +0 -2
-New patch in v2 of patch-set to re-enable support for global opencl buffers
---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8 +++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5 ++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
index baa2e30..7ae0cb2 100644
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
     case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
     case TGSI_FILE_SAMPLER:
     case TGSI_FILE_NULL:
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +5 -3
index d0936d8..628deb7 100644
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little access but
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset, length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
index cfa85ec..870b36e 100644
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before lowering
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +4 -1
index 2c4d7f5..2af1715 100644
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file, DataType ty) const
     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)
-      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL);
+      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL) ||
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
 
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i) const
        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
index a03afa8..9e1e7bf 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 7 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#4 lore raw
In reply to a message not in the archive

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

One minor comment below.

Quoted 107 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

---
Changes in v2:

(quoted diff) +0 -2
-New patch in v2 of patch-set to re-enable support for global opencl buffers
---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8 +++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5 ++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
index baa2e30..7ae0cb2 100644
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
     case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
     case TGSI_FILE_SAMPLER:
     case TGSI_FILE_NULL:
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +5 -3
index d0936d8..628deb7 100644
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little access but
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset, length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
index cfa85ec..870b36e 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp int Symbol::print(char *buf, size_t size, · line 458

Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before lowering

Could you please show me the output of NV50_PROG_DEBUG=255 with a test which uses this file type? I'm not sure if using b[] is better than g[] actually.

Quoted 39 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +4 -1
index 2c4d7f5..2af1715 100644
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file, DataType ty) const
     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)
-      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL);
+      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL) ||
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
 
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i) const
        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
index a03afa8..9e1e7bf 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 7 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

#5 lore raw

Hi,

Quoted 2 lines · Samuel Pitoiset

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

I just checked:

lspci:
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)

Before this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

After this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Quoted 108 lines

One minor comment below.

Quoted 105 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

---
Changes in v2:

(quoted diff) +0 -2
-New patch in v2 of patch-set to re-enable support for global opencl buffers
---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8 +++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5 ++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,
src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
index baa2e30..7ae0cb2 100644
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
     case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
     case TGSI_FILE_SAMPLER:
     case TGSI_FILE_NULL:
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +5 -3
index d0936d8..628deb7 100644
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() == Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind, i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little access but
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset, length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -1
index cfa85ec..870b36e 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp
Quoted 8 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp int Symbol::print(char *buf, size_t size, · line 458

Quoted 6 lines

+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp

src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before lowering

Could you please show me the output of NV50_PROG_DEBUG=255 with a test which uses this file type? I'm not sure if using b[] is better than g[] actually.

NV50_PROG_DEBUG=255 bin/arb_shader_storage_buffer_object-rendering

...

MAIN:-1 ()
BB:0 (52 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r1 0x00000000 (0)
1: ld u32 %r0 b[0x0] (0)
2: presin f32 %r3 %r0 (0)
3: cos f32 %r3 %r3 (0)
4: mov u32 %r2 %r3 (0)
...

And after the first lowering step:

MAIN:-1 ()
BB:0 (77 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r56 0x00000000 (0)
1: ld u64 %r57d c15[0x300] (0)
2: mov u32 %r58 0x00000004 (0)
3: ld u32 %r59 c15[0x308] (0)
4: set u8 %p60 gt u32 %r58 %r59 (0)
5: mov u32 %r61 0x00000000 (0)
6: not %p60 ld u32 %r62 g[%r57d+0x0] (0)
...

Note how the 'b' printing is only used before the buffer access is lowered to a global access, so this seems to be the right thing todo.

Regards,

Hans

Quoted 39 lines
Quoted 39 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +4 -1
index 2c4d7f5..2af1715 100644
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file, DataType ty) const
     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)
-      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL);
+      return (file == FILE_MEMORY_LOCAL) || (file == FILE_MEMORY_GLOBAL) ||
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
 
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i) const
        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
index a03afa8..9e1e7bf 100644
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
Quoted 8 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 8 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 18 lines · Hans de Goede

Hi,

Quoted 2 lines · Samuel Pitoiset

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

I just checked:

lspci:
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)

Before this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Quoted 5 lines

After this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

And what about compute shaders? (ie. -t arb_compute_shader) Sorry to ask you again but I just want to be sure it's fine. :-)

Quoted 164 lines
Quoted 127 lines

One minor comment below.

Quoted 123 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /

---
Changes in v2:
-New patch in v2 of patch-set to re-enable support for global opencl buffers

---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8
+++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5
++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index baa2e30..7ae0cb2 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
     case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
     case TGSI_FILE_SAMPLER:
     case TGSI_FILE_NULL:

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 d0936d8..628deb7 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +3 -2
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() ==
 Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind,
i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little

access but

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -0
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset,
 length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -1
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
index cfa85ec..870b36e 100644
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
Quoted 8 lines
Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before

lowering

Could you please show me the output of NV50_PROG_DEBUG=255 with a test which uses this file type? I'm not sure if using b[] is better than g[] actually.

NV50_PROG_DEBUG=255 bin/arb_shader_storage_buffer_object-rendering

...

MAIN:-1 ()
BB:0 (52 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r1 0x00000000 (0)
1: ld u32 %r0 b[0x0] (0)
2: presin f32 %r3 %r0 (0)
3: cos f32 %r3 %r3 (0)
4: mov u32 %r2 %r3 (0)
...

And after the first lowering step:

MAIN:-1 ()
BB:0 (77 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r56 0x00000000 (0)
1: ld u64 %r57d c15[0x300] (0)
2: mov u32 %r58 0x00000004 (0)
3: ld u32 %r59 c15[0x308] (0)
4: set u8 %p60 gt u32 %r58 %r59 (0)
5: mov u32 %r61 0x00000000 (0)
6: not %p60 ld u32 %r62 g[%r57d+0x0] (0)
...

Quoted 3 lines

Note how the 'b' printing is only used before the buffer access is lowered to a global access, so this seems to be the right thing todo.

Fine by me.
Thanks.

Quoted 52 lines

Regards,

Hans

Quoted 47 lines
Quoted 47 lines
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp index 2c4d7f5..2af1715 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file,

DataType ty) const

     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)

- return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL);
+ return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL) ||

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i)

const

        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp index a03afa8..9e1e7bf 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
Quoted 8 lines
Quoted 8 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 8 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Hi,

Quoted 21 lines · Samuel Pitoiset
Quoted 18 lines · Hans de Goede

Hi,

Quoted 2 lines · Samuel Pitoiset

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

I just checked:

lspci:
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)

Before this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Quoted 8 lines
Quoted 5 lines

After this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

And what about compute shaders? (ie. -t arb_compute_shader) Sorry to ask you again but I just want to be sure it's fine. :-)

Those tests don't run yet on mesa master on the GF119 card I've:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_compute_shader.*' results/shader [20/20] skip: 20 |

My patches don't change anything about this, and they only touch the buffer handling paths and the buffer tests (still) pass...

I've also tried on a:
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 740] (rev a1)

Same result.

Regards,

Hans

Quoted 224 lines
Quoted 165 lines
Quoted 128 lines

One minor comment below.

Quoted 123 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /

---
Changes in v2:
-New patch in v2 of patch-set to re-enable support for global opencl buffers

---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8
+++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5
++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index baa2e30..7ae0cb2 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return nv50_ir::FILE_MEMORY_BUFFER;
     case TGSI_FILE_MEMORY:          return nv50_ir::FILE_MEMORY_GLOBAL;
     case TGSI_FILE_SAMPLER:
     case TGSI_FILE_NULL:

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 d0936d8..628deb7 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +3 -2
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex * 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() ==
 Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind,
i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little

access but

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -0
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset,
 length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -1
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
index cfa85ec..870b36e 100644
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
Quoted 8 lines
Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before

lowering

Could you please show me the output of NV50_PROG_DEBUG=255 with a test which uses this file type? I'm not sure if using b[] is better than g[] actually.

NV50_PROG_DEBUG=255 bin/arb_shader_storage_buffer_object-rendering

...

MAIN:-1 ()
BB:0 (52 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r1 0x00000000 (0)
1: ld u32 %r0 b[0x0] (0)
2: presin f32 %r3 %r0 (0)
3: cos f32 %r3 %r3 (0)
4: mov u32 %r2 %r3 (0)
...

And after the first lowering step:

MAIN:-1 ()
BB:0 (77 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r56 0x00000000 (0)
1: ld u64 %r57d c15[0x300] (0)
2: mov u32 %r58 0x00000004 (0)
3: ld u32 %r59 c15[0x308] (0)
4: set u8 %p60 gt u32 %r58 %r59 (0)
5: mov u32 %r61 0x00000000 (0)
6: not %p60 ld u32 %r62 g[%r57d+0x0] (0)
...

Quoted 3 lines

Note how the 'b' printing is only used before the buffer access is lowered to a global access, so this seems to be the right thing todo.

Fine by me.
Thanks.

Quoted 52 lines

Regards,

Hans

Quoted 47 lines
Quoted 47 lines
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp index 2c4d7f5..2af1715 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file,

DataType ty) const

     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)

- return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL);
+ return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL) ||

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i)

const

        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp index a03afa8..9e1e7bf 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 8 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

Reviewed-by
#10 lore raw
Quoted 40 lines · Hans de Goede

Hi,

Quoted 21 lines · Samuel Pitoiset
Quoted 18 lines · Hans de Goede

Hi,

Quoted 2 lines · Samuel Pitoiset

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

I just checked:

lspci:
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)

Before this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Quoted 8 lines
Quoted 5 lines

After this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

And what about compute shaders? (ie. -t arb_compute_shader) Sorry to ask you again but I just want to be sure it's fine. :-)

Those tests don't run yet on mesa master on the GF119 card I've:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_compute_shader.*' results/shader
[20/20] skip: 20 |

Quoted 8 lines

My patches don't change anything about this, and they only touch the buffer handling paths and the buffer tests (still) pass...

I've also tried on a:
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 740] (rev a1)

Same result.

Sorry for the delay, I was dealing with images.

Well, you needed to override ARB_compute_shader because the extension is not currently exposed.

For example:
MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader MESA_GL_VERSION_OVERRIDE=4.2 ./piglit-run.py blabla

I tried myself to test your series but it no longer applies on top of master. Well, if you make a quick test with:

MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader MESA_GL_VERSION_OVERRIDE=4.2 ./piglit-run.py -1 --dmesg -t arb_compute_shader

that might be nice, but whatever, series is:

Quoted 237 lines

Regards,

Hans

Quoted 230 lines
Quoted 171 lines
Quoted 134 lines

One minor comment below.

Quoted 129 lines · Hans de Goede

Some of the lowering steps we currently do for FILE_MEMORY_GLOBAL only apply to buffers, making it impossible to use FILE_MEMORY_GLOBAL for OpenCL global buffers.

This commits changes the buffer code to use FILE_MEMORY_BUFFER at the ir_from_tgsi and lowering steps, freeing use of FILE_MEMORY_GLOBAL for use with OpenCL global buffers.

Note that after lowering buffer accesses use the FILE_MEMORY_GLOBAL register file.

Tested with piglet on a gk107, before this patch:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /
after:
./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader
[9/9] pass: 9 /

---
Changes in v2:
-New patch in v2 of patch-set to re-enable support for global opencl buffers

---
  src/gallium/drivers/nouveau/codegen/nv50_ir.h                 | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp     | 2 +-
  src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 8
+++++---
  src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp         | 1 +
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp   | 5
++++-
  src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp   | 1 +
  6 files changed, 13 insertions(+), 5 deletions(-)
src/gallium/drivers/nouveau/codegen/nv50_ir.h +1 -0
index 7b0eb2f..5141fc6 100644
@@ -332,6 +332,7 @@ enum DataFile
     FILE_MEMORY_CONST,
     FILE_SHADER_INPUT,
     FILE_SHADER_OUTPUT,
+   FILE_MEMORY_BUFFER,
     FILE_MEMORY_GLOBAL,
     FILE_MEMORY_SHARED,
     FILE_MEMORY_LOCAL,

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp index baa2e30..7ae0cb2 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_from_tgsi.cpp +1 -1
@@ -373,7 +373,7 @@ static nv50_ir::DataFile translateFile(uint file)
     case TGSI_FILE_PREDICATE:       return nv50_ir::FILE_PREDICATE;
     case TGSI_FILE_IMMEDIATE:       return nv50_ir::FILE_IMMEDIATE;
     case TGSI_FILE_SYSTEM_VALUE:    return
 nv50_ir::FILE_SYSTEM_VALUE;
-   case TGSI_FILE_BUFFER:          return
 nv50_ir::FILE_MEMORY_GLOBAL;
+   case TGSI_FILE_BUFFER:          return
 nv50_ir::FILE_MEMORY_BUFFER;

case TGSI_FILE_MEMORY: return
nv50_ir::FILE_MEMORY_GLOBAL;
case TGSI_FILE_SAMPLER:
case TGSI_FILE_NULL:
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 d0936d8..628deb7 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +2 -1
@@ -1141,13 +1141,14 @@ NVC0LoweringPass::handleATOM(Instruction
 *atom)
        handleSharedATOM(atom);
        return true;
     default:
-      assert(atom->src(0).getFile() == FILE_MEMORY_GLOBAL);
+      assert(atom->src(0).getFile() == FILE_MEMORY_BUFFER);
        base = loadResInfo64(ind, atom->getSrc(0)->reg.fileIndex *
 16);
        assert(base->reg.size == 8);
        if (ptr)
           base = bld.mkOp2v(OP_ADD, TYPE_U64, base, base, ptr);
        assert(base->reg.size == 8);
        atom->setIndirect(0, 0, base);
+      atom->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
        return true;
     }
     base =
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -1
@@ -1963,7 +1964,7 @@ NVC0LoweringPass::visit(Instruction *i)
        } else if (i->src(0).getFile() == FILE_SHADER_OUTPUT) {
           assert(prog->getType() ==
 Program::TYPE_TESSELLATION_CONTROL);
           i->op = OP_VFETCH;
-      } else if (i->src(0).getFile() == FILE_MEMORY_GLOBAL) {
+      } else if (i->src(0).getFile() == FILE_MEMORY_BUFFER) {
           Value *ind = i->getIndirect(0, 1);
           Value *ptr = loadResInfo64(ind,
i->getSrc(0)->reg.fileIndex * 16);
           // XXX come up with a way not to do this for EVERY little

access but

src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -0
@@ -1978,6 +1979,7 @@ NVC0LoweringPass::visit(Instruction *i)
           }
           i->setIndirect(0, 1, NULL);
           i->setIndirect(0, 0, ptr);
+         i->getSrc(0)->reg.file = FILE_MEMORY_GLOBAL;
           bld.mkCmp(OP_SET, CC_GT, TYPE_U32, pred, TYPE_U32, offset,
 length);
           i->setPredicate(CC_NOT_P, pred);
           if (i->defExists(0)) {
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +1 -1
@@ -1987,7 +1989,7 @@ NVC0LoweringPass::visit(Instruction *i)
        break;
     case OP_ATOM:
     {
-      const bool cctl = i->src(0).getFile() == FILE_MEMORY_GLOBAL;
+      const bool cctl = i->src(0).getFile() == FILE_MEMORY_BUFFER;
        handleATOM(i);
        handleCasExch(i, cctl);
     }
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +0 -0
index cfa85ec..870b36e 100644
@@ -455,6 +455,7 @@ int Symbol::print(char *buf, size_t size,
     case FILE_MEMORY_CONST:  c = 'c'; break;
Quoted 8 lines
Quoted 4 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_print.cpp +1 -0
     case FILE_SHADER_INPUT:  c = 'a'; break;
     case FILE_SHADER_OUTPUT: c = 'o'; break;
+   case FILE_MEMORY_BUFFER: c = 'b'; break; // Only used before

lowering

Could you please show me the output of NV50_PROG_DEBUG=255 with a test which uses this file type? I'm not sure if using b[] is better than g[] actually.

NV50_PROG_DEBUG=255 bin/arb_shader_storage_buffer_object-rendering

...

MAIN:-1 ()
BB:0 (52 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r1 0x00000000 (0)
1: ld u32 %r0 b[0x0] (0)
2: presin f32 %r3 %r0 (0)
3: cos f32 %r3 %r3 (0)
4: mov u32 %r2 %r3 (0)
...

And after the first lowering step:

MAIN:-1 ()
BB:0 (77 instructions) - df = { }
-> BB:1 (tree)
0: mov u32 %r56 0x00000000 (0)
1: ld u64 %r57d c15[0x300] (0)
2: mov u32 %r58 0x00000004 (0)
3: ld u32 %r59 c15[0x308] (0)
4: set u8 %p60 gt u32 %r58 %r59 (0)
5: mov u32 %r61 0x00000000 (0)
6: not %p60 ld u32 %r62 g[%r57d+0x0] (0)
...

Quoted 3 lines

Note how the 'b' printing is only used before the buffer access is lowered to a global access, so this seems to be the right thing todo.

Fine by me.
Thanks.

Quoted 52 lines

Regards,

Hans

Quoted 47 lines
Quoted 47 lines
     case FILE_MEMORY_GLOBAL: c = 'g'; break;
     case FILE_MEMORY_SHARED: c = 's'; break;
     case FILE_MEMORY_LOCAL:  c = 'l'; break;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp index 2c4d7f5..2af1715 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
@@ -207,6 +207,7 @@ TargetNV50::getFileSize(DataFile file) const
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x200;
     case FILE_SHADER_OUTPUT: return 0x200;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;
@@ -406,7 +407,8 @@ TargetNV50::isAccessSupported(DataFile file,

DataType ty) const

     if (ty == TYPE_B96 || ty == TYPE_NONE)
        return false;
     if (typeSizeof(ty) > 4)

- return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL);
+ return (file == FILE_MEMORY_LOCAL) || (file ==
FILE_MEMORY_GLOBAL) ||

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp +1 -0
+             (file == FILE_MEMORY_BUFFER);
     return true;
  }
@@ -509,6 +511,7 @@ int TargetNV50::getLatency(const Instruction *i)

const

        switch (i->src(0).getFile()) {
        case FILE_MEMORY_LOCAL:
        case FILE_MEMORY_GLOBAL:
+      case FILE_MEMORY_BUFFER:
           return 100; // really 400 to 800
        default:
           return 22;

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp index a03afa8..9e1e7bf 100644

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +0 -0
@@ -248,6 +248,7 @@ TargetNVC0::getFileSize(DataFile file) const
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp TargetNVC0::getFileSize(DataFile file) const · line 254

Quoted 8 lines
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nvc0.cpp +1 -0
     case FILE_MEMORY_CONST:  return 65536;
     case FILE_SHADER_INPUT:  return 0x400;
     case FILE_SHADER_OUTPUT: return 0x400;
+   case FILE_MEMORY_BUFFER: return 0xffffffff;
     case FILE_MEMORY_GLOBAL: return 0xffffffff;
     case FILE_MEMORY_SHARED: return 16 << 10;
     case FILE_MEMORY_LOCAL:  return 48 << 10;

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#12 lore raw

Hi,

Quoted 56 lines · Samuel Pitoiset
Quoted 40 lines · Hans de Goede

Hi,

Quoted 21 lines · Samuel Pitoiset
Quoted 18 lines · Hans de Goede

Hi,

Quoted 2 lines · Samuel Pitoiset

Are you sure this won't break compute shaders on fermi? Could you please double-check that?

I just checked:

lspci:
01:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 610] (rev a1)

Before this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

Quoted 8 lines
Quoted 5 lines

After this patch-set:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_shader_storage_buffer_object.*' results/shader [9/9] pass: 9 /

And what about compute shaders? (ie. -t arb_compute_shader) Sorry to ask you again but I just want to be sure it's fine. :-)

Those tests don't run yet on mesa master on the GF119 card I've:

[hans@plank piglit]$ ./piglit run -o shader -t '.*arb_compute_shader.*' results/shader
[20/20] skip: 20 |

Quoted 8 lines

My patches don't change anything about this, and they only touch the buffer handling paths and the buffer tests (still) pass...

I've also tried on a:
01:00.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GT 740] (rev a1)

Same result.

Sorry for the delay, I was dealing with images.

Well, you needed to override ARB_compute_shader because the extension is not currently exposed.

Quoted 8 lines

For example:
MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader MESA_GL_VERSION_OVERRIDE=4.2 ./piglit-run.py blabla

I tried myself to test your series but it no longer applies on top of master. Well, if you make a quick test with:

MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader MESA_GL_VERSION_OVERRIDE=4.2 ./piglit-run.py -1 --dmesg -t arb_compute_shader

that might be nice

Done on both a gf119 and gk107, result on both:

[hans@plank piglit]$ DISPLAY=:0 MESA_EXTENSION_OVERRIDE=GL_ARB_compute_shader MESA_GL_VERSION_OVERRIDE=4.2 ./piglit run -o shader -t '.*arb_compute_shader.*' results/shader [20/20] skip: 4, pass: 16 |
Thank you for running Piglit!

Quoted 3 lines

but whatever, series is:

Thanks, I've updated the commit msg with the results of the extra tests I've done and pushed these 2 patches to master.

Regards,

Hans
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau