diff options
| author | Yong He <yonghe@outlook.com> | 2020-09-01 13:47:26 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-01 13:47:26 -0700 |
| commit | 5c56479c7b742f94ebf4a97d93826b2a5e4f279d (patch) | |
| tree | fdd348b67d09b7af5603532d4015036bee588062 /tools/render-test/cpu-compute-util.cpp | |
| parent | 69025ad82238a7402b18d9c566fac1574faef684 (diff) | |
Support dynamic existential shader parameters in render-test (#1525)
* Support dynamic existential shader parameters in render-test
* Fix linux build error.
* Fixes.
* Fix code review issues.
* Fix gcc error.
* More fixes.
* More fixes.
Diffstat (limited to 'tools/render-test/cpu-compute-util.cpp')
| -rw-r--r-- | tools/render-test/cpu-compute-util.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/render-test/cpu-compute-util.cpp b/tools/render-test/cpu-compute-util.cpp index 70536afe9..6e1fc12cf 100644 --- a/tools/render-test/cpu-compute-util.cpp +++ b/tools/render-test/cpu-compute-util.cpp @@ -359,6 +359,58 @@ static SlangResult _newTexture(const InputTextureDesc& desc, slang::TypeLayoutRe return false; } +SlangResult CPUComputeUtil::populateRTTIEntries( + ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, + ISlangSharedLibrary* sharedLib) +{ + Slang::ComPtr<slang::ISession> linkage; + spCompileRequest_getSession(compilationAndLayout.output.request, linkage.writeRef()); + auto& inputLayout = compilationAndLayout.layout; + for (auto& entry : inputLayout.entries) + { + for (auto& rtti : entry.rttiEntries) + { + void* ptrValue = nullptr; + switch (rtti.type) + { + case RTTIDataEntryType::RTTIObject: + ptrValue = sharedLib->findSymbolAddressByName(rtti.typeName.getBuffer()); + break; + case RTTIDataEntryType::WitnessTable: + { + auto reflection = slang::ShaderReflection::get(compilationAndLayout.output.request); + auto concreteType = reflection->findTypeByName(rtti.typeName.getBuffer()); + if (!concreteType) + return SLANG_FAIL; + auto interfaceType = reflection->findTypeByName(rtti.interfaceName.getBuffer()); + if (!interfaceType) + return SLANG_FAIL; + ISlangBlob* outName = nullptr; + linkage->getTypeConformanceWitnessMangledName(concreteType, interfaceType, &outName); + if (!outName) + return SLANG_FAIL; + ptrValue = sharedLib->findSymbolAddressByName((char*)outName->getBufferPointer()); + break; + } + default: + break; + } + if (rtti.offset >= 0 && rtti.offset + sizeof(ptrValue) <= entry.bufferData.getCount() * sizeof(decltype(entry.bufferData[0]))) + { + memcpy( + ((char*)entry.bufferData.getBuffer()) + rtti.offset, + &ptrValue, + sizeof(ptrValue)); + } + else + { + return SLANG_FAIL; + } + } + } + return SLANG_OK; +} + /* static */SlangResult CPUComputeUtil::calcBindings(const ShaderCompilerUtil::OutputAndLayout& compilationAndLayout, Context& outContext) { auto request = compilationAndLayout.output.request; |
