Implement extension GL_ARB_shader_stencil_export

This commit is contained in:
Rex Xu 2017-06-29 17:46:34 +08:00
parent 89f8d1e64f
commit 37cdceed41
10 changed files with 55 additions and 3 deletions

View File

@ -520,6 +520,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addCapability(spv::CapabilityGeometry);
return spv::BuiltInPrimitiveId;
case glslang::EbvFragStencilRef:
logger->missingFunctionality("shader stencil export");
return spv::BuiltInMax;
case glslang::EbvInvocationId: return spv::BuiltInInvocationId;
case glslang::EbvTessLevelInner: return spv::BuiltInTessLevelInner;
case glslang::EbvTessLevelOuter: return spv::BuiltInTessLevelOuter;

View File

@ -0,0 +1,26 @@
spv.shaderStencilExport.frag
Missing functionality: shader stencil export
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 10
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 8
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_ARB_shader_stencil_export"
Name 4 "main"
Name 8 "gl_FragStencilRefARB"
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
7: TypePointer Output 6(int)
8(gl_FragStencilRefARB): 7(ptr) Variable Output
9: 6(int) Constant 100
4(main): 2 Function None 3
5: Label
Store 8(gl_FragStencilRefARB) 9
Return
FunctionEnd

View File

@ -0,0 +1,8 @@
#version 450 core
#extension GL_ARB_shader_stencil_export: enable
void main()
{
gl_FragStencilRefARB = 100;
}

View File

@ -193,6 +193,7 @@ enum TBuiltInVariable {
EbvFragColor,
EbvFragData,
EbvFragDepth,
EbvFragStencilRef,
EbvSampleId,
EbvSamplePosition,
EbvSampleMask,
@ -222,7 +223,6 @@ enum TBuiltInVariable {
// to one of the above.
EbvFragDepthGreater,
EbvFragDepthLesser,
EbvStencilRef,
EbvGsOutputStream,
EbvOutputPatch,
EbvInputPatch,
@ -329,6 +329,7 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvFragColor: return "FragColor";
case EbvFragData: return "FragData";
case EbvFragDepth: return "FragDepth";
case EbvFragStencilRef: return "FragStencilRef";
case EbvSampleId: return "SampleId";
case EbvSamplePosition: return "SamplePosition";
case EbvSampleMask: return "SampleMaskIn";

View File

@ -3753,6 +3753,10 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
stageBuiltins[EShLangFragment].append(
"vec2 gl_PointCoord;" // needs qualifier fixed later
);
if (version >= 140)
stageBuiltins[EShLangFragment].append(
"out int gl_FragStencilRefARB;"
);
if (IncludeLegacy(version, profile, spvVersion) || (! ForwardCompatibility && version < 420))
stageBuiltins[EShLangFragment].append(
"vec4 gl_FragColor;" // needs qualifier fixed later
@ -5473,6 +5477,11 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
BuiltInVariable("gl_CullDistance", EbvCullDistance, symbolTable);
BuiltInVariable("gl_PrimitiveID", EbvPrimitiveId, symbolTable);
if (profile != EEsProfile && version >= 140) {
symbolTable.setVariableExtensions("gl_FragStencilRefARB", 1, &E_GL_ARB_shader_stencil_export);
BuiltInVariable("gl_FragStencilRefARB", EbvFragStencilRef, symbolTable);
}
if ((profile != EEsProfile && version >= 400) ||
(profile == EEsProfile && version >= 310)) {
BuiltInVariable("gl_SampleID", EbvSampleId, symbolTable);

View File

@ -179,6 +179,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_shader_ballot] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture2] = EBhDisable;
extensionBehavior[E_GL_ARB_sparse_texture_clamp] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_stencil_export] = EBhDisable;
// extensionBehavior[E_GL_ARB_cull_distance] = EBhDisable; // present for 4.5, but need extension control over block members
extensionBehavior[E_GL_EXT_shader_non_constant_global_initializers] = EBhDisable;
@ -309,6 +310,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_shader_ballot 1\n"
"#define GL_ARB_sparse_texture2 1\n"
"#define GL_ARB_sparse_texture_clamp 1\n"
"#define GL_ARB_shader_stencil_export 1\n"
// "#define GL_ARB_cull_distance 1\n" // present for 4.5, but need extension control over block members
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n"

View File

@ -133,6 +133,7 @@ const char* const E_GL_ARB_gpu_shader_int64 = "GL_ARB_gpu_shader_int
const char* const E_GL_ARB_shader_ballot = "GL_ARB_shader_ballot";
const char* const E_GL_ARB_sparse_texture2 = "GL_ARB_sparse_texture2";
const char* const E_GL_ARB_sparse_texture_clamp = "GL_ARB_sparse_texture_clamp";
const char* const E_GL_ARB_shader_stencil_export = "GL_ARB_shader_stencil_export";
// const char* const E_GL_ARB_cull_distance = "GL_ARB_cull_distance"; // present for 4.5, but need extension control over block members
const char* const E_GL_EXT_shader_non_constant_global_initializers = "GL_EXT_shader_non_constant_global_initializers";

View File

@ -278,6 +278,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.shaderBallot.comp",
"spv.shaderDrawParams.vert",
"spv.shaderGroupVote.comp",
"spv.shaderStencilExport.frag",
"spv.shiftOps.frag",
"spv.simpleFunctionCall.frag",
"spv.simpleMat.vert",

View File

@ -5249,7 +5249,7 @@ void HlslParseContext::handleSemantic(TSourceLoc loc, TQualifier& qualifier, TBu
if (language == EShLangFragment)
builtIn = EbvFragCoord;
break;
case EbvStencilRef:
case EbvFragStencilRef:
error(loc, "unimplemented; need ARB_shader_stencil_export", "SV_STENCILREF", "");
break;
case EbvTessLevelInner:

View File

@ -466,7 +466,7 @@ void HlslScanContext::fillInKeywordMap()
(*SemanticMap)["SV_COVERAGE"] = EbvSampleMask;
(*SemanticMap)["SV_DEPTHGREATEREQUAL"] = EbvFragDepthGreater;
(*SemanticMap)["SV_DEPTHLESSEQUAL"] = EbvFragDepthLesser;
(*SemanticMap)["SV_STENCILREF"] = EbvStencilRef;
(*SemanticMap)["SV_STENCILREF"] = EbvFragStencilRef;
}
void HlslScanContext::deleteKeywordMap()