diff options
| author | Yong He <yonghe@outlook.com> | 2021-06-02 16:58:25 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-02 16:58:25 -0700 |
| commit | e67af5b1a3993529c702ff2924dea11fd1017d2e (patch) | |
| tree | c4359fb6df6110d81a658278aef9ab7244af5496 /source/slang/slang.cpp | |
| parent | 8e571669b3c8d4ac8236d0aed7a960bf88ad2bd1 (diff) | |
Various Fixes to gfx, reflection and emit. (#1867)
* Various Fixes to gfx, reflection and emit.
- Fix GLSL emit to properly output `*bitsTo*` functions for `IRBitCast` insts.
- Add line directive mode setting for `ISession`.
- Extend `TypeLayout::getElementStride` to handle `VectorType` case.
- Fix `IDevice::readBufferResource` 's D3D12 implementation to copy only the requested bytes out.
- Fix `render-test` to use the `ISession` from `gfx` instead of creating its own `ISession` to make sure `gfx` and `render-test` agree on WitnessTable and RTTI IDs.
- Extend `render-test` to support filling vector and matrix values in the new `set x = ...` TEST_INPUT syntax.
- Add a `dynamic-dispatch-15` test case to make sure packing / unpacking works correctly across all targets, and to make sure render-test's RTTI/WitnessTable ID filling logic is correct for non-trivial cases.
* Remove default-major test
* Fix cyclic reference in `ExtendedTypeLayout`.
* Move `lineDirectiveMode` setting to `TargetDesc`.
Add `structureSize` to `TargetDesc` and `SessionDesc` for future binary compatibility.
* Cleanup.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 613992354..9d2d766b9 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -445,9 +445,16 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Session::createSession( RefPtr<Linkage> linkage = new Linkage(this, astBuilder, getBuiltinLinkage()); Int targetCount = desc.targetCount; + const uint8_t* targetDescPtr = reinterpret_cast<const uint8_t*>(desc.targets); for(Int ii = 0; ii < targetCount; ++ii) { - linkage->addTarget(desc.targets[ii]); + slang::TargetDesc targetDesc; + // Copy the size field first. + memcpy(&targetDesc.structureSize, targetDescPtr, sizeof(size_t)); + // Copy the entire desc structure. + memcpy(&targetDesc, targetDescPtr, targetDesc.structureSize); + linkage->addTarget(targetDesc); + targetDescPtr += targetDesc.structureSize; } if(desc.flags & slang::kSessionFlag_FalcorCustomSharedKeywordSemantics) @@ -793,6 +800,7 @@ void Linkage::addTarget( target->setFloatingPointMode(FloatingPointMode(desc.floatingPointMode)); target->addTargetFlags(desc.flags); target->setTargetProfile(Profile(desc.profile)); + target->setLineDirectiveMode(LineDirectiveMode(desc.lineDirectiveMode)); } #if 0 @@ -1034,6 +1042,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL Linkage::createCompileRequest( SlangCompileRequest** outCompileRequest) { auto compileRequest = new EndToEndCompileRequest(this); + compileRequest->addRef(); *outCompileRequest = asExternal(compileRequest); return SLANG_OK; } @@ -1060,7 +1069,6 @@ SlangResult Linkage::setMatrixLayoutMode( return SLANG_OK; } - // // TargetRequest // @@ -2009,7 +2017,9 @@ BackEndCompileRequest::BackEndCompileRequest( : CompileRequestBase(linkage, sink) , m_program(program) , m_dumpIntermediatePrefix("slang-dump-") -{} + +{ +} EndToEndCompileRequest::EndToEndCompileRequest( Session* session) @@ -3840,8 +3850,16 @@ void EndToEndCompileRequest::setDumpIntermediatePrefix(const char* prefix) void EndToEndCompileRequest::setLineDirectiveMode(SlangLineDirectiveMode mode) { - // TODO: validation - getBackEndReq()->lineDirectiveMode = LineDirectiveMode(mode); + // This method is deprecated and user should call `setTargetLineDirectiveMode` instead. + // We provide the implementation here for backward compatibility. + // Targets added later will use `m_lineDirectiveMode`, so we update it to the new `mode` + // set by the user. + m_lineDirectiveMode = LineDirectiveMode(mode); + + // Change all existing targets to use the new mode. + auto linkage = getLinkage(); + for (auto& target : linkage->targets) + target->setLineDirectiveMode(m_lineDirectiveMode); } void EndToEndCompileRequest::setCommandLineCompilerMode() @@ -3854,11 +3872,14 @@ void EndToEndCompileRequest::setCodeGenTarget(SlangCompileTarget target) auto linkage = getLinkage(); linkage->targets.clear(); linkage->addTarget(CodeGenTarget(target)); + linkage->targets[0]->setLineDirectiveMode(m_lineDirectiveMode); } int EndToEndCompileRequest::addCodeGenTarget(SlangCompileTarget target) { - return (int)getLinkage()->addTarget(CodeGenTarget(target)); + int targetIndex = (int)getLinkage()->addTarget(CodeGenTarget(target)); + getLinkage()->targets[targetIndex]->setLineDirectiveMode(m_lineDirectiveMode); + return targetIndex; } void EndToEndCompileRequest::setTargetProfile(int targetIndex, SlangProfileID profile) @@ -3887,6 +3908,13 @@ void EndToEndCompileRequest::setTargetMatrixLayoutMode(int targetIndex, SlangMat setMatrixLayoutMode(mode); } +void EndToEndCompileRequest::setTargetLineDirectiveMode( + SlangInt targetIndex, + SlangLineDirectiveMode mode) +{ + getLinkage()->targets[targetIndex]->setLineDirectiveMode(LineDirectiveMode(mode)); +} + SlangResult EndToEndCompileRequest::addTargetCapability(SlangInt targetIndex, SlangCapabilityID capability) { auto& targets = getLinkage()->targets; |
