support SPV_NV_viewport_array2 and SPV_NV_stereo_view_rendering
This commit is contained in:
@@ -203,6 +203,11 @@ enum TBuiltInVariable {
|
||||
EbvBaryCoordPullModel,
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
EbvViewportMaskNV,
|
||||
EbvSecondaryPositionNV,
|
||||
EbvSecondaryViewportMaskNV,
|
||||
#endif
|
||||
// HLSL built-ins that live only temporarily, until they get remapped
|
||||
// to one of the above.
|
||||
EbvFragDepthGreater,
|
||||
@@ -316,6 +321,11 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
|
||||
case EbvBaryCoordSmoothSample: return "BaryCoordSmoothSample";
|
||||
case EbvBaryCoordPullModel: return "BaryCoordPullModel";
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
case EbvViewportMaskNV: return "ViewportMaskNV";
|
||||
case EbvSecondaryPositionNV: return "SecondaryPositionNV";
|
||||
case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
|
||||
#endif
|
||||
default: return "unknown built-in variable";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,6 +601,9 @@ public:
|
||||
layoutPushConstant = false;
|
||||
#ifdef NV_EXTENSIONS
|
||||
layoutPassthrough = false;
|
||||
layoutViewportRelative = false;
|
||||
// -2048 as the default vaule indicating layoutSecondaryViewportRelative is not set
|
||||
layoutSecondaryViewportRelativeOffset = -2048;
|
||||
#endif
|
||||
}
|
||||
bool hasLayout() const
|
||||
@@ -657,6 +660,8 @@ public:
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
bool layoutPassthrough;
|
||||
bool layoutViewportRelative;
|
||||
int layoutSecondaryViewportRelativeOffset;
|
||||
#endif
|
||||
|
||||
bool hasUniformLayout() const
|
||||
@@ -1336,6 +1341,12 @@ public:
|
||||
case EbvPointSize:
|
||||
case EbvClipDistance:
|
||||
case EbvCullDistance:
|
||||
#ifdef NV_EXTENSIONS
|
||||
case EbvLayer:
|
||||
case EbvViewportMaskNV:
|
||||
case EbvSecondaryPositionNV:
|
||||
case EbvSecondaryViewportMaskNV:
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@@ -1604,6 +1615,10 @@ public:
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (qualifier.layoutPassthrough)
|
||||
p += snprintf(p, end - p, "passthrough ");
|
||||
if (qualifier.layoutViewportRelative)
|
||||
p += snprintf(p, end - p, "layoutViewportRelative ");
|
||||
if (qualifier.layoutSecondaryViewportRelativeOffset != -2048)
|
||||
p += snprintf(p, end - p, "layoutSecondaryViewportRelativeOffset=%d ", qualifier.layoutSecondaryViewportRelativeOffset);
|
||||
#endif
|
||||
|
||||
p += snprintf(p, end - p, ") ");
|
||||
|
||||
@@ -3240,6 +3240,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"in int gl_DrawIDARB;"
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangVertex].append(
|
||||
"out int gl_ViewportIndex;"
|
||||
"out int gl_Layer;"
|
||||
"out int gl_ViewportMask[];"
|
||||
"out int gl_SecondaryViewportMaskNV[];"
|
||||
"out vec4 gl_SecondaryPositionNV;"
|
||||
);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// ES profile
|
||||
if (version == 100) {
|
||||
@@ -3299,6 +3311,9 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"float gl_CullDistance[];"
|
||||
#ifdef NV_EXTENSIONS
|
||||
"vec4 gl_SecondaryPositionNV;"
|
||||
#endif
|
||||
);
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"} gl_in[];"
|
||||
@@ -3343,6 +3358,16 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"out int gl_ViewportIndex;"
|
||||
);
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
"out int gl_ViewportMask[];"
|
||||
"out int gl_SecondaryViewportMaskNV[];"
|
||||
"out vec4 gl_SecondaryPositionNV;"
|
||||
);
|
||||
#endif
|
||||
|
||||
stageBuiltins[EShLangGeometry].append("\n");
|
||||
} else if (profile == EEsProfile && version >= 310) {
|
||||
stageBuiltins[EShLangGeometry].append(
|
||||
@@ -3398,6 +3423,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"float gl_CullDistance[];"
|
||||
#ifdef NV_EXTENSIONS
|
||||
"int gl_ViewportIndex;"
|
||||
"int gl_Layer;"
|
||||
"int gl_ViewportMask[];"
|
||||
"vec4 gl_SecondaryPositionNV;"
|
||||
"int gl_SecondaryViewportMaskNV[];"
|
||||
#endif
|
||||
);
|
||||
stageBuiltins[EShLangTessControl].append(
|
||||
"} gl_out[];"
|
||||
@@ -3467,6 +3499,18 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
stageBuiltins[EShLangTessEvaluation].append(
|
||||
"};"
|
||||
"\n");
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangTessEvaluation].append(
|
||||
"out int gl_ViewportIndex;"
|
||||
"out int gl_Layer;"
|
||||
"out int gl_ViewportMask[];"
|
||||
"out vec4 gl_SecondaryPositionNV;"
|
||||
"out int gl_SecondaryViewportMaskNV[];"
|
||||
);
|
||||
#endif
|
||||
|
||||
} else if (profile == EEsProfile && version >= 310) {
|
||||
// Note: "in gl_PerVertex {...} gl_in[gl_MaxPatchVertices];" is declared in initialize() below,
|
||||
// as it depends on the resource sizing of gl_MaxPatchVertices.
|
||||
@@ -4400,6 +4444,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
||||
"in gl_PerVertex {"
|
||||
"highp vec4 gl_Position;"
|
||||
"highp float gl_PointSize;"
|
||||
#ifdef NV_EXTENSIONS
|
||||
"highp vec4 gl_SecondaryPositionNV;"
|
||||
#endif
|
||||
"} gl_in[gl_MaxPatchVertices];"
|
||||
"\n");
|
||||
}
|
||||
@@ -4586,6 +4633,9 @@ void TBuiltIns::initialize(const TBuiltInResource &resources, int version, EProf
|
||||
if (profile != EEsProfile && version >= 450)
|
||||
s.append(
|
||||
"float gl_CullDistance[];"
|
||||
#ifdef NV_EXTENSIONS
|
||||
"vec4 gl_SecondaryPositionNV;"
|
||||
#endif
|
||||
);
|
||||
s.append(
|
||||
"} gl_in[gl_MaxPatchVertices];"
|
||||
@@ -4974,6 +5024,30 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
BuiltInVariable("gl_InvocationID", EbvInvocationId, symbolTable);
|
||||
BuiltInVariable("gl_Layer", EbvLayer, symbolTable);
|
||||
BuiltInVariable("gl_ViewportIndex", EbvViewportIndex, symbolTable);
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (language != EShLangGeometry) {
|
||||
symbolTable.setVariableExtensions("gl_Layer", Num_viewportEXTs, viewportEXTs);
|
||||
symbolTable.setVariableExtensions("gl_ViewportIndex", Num_viewportEXTs, viewportEXTs);
|
||||
}
|
||||
symbolTable.setVariableExtensions("gl_ViewportMask", 1, &E_GL_NV_viewport_array2);
|
||||
symbolTable.setVariableExtensions("gl_SecondaryPositionNV", 1, &E_GL_NV_stereo_view_rendering);
|
||||
symbolTable.setVariableExtensions("gl_SecondaryViewportMaskNV", 1, &E_GL_NV_stereo_view_rendering);
|
||||
|
||||
BuiltInVariable("gl_ViewportMask", EbvViewportMaskNV, symbolTable);
|
||||
BuiltInVariable("gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
|
||||
BuiltInVariable("gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
|
||||
|
||||
if (language != EShLangVertex)
|
||||
BuiltInVariable("gl_in", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
|
||||
|
||||
BuiltInVariable("gl_out", "gl_Layer", EbvLayer, symbolTable);
|
||||
BuiltInVariable("gl_out", "gl_ViewportIndex", EbvViewportIndex, symbolTable);
|
||||
BuiltInVariable("gl_out", "gl_ViewportMask", EbvViewportMaskNV, symbolTable);
|
||||
BuiltInVariable("gl_out", "gl_SecondaryPositionNV", EbvSecondaryPositionNV, symbolTable);
|
||||
BuiltInVariable("gl_out", "gl_SecondaryViewportMaskNV", EbvSecondaryViewportMaskNV, symbolTable);
|
||||
#endif
|
||||
|
||||
BuiltInVariable("gl_PatchVerticesIn", EbvPatchVertices, symbolTable);
|
||||
BuiltInVariable("gl_TessLevelOuter", EbvTessLevelOuter, symbolTable);
|
||||
BuiltInVariable("gl_TessLevelInner", EbvTessLevelInner, symbolTable);
|
||||
|
||||
@@ -3205,6 +3205,7 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
|
||||
(identifier == "gl_Color" && language == EShLangFragment) ||
|
||||
#ifdef NV_EXTENSIONS
|
||||
identifier == "gl_SampleMask" ||
|
||||
identifier == "gl_Layer" ||
|
||||
#endif
|
||||
identifier == "gl_TexCoord") {
|
||||
|
||||
@@ -3291,6 +3292,12 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
|
||||
}
|
||||
intermediate.setLayoutOverrideCoverage();
|
||||
}
|
||||
else if (identifier == "gl_Layer") {
|
||||
if (!qualifier.layoutViewportRelative && qualifier.layoutSecondaryViewportRelativeOffset == -2048)
|
||||
error(loc, "redeclaration only allowed for viewport_relative or secondary_view_offset layout", "redeclaration", symbol->getName().c_str());
|
||||
symbolQualifier.layoutViewportRelative = qualifier.layoutViewportRelative;
|
||||
symbolQualifier.layoutSecondaryViewportRelativeOffset = qualifier.layoutSecondaryViewportRelativeOffset;
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: semantics quality: separate smooth from nothing declared, then use IsInterpolation for several tests above
|
||||
@@ -3417,8 +3424,16 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
|
||||
oldType.getQualifier().flat = newType.getQualifier().flat;
|
||||
oldType.getQualifier().nopersp = newType.getQualifier().nopersp;
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (member->type->getFieldName() == "gl_Layer") {
|
||||
if (!newType.getQualifier().layoutViewportRelative && newType.getQualifier().layoutSecondaryViewportRelativeOffset == -2048)
|
||||
error(loc, "redeclaration only allowed for viewport_relative or secondary_view_offset layout", "redeclaration", member->type->getFieldName().c_str());
|
||||
oldType.getQualifier().layoutViewportRelative = newType.getQualifier().layoutViewportRelative;
|
||||
oldType.getQualifier().layoutSecondaryViewportRelativeOffset = newType.getQualifier().layoutSecondaryViewportRelativeOffset;
|
||||
}
|
||||
if (oldType.isImplicitlySizedArray() && newType.isExplicitlySizedArray())
|
||||
oldType.changeOuterArraySize(newType.getOuterArraySize());
|
||||
#endif
|
||||
|
||||
// go to next member
|
||||
++member;
|
||||
@@ -3943,8 +3958,18 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
publicType.shaderQualifiers.layoutOverrideCoverage = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (language == EShLangVertex ||
|
||||
language == EShLangTessControl ||
|
||||
language == EShLangTessEvaluation ||
|
||||
language == EShLangGeometry ) {
|
||||
if (id == "viewport_relative") {
|
||||
requireExtensions(loc, 1, &E_GL_NV_viewport_array2, "view port array2");
|
||||
publicType.qualifier.layoutViewportRelative = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), "");
|
||||
}
|
||||
|
||||
@@ -4090,6 +4115,19 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
||||
return;
|
||||
}
|
||||
|
||||
#if NV_EXTENSIONS
|
||||
if (language == EShLangVertex ||
|
||||
language == EShLangTessControl ||
|
||||
language == EShLangTessEvaluation ||
|
||||
language == EShLangGeometry) {
|
||||
if (id == "secondary_view_offset") {
|
||||
requireExtensions(loc, 1, &E_GL_NV_stereo_view_rendering, "stereo view rendering");
|
||||
publicType.qualifier.layoutSecondaryViewportRelativeOffset = value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (language) {
|
||||
case EShLangVertex:
|
||||
break;
|
||||
@@ -4253,6 +4291,10 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (src.layoutPassthrough)
|
||||
dst.layoutPassthrough = true;
|
||||
if (src.layoutViewportRelative)
|
||||
dst.layoutViewportRelative = true;
|
||||
if (src.layoutSecondaryViewportRelativeOffset != -2048)
|
||||
dst.layoutSecondaryViewportRelativeOffset = src.layoutSecondaryViewportRelativeOffset;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,9 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
#ifdef NV_EXTENSIONS
|
||||
extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable;
|
||||
extensionBehavior[E_SPV_NV_geometry_shader_passthrough] = EBhDisable;
|
||||
extensionBehavior[E_GL_ARB_shader_viewport_layer_array] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_viewport_array2] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable;
|
||||
#endif
|
||||
|
||||
// AEP
|
||||
@@ -311,6 +314,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
#ifdef NV_EXTENSIONS
|
||||
"#define GL_NV_sample_mask_override_coverage 1\n"
|
||||
"#define GL_NV_geometry_shader_passthrough 1\n"
|
||||
"#define GL_NV_viewport_array2 1\n"
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,17 @@ const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_sh
|
||||
const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_shader_half_float";
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
|
||||
const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
|
||||
|
||||
const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
|
||||
const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
|
||||
const char* const E_GL_ARB_shader_viewport_layer_array = "GL_ARB_shader_viewport_layer_array";
|
||||
const char* const E_GL_NV_viewport_array2 = "GL_NV_viewport_array2";
|
||||
const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering";
|
||||
|
||||
// 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 int Num_viewportEXTs = sizeof(viewportEXTs) / sizeof(viewportEXTs[0]);
|
||||
#endif
|
||||
|
||||
// AEP
|
||||
|
||||
Reference in New Issue
Block a user