summaryrefslogtreecommitdiffstats
path: root/source/slang/parameter-binding.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-09 18:08:22 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-09 18:08:22 -0700
commit064c28f58e845be67a31283cb885b22f32118f49 (patch)
tree559cde481de3dc37ad0e571380367bb0a6ebc3ca /source/slang/parameter-binding.cpp
parent54364eb1aef3fc6aa87b144ba91ca0a77818e4a4 (diff)
Pick layout rules based on target languge, not source.
The tricky bit here was that the `reflection-json` output format isn't really a code generation target like the others, and we need to be able to have multiple "targets" active to make sense of it. This needs cleaning-up.
Diffstat (limited to 'source/slang/parameter-binding.cpp')
-rw-r--r--source/slang/parameter-binding.cpp40
1 files changed, 11 insertions, 29 deletions
diff --git a/source/slang/parameter-binding.cpp b/source/slang/parameter-binding.cpp
index 5811fd9fa..228af7d99 100644
--- a/source/slang/parameter-binding.cpp
+++ b/source/slang/parameter-binding.cpp
@@ -137,9 +137,6 @@ struct SharedParameterBindingContext
// The program layout we are trying to construct
RefPtr<ProgramLayout> programLayout;
- // The source language we are trying to use
- SourceLanguage sourceLanguage;
-
// Information on what ranges of "registers" have already
// been claimed, for each resource type
UsedRanges usedResourceRanges[kLayoutResourceKindCount];
@@ -160,6 +157,9 @@ struct ParameterBindingContext
// What stage (if any) are we compiling for?
Stage stage;
+
+ // The source language we are trying to use
+ SourceLanguage sourceLanguage;
};
struct LayoutSemanticInfo
@@ -398,7 +398,7 @@ getTypeLayoutForGlobalShaderParameter(
ParameterBindingContext* context,
VarDeclBase* varDecl)
{
- switch( context->shared->sourceLanguage )
+ switch( context->sourceLanguage )
{
case SourceLanguage::Slang:
case SourceLanguage::HLSL:
@@ -1167,6 +1167,7 @@ static void collectParameters(
for( auto& translationUnit : request->translationUnits )
{
context->stage = inferStageForTranslationUnit(translationUnit.Ptr());
+ context->sourceLanguage = translationUnit->sourceLanguage;
// First look at global-scope parameters
collectGlobalScopeParameters(context, translationUnit->SyntaxNode.Ptr());
@@ -1189,31 +1190,13 @@ static void collectParameters(
void generateParameterBindings(
CompileRequest* request)
{
- // TODO: infer a language or set of language rules to use based on the
- // source files and entry points given
- auto language = SourceLanguage::Unknown;
- for( auto& translationUnit : request->translationUnits )
- {
- auto translationUnitLanguage = translationUnit->sourceLanguage;
- if( language == SourceLanguage::Unknown )
- {
- language = translationUnitLanguage;
- }
- else if( language == translationUnitLanguage )
- {
- // same language: nothing to do...
- }
- else
- {
- // mismatch!
- // TODO(tfoley): emit a diagnostic
- }
- }
+ // Try to find rules based on the selected code-generation target
+ auto rules = GetLayoutRulesFamilyImpl(request->Target);
- // TODO(tfoley): We should really be picking layout rules
- // based on the *target* language, and not the source...
- auto rules = GetLayoutRulesFamilyImpl(language);
- assert(rules);
+ // If there was no target, or there are no rules for the target,
+ // then bail out here.
+ if (!rules)
+ return;
RefPtr<ProgramLayout> programLayout = new ProgramLayout;
@@ -1222,7 +1205,6 @@ void generateParameterBindings(
SharedParameterBindingContext sharedContext;
sharedContext.defaultLayoutRules = rules;
sharedContext.programLayout = programLayout;
- sharedContext.sourceLanguage = language;
// Create a sub-context to collect parameters that get
// declared into the global scope