diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-02-11 09:41:10 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-11 09:41:10 -0500 |
| commit | 1c969b9a85e2e6d6981a31bb758647fc61cf6482 (patch) | |
| tree | 1c5df51b207c43198f360d353108666ab234cc4b /source/slang/parameter-binding.cpp | |
| parent | 9f8a92e468a626abf82d08a730e009321595da07 (diff) | |
[[vk::shader_record]] (#836)
* * Replaced ShaderRecordNVLayoutModifier with ShaderRecordAttribute
* Allowed attributed [[vk::shader_record] and [[shader_record]]
* Checking there is at most 1 ShaderRecord active
* Small typo fixes
* Slightly improve diagnostic.
Replace expected file.
Diffstat (limited to 'source/slang/parameter-binding.cpp')
| -rw-r--r-- | source/slang/parameter-binding.cpp | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp index ba5a68341..826332b15 100644 --- a/source/slang/parameter-binding.cpp +++ b/source/slang/parameter-binding.cpp @@ -1109,13 +1109,14 @@ RefPtr<TypeLayout> getTypeLayoutForGlobalShaderParameter( auto layoutContext = context->layoutContext; auto rules = layoutContext.getRulesFamily(); - if( varDecl->HasModifier<ShaderRecordNVLayoutModifier>() && as<ConstantBufferType>(type) ) + if( varDecl->HasModifier<ShaderRecordAttribute>() && as<ConstantBufferType>(type) ) { return CreateTypeLayout( layoutContext.with(rules->getShaderRecordConstantBufferRules()), type); } + // We want to check for a constant-buffer type with a `push_constant` layout // qualifier before we move on to anything else. if (varDecl->HasModifier<PushConstantAttribute>() && as<ConstantBufferType>(type)) @@ -2741,6 +2742,21 @@ void diagnoseGlobalUniform( getSink(sharedContext)->diagnose(varDecl, Diagnostics::globalUniformsNotSupported, varDecl->getName()); } +static int _calcTotalNumUsedRegistersForParameterCategory(ParameterBindingContext* bindingContext, SlangParameterCategory paramCategory) +{ + int numUsed = 0; + for (auto& pair : bindingContext->shared->globalSpaceUsedRangeSets) + { + UsedRangeSet* rangeSet = pair.Value; + const auto& usedRanges = rangeSet->usedResourceRanges[paramCategory]; + for (const auto& usedRange : usedRanges.ranges) + { + numUsed += int(usedRange.end - usedRange.begin); + } + } + return numUsed; +} + void generateParameterBindings( TargetRequest* targetReq) { @@ -2890,7 +2906,7 @@ void generateParameterBindings( // in the global scope we will process the parameters // of each entry point in order. // - // Note: the effect of the current implemetnation is to + // Note: the effect of the current implementation is to // allocate non-overlapping registers/bindings between all // the entry points in the compile request (e.g., if you // have a vertex and fragment shader being compiled together, @@ -2944,6 +2960,16 @@ void generateParameterBindings( cbInfo->index = globalConstantBufferBinding.index; } programLayout->parametersLayout = globalScopeVarLayout; + + { + const int numShaderRecordRegs = _calcTotalNumUsedRegistersForParameterCategory(&context, SLANG_PARAMETER_CATEGORY_SHADER_RECORD); + if (numShaderRecordRegs > 1) + { + compileReq->mSink.diagnose(SourceLoc(), Diagnostics::tooManyShaderRecordConstantBuffers, numShaderRecordRegs); + return; + } + } + } RefPtr<ProgramLayout> specializeProgramLayout( |
