Skip to content

Commit

Permalink
Merge pull request #161 from tfoleyNV/gh-160
Browse files Browse the repository at this point in the history
Handle possibility of bad types in varying input/output signature.
  • Loading branch information
Tim Foley authored Aug 15, 2017
2 parents aeb247c + 3a2f191 commit 4a9b281
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
32 changes: 19 additions & 13 deletions source/slang/parameter-binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,15 +1253,18 @@ static RefPtr<TypeLayout> processEntryPointParameter(
state,
fieldVarLayout);

fieldVarLayout->typeLayout = fieldTypeLayout;

for (auto rr : fieldTypeLayout->resourceInfos)
if(fieldTypeLayout)
{
SLANG_RELEASE_ASSERT(rr.count != 0);
fieldVarLayout->typeLayout = fieldTypeLayout;

for (auto rr : fieldTypeLayout->resourceInfos)
{
SLANG_RELEASE_ASSERT(rr.count != 0);

auto structRes = structLayout->findOrAddResourceInfo(rr.kind);
fieldVarLayout->findOrAddResourceInfo(rr.kind)->index = structRes->count;
structRes->count += rr.count;
auto structRes = structLayout->findOrAddResourceInfo(rr.kind);
fieldVarLayout->findOrAddResourceInfo(rr.kind)->index = structRes->count;
structRes->count += rr.count;
}
}

structLayout->fields.Add(fieldVarLayout);
Expand Down Expand Up @@ -1404,13 +1407,16 @@ static void collectEntryPointParameters(
state,
resultLayout);

resultLayout->typeLayout = resultTypeLayout;

for (auto rr : resultTypeLayout->resourceInfos)
if( resultTypeLayout )
{
auto entryPointRes = entryPointLayout->findOrAddResourceInfo(rr.kind);
resultLayout->findOrAddResourceInfo(rr.kind)->index = entryPointRes->count;
entryPointRes->count += rr.count;
resultLayout->typeLayout = resultTypeLayout;

for (auto rr : resultTypeLayout->resourceInfos)
{
auto entryPointRes = entryPointLayout->findOrAddResourceInfo(rr.kind);
resultLayout->findOrAddResourceInfo(rr.kind)->index = entryPointRes->count;
entryPointRes->count += rr.count;
}
}

entryPointLayout->resultLayout = resultLayout;
Expand Down
13 changes: 13 additions & 0 deletions tests/rewriter/gh-160.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//TEST:COMPARE_HLSL: -no-checking -target dxbc-assembly -profile ps_4_0 -entry main

#ifdef __SLANG__
__import gh_160;
#endif

vec4 main(VS_OUT vOut) : SV_TARGET
{
float3 color = float3(1,0,0);

vec4 finalColor = vec4(color, 1.f);
return finalColor;
}
3 changes: 3 additions & 0 deletions tests/rewriter/gh-160.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//TEST_IGNORE_FILE:

// This file only exists so that `gh-160.hlsl` can import it.

0 comments on commit 4a9b281

Please sign in to comment.