diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-14 16:23:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-14 16:23:19 -0700 |
| commit | 661d6198bbb9857d3fdc6df477e0742ed0b0765c (patch) | |
| tree | 974a57cfa2e43624e91502e9e652a0cc78105b3a /source/slang/slang-spirv-val.cpp | |
| parent | 0403e0556b470f6b316153caea2dc6f5c314da5b (diff) | |
Support per field matrix layout (#3101)
* Support per field matrix layout
* Fix warnings.
* Fix.
* Fix tests.
* Fix spiv gen.
* Fix.
* More test fixes.
* Fix.
* Run only GPU tests on self-hosted servers.
* Remove -use-glsl-matrix-layout-modifier.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-spirv-val.cpp')
| -rw-r--r-- | source/slang/slang-spirv-val.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/source/slang/slang-spirv-val.cpp b/source/slang/slang-spirv-val.cpp index 990ccd909..54bf5348b 100644 --- a/source/slang/slang-spirv-val.cpp +++ b/source/slang/slang-spirv-val.cpp @@ -3,6 +3,29 @@ namespace Slang { +SlangResult debugDisassembleSPIRV(const List<uint8_t>& spirv, String& outDis) +{ + CommandLine commandLine; + commandLine.m_executableLocation.setName("spirv-dis"); + RefPtr<Process> p; + const auto createResult = Process::create(commandLine, 0, p); + // If we failed to even start the process, then validation isn't available + SLANG_RETURN_ON_FAIL(createResult); + const auto in = p->getStream(StdStreamType::In); + const auto out = p->getStream(StdStreamType::Out); + // Write the assembly + SLANG_RETURN_ON_FAIL(in->write(spirv.getBuffer(), spirv.getCount())); + in->close(); + // Wait for it to finish + if (!p->waitForTermination(1000)) + return SLANG_FAIL; + + List<Byte> outData; + SLANG_RETURN_ON_FAIL(StreamUtil::readAll(out, 0, outData)); + outDis = String((const char*)outData.getBuffer()); + return SLANG_OK; +} + SlangResult debugValidateSPIRV(const List<uint8_t>& spirv) { // Set up our process @@ -25,6 +48,7 @@ SlangResult debugValidateSPIRV(const List<uint8_t>& spirv) if(!p->waitForTermination(1000)) return SLANG_FAIL; + // TODO: allow inheriting stderr in Process List<Byte> outData; SLANG_RETURN_ON_FAIL(StreamUtil::readAll(out, 0, outData)); @@ -32,8 +56,14 @@ SlangResult debugValidateSPIRV(const List<uint8_t>& spirv) outData.clear(); SLANG_RETURN_ON_FAIL(StreamUtil::readAll(err, 0, outData)); fwrite(outData.getBuffer(), outData.getCount(), 1, stderr); - const auto ret = p->getReturnValue(); + if (SLANG_FAILED(ret)) + { + String spirvDis; + debugDisassembleSPIRV(spirv, spirvDis); + fwrite(spirvDis.getBuffer(), spirvDis.getLength(), 1, stderr); + } + return ret == 0 ? SLANG_OK : SLANG_FAIL; } |
