Commit 9eada4b9 by Chao Chen

Add-support-for-SPV_NV_fragment_shader_barycentric

parent 6dd4757f
...@@ -33,7 +33,7 @@ enum Op; ...@@ -33,7 +33,7 @@ enum Op;
enum Capability; enum Capability;
static const int GLSLextNVVersion = 100; static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 5; static const int GLSLextNVRevision = 6;
//SPV_NV_sample_mask_override_coverage //SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage"; const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
...@@ -54,4 +54,7 @@ const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_p ...@@ -54,4 +54,7 @@ const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_p
//SPV_NV_shader_subgroup_partitioned //SPV_NV_shader_subgroup_partitioned
const char* const E_SPV_NV_shader_subgroup_partitioned = "SPV_NV_shader_subgroup_partitioned"; const char* const E_SPV_NV_shader_subgroup_partitioned = "SPV_NV_shader_subgroup_partitioned";
//SPV_NV_fragment_shader_barycentric
const char* const E_SPV_NV_fragment_shader_barycentric = "SPV_NV_fragment_shader_barycentric";
#endif // #ifndef GLSLextNV_H #endif // #ifndef GLSLextNV_H
\ No newline at end of file
...@@ -827,6 +827,14 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI ...@@ -827,6 +827,14 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addExtension(spv::E_SPV_EXT_fragment_fully_covered); builder.addExtension(spv::E_SPV_EXT_fragment_fully_covered);
builder.addCapability(spv::CapabilityFragmentFullyCoveredEXT); builder.addCapability(spv::CapabilityFragmentFullyCoveredEXT);
return spv::BuiltInFullyCoveredEXT; return spv::BuiltInFullyCoveredEXT;
case glslang::EbvBaryCoordNV:
builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
builder.addCapability(spv::CapabilityFragmentBarycentricNV);
return spv::BuiltInBaryCoordNV;
case glslang::EbvBaryCoordNoPerspNV:
builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
builder.addCapability(spv::CapabilityFragmentBarycentricNV);
return spv::BuiltInBaryCoordNoPerspNV;
#endif #endif
default: default:
return spv::BuiltInMax; return spv::BuiltInMax;
...@@ -6858,6 +6866,11 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol ...@@ -6858,6 +6866,11 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV); builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV);
builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough); builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough);
} }
if (symbol->getQualifier().pervertexNV) {
builder.addDecoration(id, spv::DecorationPerVertexNV);
builder.addCapability(spv::CapabilityFragmentBarycentricNV);
builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
}
#endif #endif
if (glslangIntermediate->getHlslFunctionality1() && symbol->getType().getQualifier().semanticName != nullptr) { if (glslangIntermediate->getHlslFunctionality1() && symbol->getType().getQualifier().semanticName != nullptr) {
......
...@@ -510,7 +510,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode, ...@@ -510,7 +510,8 @@ void SpirvStream::disassembleInstruction(Id resultId, Id /*typeId*/, Op opCode,
}else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 || }else if (strcmp(spv::E_SPV_NV_sample_mask_override_coverage, name) == 0 ||
strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 || strcmp(spv::E_SPV_NV_geometry_shader_passthrough, name) == 0 ||
strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 || strcmp(spv::E_SPV_NV_viewport_array2, name) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0) { strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0) {
extInstSet = GLSLextNVInst; extInstSet = GLSLextNVInst;
#endif #endif
} }
...@@ -691,7 +692,8 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) ...@@ -691,7 +692,8 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0 || strcmp(name, spv::E_SPV_NV_geometry_shader_passthrough) == 0 ||
strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 || strcmp(name, spv::E_ARB_shader_viewport_layer_array) == 0 ||
strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 || strcmp(name, spv::E_SPV_NV_viewport_array2) == 0 ||
strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0) { strcmp(spv::E_SPV_NVX_multiview_per_view_attributes, name) == 0 ||
strcmp(spv::E_SPV_NV_fragment_shader_barycentric, name) == 0) {
switch (entrypoint) { switch (entrypoint) {
case DecorationOverrideCoverageNV: return "OverrideCoverageNV"; case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
case DecorationPassthroughNV: return "PassthroughNV"; case DecorationPassthroughNV: return "PassthroughNV";
...@@ -706,6 +708,10 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint) ...@@ -706,6 +708,10 @@ static const char* GLSLextNVGetDebugNames(const char* name, unsigned entrypoint)
case BuiltInPositionPerViewNV: return "PositionPerViewNV"; case BuiltInPositionPerViewNV: return "PositionPerViewNV";
case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV"; case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case DecorationPerVertexNV: return "PerVertexNV";
case BuiltInBaryCoordNV: return "BaryCoordNV";
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
default: return "Bad"; default: return "Bad";
} }
} }
......
...@@ -254,6 +254,7 @@ const char* DecorationString(int decoration) ...@@ -254,6 +254,7 @@ const char* DecorationString(int decoration)
case DecorationPassthroughNV: return "PassthroughNV"; case DecorationPassthroughNV: return "PassthroughNV";
case DecorationViewportRelativeNV: return "ViewportRelativeNV"; case DecorationViewportRelativeNV: return "ViewportRelativeNV";
case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV"; case DecorationSecondaryViewportRelativeNV: return "SecondaryViewportRelativeNV";
case DecorationPerVertexNV: return "PerVertexNV";
#endif #endif
case DecorationNonUniformEXT: return "DecorationNonUniformEXT"; case DecorationNonUniformEXT: return "DecorationNonUniformEXT";
...@@ -338,6 +339,8 @@ const char* BuiltInString(int builtIn) ...@@ -338,6 +339,8 @@ const char* BuiltInString(int builtIn)
case 5258: return "SecondaryViewportMaskNV"; case 5258: return "SecondaryViewportMaskNV";
case 5261: return "PositionPerViewNV"; case 5261: return "PositionPerViewNV";
case 5262: return "ViewportMaskPerViewNV"; case 5262: return "ViewportMaskPerViewNV";
case BuiltInBaryCoordNV: return "BaryCoordNV";
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
#endif #endif
case 5264: return "FullyCoveredEXT"; case 5264: return "FullyCoveredEXT";
...@@ -826,6 +829,7 @@ const char* CapabilityString(int info) ...@@ -826,6 +829,7 @@ const char* CapabilityString(int info)
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV"; case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV"; case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV"; case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
#endif #endif
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT"; case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";
......
spv.fragmentShaderBarycentric.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 43
Capability Shader
Capability FragmentBarycentricNV
Extension "SPV_NV_fragment_shader_barycentric"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 11 21
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_NV_fragment_shader_barycentric"
Name 4 "main"
Name 8 "value"
Name 11 "gl_BaryCoordNV"
Name 17 "vertices"
MemberName 17(vertices) 0 "attrib"
Name 21 "v"
Decorate 8(value) Location 1
Decorate 11(gl_BaryCoordNV) BuiltIn BaryCoordNV
Decorate 17(vertices) Block
Decorate 21(v) Location 0
Decorate 21(v) PerVertexNV
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Output 6(float)
8(value): 7(ptr) Variable Output
9: TypeVector 6(float) 3
10: TypePointer Input 9(fvec3)
11(gl_BaryCoordNV): 10(ptr) Variable Input
12: TypeInt 32 0
13: 12(int) Constant 0
14: TypePointer Input 6(float)
17(vertices): TypeStruct 6(float)
18: 12(int) Constant 3
19: TypeArray 17(vertices) 18
20: TypePointer Input 19
21(v): 20(ptr) Variable Input
22: TypeInt 32 1
23: 22(int) Constant 0
27: 12(int) Constant 1
30: 22(int) Constant 1
35: 12(int) Constant 2
38: 22(int) Constant 2
4(main): 2 Function None 3
5: Label
15: 14(ptr) AccessChain 11(gl_BaryCoordNV) 13
16: 6(float) Load 15
24: 14(ptr) AccessChain 21(v) 23 23
25: 6(float) Load 24
26: 6(float) FMul 16 25
28: 14(ptr) AccessChain 11(gl_BaryCoordNV) 27
29: 6(float) Load 28
31: 14(ptr) AccessChain 21(v) 30 23
32: 6(float) Load 31
33: 6(float) FMul 29 32
34: 6(float) FAdd 26 33
36: 14(ptr) AccessChain 11(gl_BaryCoordNV) 35
37: 6(float) Load 36
39: 14(ptr) AccessChain 21(v) 38 23
40: 6(float) Load 39
41: 6(float) FMul 37 40
42: 6(float) FAdd 34 41
Store 8(value) 42
Return
FunctionEnd
spv.fragmentShaderBarycentric2.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 42
Capability Shader
Capability FragmentBarycentricNV
Extension "SPV_NV_fragment_shader_barycentric"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8 11 20
ExecutionMode 4 OriginUpperLeft
Source ESSL 320
SourceExtension "GL_NV_fragment_shader_barycentric"
Name 4 "main"
Name 8 "value"
Name 11 "gl_BaryCoordNoPerspNV"
Name 20 "vertexIDs"
Decorate 8(value) Location 1
Decorate 11(gl_BaryCoordNoPerspNV) BuiltIn BaryCoordNoPerspNV
Decorate 20(vertexIDs) Location 0
Decorate 20(vertexIDs) PerVertexNV
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypePointer Output 6(float)
8(value): 7(ptr) Variable Output
9: TypeVector 6(float) 3
10: TypePointer Input 9(fvec3)
11(gl_BaryCoordNoPerspNV): 10(ptr) Variable Input
12: TypeInt 32 0
13: 12(int) Constant 0
14: TypePointer Input 6(float)
17: 12(int) Constant 3
18: TypeArray 6(float) 17
19: TypePointer Input 18
20(vertexIDs): 19(ptr) Variable Input
21: TypeInt 32 1
22: 21(int) Constant 0
26: 12(int) Constant 1
29: 21(int) Constant 1
34: 12(int) Constant 2
37: 21(int) Constant 2
4(main): 2 Function None 3
5: Label
15: 14(ptr) AccessChain 11(gl_BaryCoordNoPerspNV) 13
16: 6(float) Load 15
23: 14(ptr) AccessChain 20(vertexIDs) 22
24: 6(float) Load 23
25: 6(float) FMul 16 24
27: 14(ptr) AccessChain 11(gl_BaryCoordNoPerspNV) 26
28: 6(float) Load 27
30: 14(ptr) AccessChain 20(vertexIDs) 29
31: 6(float) Load 30
32: 6(float) FMul 28 31
33: 6(float) FAdd 25 32
35: 14(ptr) AccessChain 11(gl_BaryCoordNoPerspNV) 34
36: 6(float) Load 35
38: 14(ptr) AccessChain 20(vertexIDs) 37
39: 6(float) Load 38
40: 6(float) FMul 36 39
41: 6(float) FAdd 33 40
Store 8(value) 41
Return
FunctionEnd
#version 450
#extension GL_NV_fragment_shader_barycentric : require
layout(location = 0) pervertexNV in vertices {
float attrib;
} v[];
layout(location = 1) out float value;
void main () {
value = (gl_BaryCoordNV.x * v[0].attrib +
gl_BaryCoordNV.y * v[1].attrib +
gl_BaryCoordNV.z * v[2].attrib);
}
#version 320 es
#extension GL_NV_fragment_shader_barycentric : require
precision highp float;
layout(location = 0) pervertexNV in float vertexIDs[3];
layout(location = 1) out float value;
void main () {
value = (gl_BaryCoordNoPerspNV.x * vertexIDs[0] +
gl_BaryCoordNoPerspNV.y * vertexIDs[1] +
gl_BaryCoordNoPerspNV.z * vertexIDs[2]);
}
...@@ -227,6 +227,8 @@ enum TBuiltInVariable { ...@@ -227,6 +227,8 @@ enum TBuiltInVariable {
EbvPositionPerViewNV, EbvPositionPerViewNV,
EbvViewportMaskPerViewNV, EbvViewportMaskPerViewNV,
EbvFragFullyCoveredNV, EbvFragFullyCoveredNV,
EbvBaryCoordNV,
EbvBaryCoordNoPerspNV,
#endif #endif
// HLSL built-ins that live only temporarily, until they get remapped // HLSL built-ins that live only temporarily, until they get remapped
...@@ -365,6 +367,8 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v) ...@@ -365,6 +367,8 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvPositionPerViewNV: return "PositionPerViewNV"; case EbvPositionPerViewNV: return "PositionPerViewNV";
case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV"; case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
case EbvBaryCoordNV: return "BaryCoordNV";
case EbvBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
#endif #endif
default: return "unknown built-in variable"; default: return "unknown built-in variable";
} }
......
...@@ -457,6 +457,9 @@ public: ...@@ -457,6 +457,9 @@ public:
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
explicitInterp = false; explicitInterp = false;
#endif #endif
#ifdef NV_EXTENSIONS
pervertexNV = false;
#endif
} }
void clearMemory() void clearMemory()
...@@ -501,6 +504,9 @@ public: ...@@ -501,6 +504,9 @@ public:
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
bool explicitInterp : 1; bool explicitInterp : 1;
#endif #endif
#ifdef NV_EXTENSIONS
bool pervertexNV : 1;
#endif
bool patch : 1; bool patch : 1;
bool sample : 1; bool sample : 1;
bool coherent : 1; bool coherent : 1;
...@@ -524,6 +530,7 @@ public: ...@@ -524,6 +530,7 @@ public:
{ {
return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || volatil || restrict || readonly || writeonly; return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || volatil || restrict || readonly || writeonly;
} }
bool isInterpolation() const bool isInterpolation() const
{ {
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
...@@ -532,15 +539,21 @@ public: ...@@ -532,15 +539,21 @@ public:
return flat || smooth || nopersp; return flat || smooth || nopersp;
#endif #endif
} }
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
bool isExplicitInterpolation() const bool isExplicitInterpolation() const
{ {
return explicitInterp; return explicitInterp;
} }
#endif #endif
bool isAuxiliary() const bool isAuxiliary() const
{ {
#ifdef NV_EXTENSIONS
return centroid || patch || sample || pervertexNV;
#else
return centroid || patch || sample; return centroid || patch || sample;
#endif
} }
bool isPipeInput() const bool isPipeInput() const
...@@ -656,6 +669,11 @@ public: ...@@ -656,6 +669,11 @@ public:
return ! patch && (isPipeInput() || isPipeOutput()); return ! patch && (isPipeInput() || isPipeOutput());
case EShLangTessEvaluation: case EShLangTessEvaluation:
return ! patch && isPipeInput(); return ! patch && isPipeInput();
#ifdef NV_EXTENSIONS
case EShLangFragment:
return pervertexNV && isPipeInput();
#endif
default: default:
return false; return false;
} }
...@@ -1721,6 +1739,10 @@ public: ...@@ -1721,6 +1739,10 @@ public:
if (qualifier.explicitInterp) if (qualifier.explicitInterp)
appendStr(" __explicitInterpAMD"); appendStr(" __explicitInterpAMD");
#endif #endif
#ifdef NV_EXTENSIONS
if (qualifier.pervertexNV)
appendStr(" pervertexNV");
#endif
if (qualifier.patch) if (qualifier.patch)
appendStr(" patch"); appendStr(" patch");
if (qualifier.sample) if (qualifier.sample)
......
...@@ -5734,6 +5734,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV ...@@ -5734,6 +5734,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangFragment].append( stageBuiltins[EShLangFragment].append(
"in bool gl_FragFullyCoveredNV;" "in bool gl_FragFullyCoveredNV;"
); );
if (version >= 450)
stageBuiltins[EShLangFragment].append(
"in vec3 gl_BaryCoordNV;"
"in vec3 gl_BaryCoordNoPerspNV;"
);
#endif #endif
} else { } else {
// ES profile // ES profile
...@@ -5775,6 +5780,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV ...@@ -5775,6 +5780,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangFragment].append( stageBuiltins[EShLangFragment].append(
"highp float gl_FragDepthEXT;" // GL_EXT_frag_depth "highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
); );
#ifdef NV_EXTENSIONS
if (version >= 320)
stageBuiltins[EShLangFragment].append(
"in vec3 gl_BaryCoordNV;"
"in vec3 gl_BaryCoordNoPerspNV;"
);
#endif
} }
stageBuiltins[EShLangFragment].append("\n"); stageBuiltins[EShLangFragment].append("\n");
...@@ -7904,6 +7916,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion ...@@ -7904,6 +7916,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation); symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation);
BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable); BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable);
} }
if ((profile != EEsProfile && version >= 450) ||
(profile == EEsProfile && version >= 320)) {
symbolTable.setVariableExtensions("gl_BaryCoordNV", 1, &E_GL_NV_fragment_shader_barycentric);
symbolTable.setVariableExtensions("gl_BaryCoordNoPerspNV", 1, &E_GL_NV_fragment_shader_barycentric);
BuiltInVariable("gl_BaryCoordNV", EbvBaryCoordNV, symbolTable);
BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
}
#endif #endif
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth); symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
......
...@@ -496,7 +496,12 @@ bool TParseContext::isIoResizeArray(const TType& type) const ...@@ -496,7 +496,12 @@ bool TParseContext::isIoResizeArray(const TType& type) const
{ {
return type.isArray() && return type.isArray() &&
((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) || ((language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn) ||
(language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut && ! type.getQualifier().patch)); (language == EShLangTessControl && type.getQualifier().storage == EvqVaryingOut && ! type.getQualifier().patch)
#ifdef NV_EXTENSIONS
||
(language == EShLangFragment && type.getQualifier().storage == EvqVaryingIn && type.getQualifier().pervertexNV)
#endif
);
} }
// If an array is not isIoResizeArray() but is an io array, make sure it has the right size // If an array is not isIoResizeArray() but is an io array, make sure it has the right size
...@@ -569,7 +574,12 @@ void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnl ...@@ -569,7 +574,12 @@ void TParseContext::checkIoArraysConsistency(const TSourceLoc& loc, bool tailOnl
const char* feature; const char* feature;
if (language == EShLangGeometry) if (language == EShLangGeometry)
feature = TQualifier::getGeometryString(intermediate.getInputPrimitive()); feature = TQualifier::getGeometryString(intermediate.getInputPrimitive());
else if (language == EShLangTessControl) else if (language == EShLangTessControl
#ifdef NV_EXTENSIONS
|| language == EShLangFragment
#endif
)
feature = "vertices"; feature = "vertices";
else else
feature = "unknown"; feature = "unknown";
...@@ -589,6 +599,11 @@ int TParseContext::getIoArrayImplicitSize() const ...@@ -589,6 +599,11 @@ int TParseContext::getIoArrayImplicitSize() const
return TQualifier::mapGeometryToSize(intermediate.getInputPrimitive()); return TQualifier::mapGeometryToSize(intermediate.getInputPrimitive());
else if (language == EShLangTessControl) else if (language == EShLangTessControl)
return intermediate.getVertices() != TQualifier::layoutNotSet ? intermediate.getVertices() : 0; return intermediate.getVertices() != TQualifier::layoutNotSet ? intermediate.getVertices() : 0;
#ifdef NV_EXTENSIONS
else if (language == EShLangFragment)
return 3; //Number of vertices for Fragment shader is always three.
#endif
else else
return 0; return 0;
} }
...@@ -602,6 +617,12 @@ void TParseContext::checkIoArrayConsistency(const TSourceLoc& loc, int requiredS ...@@ -602,6 +617,12 @@ void TParseContext::checkIoArrayConsistency(const TSourceLoc& loc, int requiredS
error(loc, "inconsistent input primitive for array size of", feature, name.c_str()); error(loc, "inconsistent input primitive for array size of", feature, name.c_str());
else if (language == EShLangTessControl) else if (language == EShLangTessControl)
error(loc, "inconsistent output number of vertices for array size of", feature, name.c_str()); error(loc, "inconsistent output number of vertices for array size of", feature, name.c_str());
#ifdef NV_EXTENSIONS
else if (language == EShLangFragment) {
if (type.getOuterArraySize() > requiredSize)
error(loc, " cannot be greater than 3 for pervertexNV", feature, name.c_str());
}
#endif
else else
assert(0); assert(0);
} }
...@@ -3020,11 +3041,14 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali ...@@ -3020,11 +3041,14 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
if (isTypeInt(publicType.basicType) || publicType.basicType == EbtDouble) if (isTypeInt(publicType.basicType) || publicType.basicType == EbtDouble)
profileRequires(loc, EEsProfile, 300, nullptr, "shader input/output"); profileRequires(loc, EEsProfile, 300, nullptr, "shader input/output");
if (!qualifier.flat
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
if (! qualifier.flat && ! qualifier.explicitInterp) { && !qualifier.explicitInterp
#else #endif
if (!qualifier.flat) { #ifdef NV_EXTENSIONS
&& !qualifier.pervertexNV
#endif #endif
) {
if (isTypeInt(publicType.basicType) || if (isTypeInt(publicType.basicType) ||
publicType.basicType == EbtDouble || publicType.basicType == EbtDouble ||
(publicType.userDef && (publicType.userDef->containsBasicType(EbtInt8) || (publicType.userDef && (publicType.userDef->containsBasicType(EbtInt8) ||
...@@ -4939,6 +4963,8 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie ...@@ -4939,6 +4963,8 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
dst.layoutViewportRelative = true; dst.layoutViewportRelative = true;
if (src.layoutSecondaryViewportRelativeOffset != -2048) if (src.layoutSecondaryViewportRelativeOffset != -2048)
dst.layoutSecondaryViewportRelativeOffset = src.layoutSecondaryViewportRelativeOffset; dst.layoutSecondaryViewportRelativeOffset = src.layoutSecondaryViewportRelativeOffset;
if (src.pervertexNV)
dst.pervertexNV = true;
#endif #endif
} }
} }
......
...@@ -691,6 +691,9 @@ void TScanContext::fillInKeywordMap() ...@@ -691,6 +691,9 @@ void TScanContext::fillInKeywordMap()
(*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD; (*KeywordMap)["__explicitInterpAMD"] = EXPLICITINTERPAMD;
#endif #endif
(*KeywordMap)["centroid"] = CENTROID; (*KeywordMap)["centroid"] = CENTROID;
#ifdef NV_EXTENSIONS
(*KeywordMap)["pervertexNV"] = PERVERTEXNV;
#endif
(*KeywordMap)["precise"] = PRECISE; (*KeywordMap)["precise"] = PRECISE;
(*KeywordMap)["invariant"] = INVARIANT; (*KeywordMap)["invariant"] = INVARIANT;
(*KeywordMap)["packed"] = PACKED; (*KeywordMap)["packed"] = PACKED;
...@@ -1507,6 +1510,15 @@ int TScanContext::tokenizeIdentifier() ...@@ -1507,6 +1510,15 @@ int TScanContext::tokenizeIdentifier()
return identifierOrType(); return identifierOrType();
#endif #endif
#ifdef NV_EXTENSIONS
case PERVERTEXNV:
if (((parseContext.profile != EEsProfile && parseContext.version >= 450) ||
(parseContext.profile == EEsProfile && parseContext.version >= 320)) &&
parseContext.extensionTurnedOn(E_GL_NV_fragment_shader_barycentric))
return keyword;
return identifierOrType();
#endif
case FLAT: case FLAT:
if (parseContext.profile == EEsProfile && parseContext.version < 300) if (parseContext.profile == EEsProfile && parseContext.version < 300)
reservedWord(); reservedWord();
......
...@@ -235,6 +235,7 @@ void TParseVersions::initializeExtensionBehavior() ...@@ -235,6 +235,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable; extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable;
extensionBehavior[E_GL_NV_shader_noperspective_interpolation] = EBhDisable; extensionBehavior[E_GL_NV_shader_noperspective_interpolation] = EBhDisable;
extensionBehavior[E_GL_NV_shader_subgroup_partitioned] = EBhDisable; extensionBehavior[E_GL_NV_shader_subgroup_partitioned] = EBhDisable;
extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable;
#endif #endif
// AEP // AEP
...@@ -405,6 +406,7 @@ void TParseVersions::getPreamble(std::string& preamble) ...@@ -405,6 +406,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_shader_atomic_int64 1\n" "#define GL_NV_shader_atomic_int64 1\n"
"#define GL_NV_conservative_raster_underestimation 1\n" "#define GL_NV_conservative_raster_underestimation 1\n"
"#define GL_NV_shader_subgroup_partitioned 1\n" "#define GL_NV_shader_subgroup_partitioned 1\n"
"#define GL_NV_fragment_shader_barycentric 1\n"
#endif #endif
"#define GL_KHX_shader_explicit_arithmetic_types 1\n" "#define GL_KHX_shader_explicit_arithmetic_types 1\n"
"#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n" "#define GL_KHX_shader_explicit_arithmetic_types_int8 1\n"
......
...@@ -207,7 +207,7 @@ const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_ ...@@ -207,7 +207,7 @@ const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_
const char* const E_GL_NV_conservative_raster_underestimation = "GL_NV_conservative_raster_underestimation"; const char* const E_GL_NV_conservative_raster_underestimation = "GL_NV_conservative_raster_underestimation";
const char* const E_GL_NV_shader_noperspective_interpolation = "GL_NV_shader_noperspective_interpolation"; const char* const E_GL_NV_shader_noperspective_interpolation = "GL_NV_shader_noperspective_interpolation";
const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_subgroup_partitioned"; const char* const E_GL_NV_shader_subgroup_partitioned = "GL_NV_shader_subgroup_partitioned";
const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric";
// Arrays of extensions for the above viewportEXTs duplications // Arrays of extensions for the above viewportEXTs duplications
const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 }; const char* const viewportEXTs[] = { E_GL_ARB_shader_viewport_layer_array, E_GL_NV_viewport_array2 };
......
...@@ -146,7 +146,7 @@ extern int yylex(YYSTYPE*, TParseContext&); ...@@ -146,7 +146,7 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4 %token <lex> F16VEC2 F16VEC3 F16VEC4 F16MAT2 F16MAT3 F16MAT4
%token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4 %token <lex> F32VEC2 F32VEC3 F32VEC4 F32MAT2 F32MAT3 F32MAT4
%token <lex> F64VEC2 F64VEC3 F64VEC4 F64MAT2 F64MAT3 F64MAT4 %token <lex> F64VEC2 F64VEC3 F64VEC4 F64MAT2 F64MAT3 F64MAT4
%token <lex> NOPERSPECTIVE FLAT SMOOTH LAYOUT EXPLICITINTERPAMD %token <lex> NOPERSPECTIVE FLAT SMOOTH LAYOUT EXPLICITINTERPAMD PERVERTEXNV
%token <lex> MAT2X2 MAT2X3 MAT2X4 %token <lex> MAT2X2 MAT2X3 MAT2X4
%token <lex> MAT3X2 MAT3X3 MAT3X4 %token <lex> MAT3X2 MAT3X3 MAT3X4
...@@ -1144,6 +1144,16 @@ interpolation_qualifier ...@@ -1144,6 +1144,16 @@ interpolation_qualifier
$$.qualifier.explicitInterp = true; $$.qualifier.explicitInterp = true;
#endif #endif
} }
| PERVERTEXNV {
#ifdef NV_EXTENSIONS
parseContext.globalCheck($1.loc, "pervertexNV");
parseContext.profileRequires($1.loc, ECoreProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, ECompatibilityProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_NV_fragment_shader_barycentric, "fragment shader barycentric");
$$.init($1.loc);
$$.qualifier.pervertexNV = true;
#endif
}
; ;
layout_qualifier layout_qualifier
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -501,6 +501,8 @@ INSTANTIATE_TEST_CASE_P( ...@@ -501,6 +501,8 @@ INSTANTIATE_TEST_CASE_P(
"spv.multiviewPerViewAttributes.vert", "spv.multiviewPerViewAttributes.vert",
"spv.multiviewPerViewAttributes.tesc", "spv.multiviewPerViewAttributes.tesc",
"spv.atomicInt64.comp", "spv.atomicInt64.comp",
"spv.fragmentShaderBarycentric.frag",
"spv.fragmentShaderBarycentric2.frag",
})), })),
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment