SPV: Implement extension SPV_EXT_shader_stencil_export
authorRex Xu <rex.xu@amd.com>
Wed, 23 Aug 2017 15:24:42 +0000 (23:24 +0800)
committerRex Xu <rex.xu@amd.com>
Wed, 23 Aug 2017 22:26:15 +0000 (06:26 +0800)
SPIRV/GLSL.ext.KHR.h
SPIRV/GlslangToSpv.cpp
SPIRV/doc.cpp
SPIRV/spirv.hpp
Test/baseResults/spv.shaderStencilExport.frag.out

index 6e025298a5850e0e3e8b432085dc22bc1e6a25da..8a5db3e19c53f2fd080986266e44ec9cea593d63 100644 (file)
@@ -42,5 +42,6 @@ static const char* const E_SPV_KHR_shader_draw_parameters       = "SPV_KHR_shade
 static const char* const E_SPV_KHR_16bit_storage                = "SPV_KHR_16bit_storage";
 static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
 static const char* const E_SPV_KHR_post_depth_coverage          = "SPV_KHR_post_depth_coverage";
+static const char* const E_SPV_EXT_shader_stencil_export        = "SPV_EXT_shader_stencil_export";
 
 #endif  // #ifndef GLSLextKHR_H
index a1677027d926f9ffc289ad7bd2bba378bbe1479b..c8d6e44c2f54d53af48441dc6262d4e24a025155 100755 (executable)
@@ -522,8 +522,9 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
         return spv::BuiltInPrimitiveId;
 
     case glslang::EbvFragStencilRef:
-        logger->missingFunctionality("shader stencil export");
-        return spv::BuiltInMax;
+        builder.addExtension(spv::E_SPV_EXT_shader_stencil_export);
+        builder.addCapability(spv::CapabilityStencilExportEXT);
+        return spv::BuiltInFragStencilRefEXT;
 
     case glslang::EbvInvocationId:         return spv::BuiltInInvocationId;
     case glslang::EbvTessLevelInner:       return spv::BuiltInTessLevelInner;
index b47fa48894cbdeeb55c934fb9929ec15aff7ce3d..037a9749770c23d13901b7ebdc64237cac764175 100755 (executable)
@@ -331,6 +331,7 @@ const char* BuiltInString(int builtIn)
     case 4424: return "BaseVertex";
     case 4425: return "BaseInstance";
     case 4426: return "DrawIndex";
+    case 5014: return "FragStencilRefEXT";
 
 #ifdef AMD_EXTENSIONS
     case 4992: return "BaryCoordNoPerspAMD";
@@ -842,6 +843,8 @@ const char* CapabilityString(int info)
     case 4437: return "DeviceGroup";
     case 4439: return "MultiView";
 
+    case 5013: return "StencilExportEXT";
+
 #ifdef AMD_EXTENSIONS
     case 5009: return "ImageGatherBiasLodAMD";
 #endif
index 338f6a16d38387bdb8b414db908fe672cebb90aa..8bddf7e503a319f6706cba7fadb9b94b80ca5da3 100755 (executable)
@@ -47,11 +47,11 @@ namespace spv {
 typedef unsigned int Id;
 
 #define SPV_VERSION 0x10000
-#define SPV_REVISION 11
+#define SPV_REVISION 12
 
 static const unsigned int MagicNumber = 0x07230203;
 static const unsigned int Version = 0x00010000;
-static const unsigned int Revision = 11;
+static const unsigned int Revision = 12;
 static const unsigned int OpCodeMask = 0xffff;
 static const unsigned int WordCountShift = 16;
 
@@ -444,6 +444,7 @@ enum BuiltIn {
     BuiltInBaryCoordSmoothCentroidAMD = 4996,
     BuiltInBaryCoordSmoothSampleAMD = 4997,
     BuiltInBaryCoordPullModelAMD = 4998,
+    BuiltInFragStencilRefEXT = 5014,
     BuiltInViewportMaskNV = 5253,
     BuiltInSecondaryPositionNV = 5257,
     BuiltInSecondaryViewportMaskNV = 5258,
@@ -640,8 +641,10 @@ enum Capability {
     CapabilityAtomicStorageOps = 4445,
     CapabilitySampleMaskPostDepthCoverage = 4447,
     CapabilityImageGatherBiasLodAMD = 5009,
+    CapabilityStencilExportEXT = 5013,
     CapabilitySampleMaskOverrideCoverageNV = 5249,
     CapabilityGeometryShaderPassthroughNV = 5251,
+    CapabilityShaderViewportIndexLayerEXT = 5254,
     CapabilityShaderViewportIndexLayerNV = 5254,
     CapabilityShaderViewportMaskNV = 5255,
     CapabilityShaderStereoViewNV = 5259,
index c0c72095256d7e19e4fd963bc35878c19506650d..b0774de9216eb5bdf8580a0426c43afea3579f35 100644 (file)
@@ -1,10 +1,11 @@
 spv.shaderStencilExport.frag
-Missing functionality: shader stencil export
 // Module Version 10000
 // Generated by (magic number): 80001
 // Id's are bound by 10
 
                               Capability Shader
+                              Capability StencilExportEXT
+                              Extension  "SPV_EXT_shader_stencil_export"
                1:             ExtInstImport  "GLSL.std.450"
                               MemoryModel Logical GLSL450
                               EntryPoint Fragment 4  "main" 8
@@ -13,6 +14,7 @@ Missing functionality: shader stencil export
                               SourceExtension  "GL_ARB_shader_stencil_export"
                               Name 4  "main"
                               Name 8  "gl_FragStencilRefARB"
+                              Decorate 8(gl_FragStencilRefARB) BuiltIn FragStencilRefEXT
                2:             TypeVoid
                3:             TypeFunction 2
                6:             TypeInt 32 1