Add implementation of SPV_EXT_fragment_fully_covered

This implementation uses the GLSL extension
GL_NV_conservative_raster_underestimation to generate the new SPIR-V
FullyCoveredEXT built in.
This commit is contained in:
Piers Daniell 2017-12-13 13:07:22 -07:00 committed by John Kessenich
parent e9e0cb60ec
commit 1c5443c693
11 changed files with 116 additions and 1 deletions

39
SPIRV/GLSL.ext.EXT.h Normal file
View File

@ -0,0 +1,39 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLextEXT_H
#define GLSLextEXT_H
enum BuiltIn;
enum Op;
enum Capability;
static const int GLSLextEXTVersion = 100;
static const int GLSLextEXTRevision = 1;
static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fully_covered";
#endif // #ifndef GLSLextEXT_H

View File

@ -44,6 +44,7 @@
namespace spv { namespace spv {
#include "GLSL.std.450.h" #include "GLSL.std.450.h"
#include "GLSL.ext.KHR.h" #include "GLSL.ext.KHR.h"
#include "GLSL.ext.EXT.h"
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
#include "GLSL.ext.AMD.h" #include "GLSL.ext.AMD.h"
#endif #endif
@ -646,6 +647,10 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addCapability(spv::CapabilityPerViewAttributesNV); builder.addCapability(spv::CapabilityPerViewAttributesNV);
} }
return spv::BuiltInViewportMaskPerViewNV; return spv::BuiltInViewportMaskPerViewNV;
case glslang::EbvFragFullyCoveredNV:
builder.addExtension(spv::E_SPV_EXT_fragment_fully_covered);
builder.addCapability(spv::CapabilityFragmentFullyCoveredEXT);
return spv::BuiltInFullyCoveredEXT;
#endif #endif
default: default:
return spv::BuiltInMax; return spv::BuiltInMax;

View File

@ -49,6 +49,7 @@ namespace spv {
extern "C" { extern "C" {
// Include C-based headers that don't have a namespace // Include C-based headers that don't have a namespace
#include "GLSL.ext.KHR.h" #include "GLSL.ext.KHR.h"
#include "GLSL.ext.EXT.h"
#ifdef AMD_EXTENSIONS #ifdef AMD_EXTENSIONS
#include "GLSL.ext.AMD.h" #include "GLSL.ext.AMD.h"
#endif #endif
@ -351,6 +352,8 @@ const char* BuiltInString(int builtIn)
case 5262: return "ViewportMaskPerViewNV"; case 5262: return "ViewportMaskPerViewNV";
#endif #endif
case 5264: return "FullyCoveredEXT";
case BuiltInCeiling: case BuiltInCeiling:
default: return "Bad"; default: return "Bad";
} }
@ -862,6 +865,8 @@ const char* CapabilityString(int info)
case 5260: return "PerViewAttributesNV"; case 5260: return "PerViewAttributesNV";
#endif #endif
case 5265: return "FragmentFullyCoveredEXT";
case CapabilityCeiling: case CapabilityCeiling:
default: return "Bad"; default: return "Bad";
} }

View File

@ -0,0 +1,37 @@
spv.fullyCovered.frag
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 18
Capability Shader
Capability FragmentFullyCoveredEXT
Extension "SPV_EXT_fragment_fully_covered"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 9 12
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_NV_conservative_raster_underestimation"
Name 4 "main"
Name 9 "color"
Name 12 "gl_FragFullyCoveredNV"
Decorate 12(gl_FragFullyCoveredNV) BuiltIn FullyCoveredEXT
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Output 7(fvec4)
9(color): 8(ptr) Variable Output
10: TypeBool
11: TypePointer Input 10(bool)
12(gl_FragFullyCoveredNV): 11(ptr) Variable Input
14: 6(float) Constant 0
15: 6(float) Constant 1065353216
4(main): 2 Function None 3
5: Label
13: 10(bool) Load 12(gl_FragFullyCoveredNV)
16: 6(float) Select 13 15 14
17: 7(fvec4) CompositeConstruct 16 14 14 14
Store 9(color) 17
Return
FunctionEnd

View File

@ -0,0 +1,9 @@
#version 450
#extension GL_NV_conservative_raster_underestimation : enable
out vec4 color;
void main() {
color = vec4(gl_FragFullyCoveredNV, 0, 0, 0);
}

View File

