-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for GLSL interface blocks #6351
Merged
Merged
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dfe7352
MaterialX Debugging
cheneym2 55806b7
Merge branch 'shader-slang:master' into cheneym2/materialx
cheneym2 9027c73
Update
cheneym2 1bbe430
Works without shadow optimization
cheneym2 2c8f4dd
Clean up
cheneym2 38af779
Update
cheneym2 0759a89
Update
cheneym2 5fb989a
Remove pixel.glsl
cheneym2 15a6b8a
Remove debug prints
cheneym2 d114316
Merge branch 'master' into cheneym2/materialx
cheneym2 7598fa3
Update slang-ir-glsl-legalize.cpp
cheneym2 51aaa51
Update slang-ir-glsl-legalize.cpp
cheneym2 61847f6
Merge branch 'master' into cheneym2/materialx
cheneym2 4f233fb
Update slang-ir-glsl-legalize.cpp
cheneym2 6647c54
Merge branch 'cheneym2/materialx' of https://github.com/cheneym2/slan…
cheneym2 45068f0
Merge branch 'master' into cheneym2/materialx
cheneym2 ea00eff
format code
slangbot c19c22b
Merge pull request #13 from slangbot/format-6351-cheneym2/materialx
cheneym2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,8 +83,25 @@ struct GlobalVarTranslationContext | |
auto key = builder.createStructKey(); | ||
inputKeys.add(key); | ||
builder.createStructField(inputStructType, key, inputType); | ||
IRTypeLayout::Builder fieldTypeLayout(&builder); | ||
IRVarLayout::Builder varLayoutBuilder(&builder, fieldTypeLayout.build()); | ||
|
||
IRTypeLayout::Builder fieldTypeLayoutBuilder(&builder); | ||
IRTypeLayout* fieldTypeLayout = nullptr; | ||
bool hasExistingLayout = false; | ||
if (auto existingLayoutDecoration = input->findDecoration<IRLayoutDecoration>()) | ||
{ | ||
if (auto existingVarLayout = as<IRVarLayout>(existingLayoutDecoration->getLayout())) | ||
{ | ||
fieldTypeLayout = existingVarLayout->getTypeLayout(); | ||
hasExistingLayout = true; | ||
} | ||
} | ||
|
||
if (!hasExistingLayout) | ||
{ | ||
fieldTypeLayout = fieldTypeLayoutBuilder.build(); | ||
} | ||
|
||
IRVarLayout::Builder varLayoutBuilder(&builder, fieldTypeLayout); | ||
varLayoutBuilder.setStage(entryPointDecor->getProfile().getStage()); | ||
if (auto semanticDecor = input->findDecoration<IRSemanticDecoration>()) | ||
{ | ||
|
@@ -94,9 +111,12 @@ struct GlobalVarTranslationContext | |
} | ||
else | ||
{ | ||
fieldTypeLayout.addResourceUsage( | ||
LayoutResourceKind::VaryingInput, | ||
LayoutSize(1)); | ||
if (!hasExistingLayout) | ||
{ | ||
fieldTypeLayoutBuilder.addResourceUsage( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The doubt I was having was about this call to addResourceUsage. I think it doesn't make sense if I'm pulling fieldTypeLayout from IRLayoutDecoration. |
||
LayoutResourceKind::VaryingInput, | ||
LayoutSize(1)); | ||
} | ||
if (auto layoutDecor = findVarLayout(input)) | ||
{ | ||
if (auto offsetAttr = | ||
|
@@ -137,6 +157,8 @@ struct GlobalVarTranslationContext | |
auto input = inputVars[i]; | ||
setInsertBeforeOrdinaryInst(&builder, firstBlock->getFirstOrdinaryInst()); | ||
auto inputType = cast<IRPtrTypeBase>(input->getDataType())->getValueType(); | ||
// TODO: This could be more efficient as a Load(FieldAddress(inputParam, i)) | ||
// operation instead of a FieldExtract(Load(inputParam)). | ||
builder.emitStore( | ||
input, | ||
builder | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//TEST:SIMPLE(filecheck=CHECK_GLSL): -target glsl -stage fragment -entry fragmentMain -allow-glsl | ||
|
||
//CHECK_GLSL: layout(location = 0) | ||
//CHECK_GLSL: out vec4 entryPointParam_fragmentMain_out1_0; | ||
|
||
//CHECK_GLSL: layout(location = 0) | ||
//CHECK_GLSL: in vec2 vd_texcoord_0_0; | ||
|
||
//CHECK_GLSL: layout(location = 1) | ||
//CHECK_GLSL: in vec2 vd_texcoord_1_0; | ||
|
||
//CHECK_GLSL: layout(location = 2) | ||
//CHECK_GLSL: in vec4 vd_inner_texcoord_2_0; | ||
|
||
import glsl; | ||
|
||
#version 400 | ||
|
||
struct innerData | ||
{ | ||
vec4 texcoord_2; | ||
}; | ||
|
||
in VertexData | ||
{ | ||
vec2 texcoord_0; | ||
vec2 texcoord_1; | ||
innerData inner; | ||
} vd; | ||
|
||
out vec4 out1; | ||
|
||
void fragmentMain() | ||
{ | ||
out1 = vec4(vd.texcoord_0, vd.texcoord_1.x, vd.inner.texcoord_2.y); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can also follow uses of any FieldAddr on the globalVar and remove the stores to those field addrs to get rid of the store to _S3 in the test case.