summaryrefslogtreecommitdiff
path: root/source/slang/slang-parameter-binding.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-08-08 17:23:03 -0400
committerGitHub <noreply@github.com>2019-08-08 17:23:03 -0400
commit41247c3942210df33b9e3dd733eafb23573a4f2f (patch)
treea49a88e680078bd379fe183cf826d49d7f935737 /source/slang/slang-parameter-binding.cpp
parentc1cc93dd962a6db6c839341f11d2654cf0e62e37 (diff)
WIP: Preliminary Slang -> C++ code generation (#1009)
* Expanded prelude for some other resource types. Disable C++ output for ParameterGroup. * WIP: Layout for CPU. * Fixes to CPU layout. * WIP: The uniform is output, but the variable definition is not. * WIP: Entry point parameters to global scope in C++. Handling of resource types (in so far as outputting) * Some discussion of ABI and different input types. * WIP: More C++ support around resource types. * WIP: Split up variables into different structures on emit. * WIP: Emitting C++ with wrapping up of 'Context' * WIP: C++ code has access to semantic values. Wrap in struct so can use method calls to pass shared state. Disable legalizeResourceTypes and legalizeExistentialTypeLayout * Fix structured buffer layout for CPU. * Remove testing/handling of global uniforms on CPU path. Typo fix. Changed CPU tests to use new CPU calling convention. * Check globals are working. Initalize context to zero globals. * Order the global parameters for C++ ouput by their layout. Note - that layout isn't quite working correctly because the StructuredBuffer<int> the int seems to be consuming uniform space. * Work around for reflection not having all data needed for layout ordering for C++ code. * Output constant buffers as pointers. * Entry point parameters accessed through pointer to struct. * WIP: Layout for CPU is reasonable for test case. * Only output 'f' after float literal if type marks as a float. * Cast construction works on C++. * Made IntrinsicOp::ConvertConstruct to make intent clearer. * C++ handling construction from scalar. Handle access of a scalar with .x. Check default initialization. * Comment about need for split of kIROp_construct. Release build works. * Added support from constructVectorFromScalar to C/C++ target. * Handling of in/out in C/C++. * First pass documentation CPU support. * Improvements to C++/C slang code generation documentation. * Small doc change to include need for mechansim to specify cpp compiler path. * Better handling of swizzling - allow swizzling a scalar into a vector.
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
-rw-r--r--source/slang/slang-parameter-binding.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index 722725af7..f9657e776 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -2632,6 +2632,21 @@ static int _calcTotalNumUsedRegistersForLayoutResourceKind(ParameterBindingConte
return numUsed;
}
+static bool _isCPUTarget(CodeGenTarget target)
+{
+ switch (target)
+ {
+ case CodeGenTarget::CPPSource:
+ case CodeGenTarget::CSource:
+ case CodeGenTarget::Executable:
+ case CodeGenTarget::SharedLibrary:
+ {
+ return true;
+ }
+ default: return false;
+ }
+}
+
/// Keep track of the running global counter for entry points and global parameters visited.
///
/// Because of explicit `register` and `[[vk::binding(...)]]` support, parameter binding
@@ -3022,16 +3037,22 @@ RefPtr<ProgramLayout> generateParameterBindings(
// want to do so through a different feature.
//
bool needDefaultConstantBuffer = false;
- for( auto& parameterInfo : sharedContext.parameters )
- {
- SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0);
- auto firstVarLayout = parameterInfo->varLayouts.getFirst();
- // Does the field have any uniform data?
- if( firstVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform) )
+ // On a CPU target, it's okay to have global scope parameters that use Uniform resources (because on CPU
+ // all resources are 'Uniform')
+ if (!_isCPUTarget(targetReq->target))
+ {
+ for( auto& parameterInfo : sharedContext.parameters )
{
- needDefaultConstantBuffer = true;
- diagnoseGlobalUniform(&sharedContext, firstVarLayout->varDecl);
+ SLANG_RELEASE_ASSERT(parameterInfo->varLayouts.getCount() != 0);
+ auto firstVarLayout = parameterInfo->varLayouts.getFirst();
+
+ // Does the field have any uniform data?
+ if( firstVarLayout->typeLayout->FindResourceInfo(LayoutResourceKind::Uniform) )
+ {
+ needDefaultConstantBuffer = true;
+ diagnoseGlobalUniform(&sharedContext, firstVarLayout->varDecl);
+ }
}
}