@ -218,6 +218,7 @@ enum TBuiltInVariable {
EbvSecondaryViewportMaskNV, EbvSecondaryViewportMaskNV,
EbvPositionPerViewNV, EbvPositionPerViewNV,
EbvViewportMaskPerViewNV, EbvViewportMaskPerViewNV,
EbvFragFullyCoveredNV,
#endif #endif
// HLSL built-ins that live only temporarily, until they get remapped // HLSL built-ins that live only temporarily, until they get remapped
@ -355,6 +356,7 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV"; case EbvSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
case EbvPositionPerViewNV: return "PositionPerViewNV"; case EbvPositionPerViewNV: return "PositionPerViewNV";
case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV"; case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
#endif #endif
default: return "unknown built-in variable"; default: return "unknown built-in variable";
} }

View File

@ -3963,6 +3963,13 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
"in vec3 gl_BaryCoordPullModelAMD;" "in vec3 gl_BaryCoordPullModelAMD;"
); );
#endif #endif
#ifdef NV_EXTENSIONS
if (version >= 430)
stageBuiltins[EShLangFragment].append(
"in bool gl_FragFullyCoveredNV;"
);
#endif
} else { } else {
// ES profile // ES profile
@ -5858,6 +5865,13 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
} }
#endif #endif
#ifdef NV_EXTENSIONS
if (profile != EEsProfile && version >= 430) {
symbolTable.setVariableExtensions("gl_FragFullyCoveredNV", 1, &E_GL_NV_conservative_raster_underestimation);
BuiltInVariable("gl_FragFullyCoveredNV", EbvFragFullyCoveredNV, symbolTable);
}
#endif
symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth); symbolTable.setVariableExtensions("gl_FragDepthEXT", 1, &E_GL_EXT_frag_depth);
if (profile == EEsProfile && version < 320) { if (profile == EEsProfile && version < 320) {

View File

@ -2560,7 +2560,7 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
// now, knowing it is a shader in/out, do all the in/out semantic checks // now, knowing it is a shader in/out, do all the in/out semantic checks
if (publicType.basicType == EbtBool) { if (publicType.basicType == EbtBool && !parsingBuiltins) {
error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), ""); error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), "");
return; return;
} }

View File

@ -212,6 +212,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable; extensionBehavior[E_GL_NV_stereo_view_rendering] = EBhDisable;
extensionBehavior[E_GL_NVX_multiview_per_view_attributes] = EBhDisable; extensionBehavior[E_GL_NVX_multiview_per_view_attributes] = EBhDisable;
extensionBehavior[E_GL_NV_shader_atomic_int64] = EBhDisable; extensionBehavior[E_GL_NV_shader_atomic_int64] = EBhDisable;
extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable;
#endif #endif
// AEP // AEP
@ -345,6 +346,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_NV_geometry_shader_passthrough 1\n" "#define GL_NV_geometry_shader_passthrough 1\n"
"#define GL_NV_viewport_array2 1\n" "#define GL_NV_viewport_array2 1\n"
"#define GL_NV_shader_atomic_int64 1\n" "#define GL_NV_shader_atomic_int64 1\n"
"#define GL_NV_conservative_raster_underestimation 1\n"
#endif #endif
; ;

View File

@ -183,6 +183,7 @@ const char* const E_GL_NV_viewport_array2 = "GL_NV_viewpor
const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering"; const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_view_rendering";
const char* const E_GL_NVX_multiview_per_view_attributes = "GL_NVX_multiview_per_view_attributes"; const char* const E_GL_NVX_multiview_per_view_attributes = "GL_NVX_multiview_per_view_attributes";
const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_atomic_int64"; const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_atomic_int64";
const char* const E_GL_NV_conservative_raster_underestimation = "GL_NV_conservative_raster_underestimation";
// Arrays of extensions for the above viewportEXTs duplications // Arrays of extensions for the above viewportEXTs duplications

View File

@ -249,6 +249,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.flowControl.frag", "spv.flowControl.frag",
"spv.forLoop.frag", "spv.forLoop.frag",
"spv.forwardFun.frag", "spv.forwardFun.frag",
"spv.fullyCovered.frag",
"spv.functionCall.frag", "spv.functionCall.frag",
"spv.functionNestedOpaque.vert", "spv.functionNestedOpaque.vert",
"spv.functionSemantics.frag", "spv.functionSemantics.frag",