GLSL/SPV: XFB: No streams on types, but support them on built-in blocks.

From internal Khronos discussions, work, and testing.
This commit is contained in:
John Kessenich 2018-12-13 12:06:12 -07:00
parent ba9f596eee
commit 236eb0d325
4 changed files with 12 additions and 10 deletions

View File

@ -3279,10 +3279,6 @@ void TGlslangToSpvTraverser::decorateStructType(const glslang::TType& type,
// Decorate the structure
builder.addDecoration(spvType, TranslateLayoutDecoration(type, qualifier.layoutMatrix));
builder.addDecoration(spvType, TranslateBlockDecoration(type, glslangIntermediate->usingStorageBuffer()));
if (type.getQualifier().hasStream() && glslangIntermediate->isMultiStream()) {
builder.addCapability(spv::CapabilityGeometryStreams);
builder.addDecoration(spvType, spv::DecorationStream, type.getQualifier().layoutStream);
}
}
// Turn the expression forming the array size into an id.

View File

@ -38,14 +38,12 @@ spv.150.geom
MemberName 68(toFragment) 0 "color"
Name 70 "toF"
Decorate 8(fromVertex) Block
Decorate 8(fromVertex) Stream 3
Decorate 10 Stream 3
Decorate 13(fromVertex) Block
MemberDecorate 27(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 27(gl_PerVertex) 1 BuiltIn PointSize
MemberDecorate 27(gl_PerVertex) 2 BuiltIn ClipDistance
Decorate 27(gl_PerVertex) Block
Decorate 27(gl_PerVertex) Stream 0
Decorate 29 Stream 0
MemberDecorate 30(gl_PerVertex) 0 BuiltIn Position
MemberDecorate 30(gl_PerVertex) 1 BuiltIn PointSize
@ -57,7 +55,6 @@ spv.150.geom
Decorate 51(gl_Layer) Stream 0
Decorate 51(gl_Layer) BuiltIn Layer
Decorate 68(toFragment) Block
Decorate 68(toFragment) Stream 3
Decorate 70(toF) Stream 3
2: TypeVoid
3: TypeFunction 2

View File

@ -36,7 +36,6 @@ spv.420.geom
Decorate 9(gl_PerVertex) Block
MemberDecorate 21(gl_PerVertex) 0 BuiltIn PointSize
Decorate 21(gl_PerVertex) Block
Decorate 21(gl_PerVertex) Stream 0
Decorate 23 Stream 0
Decorate 28(gl_ViewportIndex) Stream 0
Decorate 28(gl_ViewportIndex) BuiltIn ViewportIndex

14
glslang/MachineIndependent/ParseHelper.cpp Normal file → Executable file
View File

@ -4059,6 +4059,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
if (currentBlockQualifier.storage == EvqVaryingOut && globalOutputDefaults.hasXfbBuffer()) {
if (!currentBlockQualifier.hasXfbBuffer())
currentBlockQualifier.layoutXfbBuffer = globalOutputDefaults.layoutXfbBuffer;
if (!currentBlockQualifier.hasStream())
currentBlockQualifier.layoutStream = globalOutputDefaults.layoutStream;
fixXfbOffsets(currentBlockQualifier, newTypeList);
}
@ -4141,6 +4143,9 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
if (newType.getQualifier().hasXfbBuffer() &&
newType.getQualifier().layoutXfbBuffer != currentBlockQualifier.layoutXfbBuffer)
error(memberLoc, "member cannot contradict block (or what block inherited from global)", "xfb_buffer", "");
if (newType.getQualifier().hasStream() &&
newType.getQualifier().layoutStream != currentBlockQualifier.layoutStream)
error(memberLoc, "member cannot contradict block (or what block inherited from global)", "xfb_stream", "");
oldType.getQualifier().centroid = newType.getQualifier().centroid;
oldType.getQualifier().sample = newType.getQualifier().sample;
oldType.getQualifier().invariant = newType.getQualifier().invariant;
@ -4152,8 +4157,8 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
oldType.getQualifier().layoutXfbBuffer = newType.getQualifier().layoutXfbBuffer;
oldType.getQualifier().layoutXfbStride = newType.getQualifier().layoutXfbStride;
if (oldType.getQualifier().layoutXfbOffset != TQualifier::layoutXfbBufferEnd) {
// if any member as an xfb_offset, then the block's xfb_buffer inherents current xfb_buffer,
// and for xfb processing, the member needs it as well, along with xfb_stride
// If any member has an xfb_offset, then the block's xfb_buffer inherents current xfb_buffer,
// and for xfb processing, the member needs it as well, along with xfb_stride.
type.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer;
oldType.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer;
}
@ -4178,6 +4183,11 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
}
}
if (spvVersion.vulkan > 0) {
// ...then streams apply to built-in blocks, instead of them being only on stream 0
type.getQualifier().layoutStream = currentBlockQualifier.layoutStream;
}
if (numOriginalMembersFound < newTypeList.size())
error(loc, "block redeclaration has extra members", blockName.c_str(), "");
if (type.isArray() != (arraySizes != nullptr) ||