diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-11-30 10:42:42 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-30 10:42:42 -0800 |
| commit | e40c106d6f8c4218de5a16450f201c0e395f8167 (patch) | |
| tree | 3f50413628102d9fe7936afca96ab063d7f9be56 /source | |
| parent | b51a582a0ed5943765c220152b1e15cda8c2a555 (diff) | |
Use register spaces by default for D3D12 targets (#734)
The change here is that the logical that used to be controlled by `-parameter-blocks-use-register-spaces` is now turned on unconditionally, meaning that a `ParameterBlock<X>` will get its own register `space` by default when targetting D3D Shader Model 5.1 and later.
I had originally made this feature optional because I wasn't sure whether Shader Model 5.1 should default to using register spaces or not, because D3D 11 doesn't support spaces at the API level and MSDN documetnation made it sound like SM5.1 was available for D3D11 as well. Subsequent reading has led me to understand that MSDN is wrong on this front, and SM5.1 and later are D3D12-only, so it is always safe to use spaces.
The new logic is now that we automatically use spaces for parameter blocks any time it is possible (SM5.1+ and any Vulkan target), and otherwise fall back to not using spaces (SM5.0 and earlier).
I updated a reflection test case that was covering parameter blocks to confirm the output differs between SM5.0 and 5.1.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/type-layout.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/type-layout.cpp b/source/slang/type-layout.cpp index 7fc6320cc..41476a7e5 100644 --- a/source/slang/type-layout.cpp +++ b/source/slang/type-layout.cpp @@ -868,6 +868,22 @@ static bool isSM5OrEarlier(TargetRequest* targetReq) return false; } +static bool isSM5_1OrLater(TargetRequest* targetReq) +{ + if(!isD3DTarget(targetReq)) + return false; + + auto profile = targetReq->targetProfile; + + if(profile.getFamily() == ProfileFamily::DX) + { + if(profile.GetVersion() >= ProfileVersion::DX_5_1) + return true; + } + + return false; +} + static bool isVulkanTarget(TargetRequest* targetReq) { switch( targetReq->target ) @@ -907,10 +923,9 @@ static bool shouldAllocateRegisterSpaceForParameterBlock( // are generating code for D3D12, and using SM5.1 or later. // We will use a register space for parameter blocks *if* // the target options tell us to: - if( isD3D12Target(targetReq) ) + if( isD3D12Target(targetReq) && isSM5_1OrLater(targetReq) ) { - if(targetReq->targetFlags & SLANG_TARGET_FLAG_PARAMETER_BLOCKS_USE_REGISTER_SPACES) - return true; + return true; } return false; |
