mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Add-support-for-SPV_NV_shading_rate
This commit is contained in:
parent
b50c02ef53
commit
5b2203db04
@ -33,7 +33,7 @@ enum Op;
|
||||
enum Capability;
|
||||
|
||||
static const int GLSLextNVVersion = 100;
|
||||
static const int GLSLextNVRevision = 10;
|
||||
static const int GLSLextNVRevision = 11;
|
||||
|
||||
//SPV_NV_sample_mask_override_coverage
|
||||
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
|
||||
@ -69,4 +69,7 @@ const char* const E_SPV_NV_mesh_shader = "SPV_NV_mesh_shader";
|
||||
//SPV_NVX_raytracing
|
||||
const char* const E_SPV_NVX_raytracing = "SPV_NVX_raytracing";
|
||||
|
||||
//SPV_NV_shading_rate
|
||||
const char* const E_SPV_NV_shading_rate = "SPV_NV_shading_rate";
|
||||
|
||||
#endif // #ifndef GLSLextNV_H
|
||||
|
@ -864,6 +864,14 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
|
||||
builder.addExtension(spv::E_SPV_EXT_fragment_fully_covered);
|
||||
builder.addCapability(spv::CapabilityFragmentFullyCoveredEXT);
|
||||
return spv::BuiltInFullyCoveredEXT;
|
||||
case glslang::EbvFragmentSizeNV:
|
||||
builder.addExtension(spv::E_SPV_NV_shading_rate);
|
||||
builder.addCapability(spv::CapabilityShadingRateNV);
|
||||
return spv::BuiltInFragmentSizeNV;
|
||||
case glslang::EbvInvocationsPerPixelNV:
|
||||
builder.addExtension(spv::E_SPV_NV_shading_rate);
|
||||
builder.addCapability(spv::CapabilityShadingRateNV);
|
||||
return spv::BuiltInInvocationsPerPixelNV;
|
||||
|
||||
// raytracing
|
||||
case glslang::EbvLaunchIdNV:
|
||||
|
@ -385,6 +385,8 @@ const char* BuiltInString(int builtIn)
|
||||
case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
|
||||
case BuiltInPositionPerViewNV: return "PositionPerViewNV";
|
||||
case BuiltInViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
|
||||
case BuiltInFragmentSizeNV: return "FragmentSizeNV";
|
||||
case BuiltInInvocationsPerPixelNV: return "InvocationsPerPixelNV";
|
||||
case BuiltInBaryCoordNV: return "BaryCoordNV";
|
||||
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
|
||||
#endif
|
||||
@ -892,6 +894,7 @@ const char* CapabilityString(int info)
|
||||
case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
|
||||
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
|
||||
case CapabilityMeshShadingNV: return "MeshShadingNV";
|
||||
case CapabilityShadingRateNV: return "ShadingRateNV";
|
||||
#endif
|
||||
|
||||
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";
|
||||
|
48
Test/baseResults/spv.shadingRate.frag.out
Normal file
48
Test/baseResults/spv.shadingRate.frag.out
Normal file
@ -0,0 +1,48 @@
|
||||
spv.shadingRate.frag
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80007
|
||||
// Id's are bound by 21
|
||||
|
||||
Capability Shader
|
||||
Capability ShadingRateNV
|
||||
Extension "SPV_NV_shading_rate"
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main" 9 13 17 19
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source GLSL 450
|
||||
SourceExtension "GL_NV_shading_rate_image"
|
||||
Name 4 "main"
|
||||
Name 9 "FragmentSize"
|
||||
Name 13 "gl_FragmentSizeNV"
|
||||
Name 17 "InvocationsPerPixel"
|
||||
Name 19 "gl_InvocationsPerPixelNV"
|
||||
Decorate 9(FragmentSize) Location 0
|
||||
Decorate 13(gl_FragmentSizeNV) Flat
|
||||
Decorate 13(gl_FragmentSizeNV) BuiltIn FragmentSizeNV
|
||||
Decorate 17(InvocationsPerPixel) Location 2
|
||||
Decorate 19(gl_InvocationsPerPixelNV) Flat
|
||||
Decorate 19(gl_InvocationsPerPixelNV) BuiltIn InvocationsPerPixelNV
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeFloat 32
|
||||
7: TypeVector 6(float) 2
|
||||
8: TypePointer Output 7(fvec2)
|
||||
9(FragmentSize): 8(ptr) Variable Output
|
||||
10: TypeInt 32 1
|
||||
11: TypeVector 10(int) 2
|
||||
12: TypePointer Input 11(ivec2)
|
||||
13(gl_FragmentSizeNV): 12(ptr) Variable Input
|
||||
16: TypePointer Output 10(int)
|
||||
17(InvocationsPerPixel): 16(ptr) Variable Output
|
||||
18: TypePointer Input 10(int)
|
||||
19(gl_InvocationsPerPixelNV): 18(ptr) Variable Input
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
14: 11(ivec2) Load 13(gl_FragmentSizeNV)
|
||||
15: 7(fvec2) ConvertSToF 14
|
||||
Store 9(FragmentSize) 15
|
||||
20: 10(int) Load 19(gl_InvocationsPerPixelNV)
|
||||
Store 17(InvocationsPerPixel) 20
|
||||
Return
|
||||
FunctionEnd
|
11
Test/spv.shadingRate.frag
Normal file
11
Test/spv.shadingRate.frag
Normal file
@ -0,0 +1,11 @@
|
||||
#version 450
|
||||
|
||||
#extension GL_NV_shading_rate_image : require
|
||||
|
||||
layout (location = 0) out vec2 FragmentSize;
|
||||
layout (location = 2) out int InvocationsPerPixel;
|
||||
|
||||
void main () {
|
||||
FragmentSize = gl_FragmentSizeNV;
|
||||
InvocationsPerPixel = gl_InvocationsPerPixelNV;
|
||||
}
|
@ -237,6 +237,8 @@ enum TBuiltInVariable {
|
||||
EbvPositionPerViewNV,
|
||||
EbvViewportMaskPerViewNV,
|
||||
EbvFragFullyCoveredNV,
|
||||
EbvFragmentSizeNV,
|
||||
EbvInvocationsPerPixelNV,
|
||||
// raytracing
|
||||
EbvLaunchIdNV,
|
||||
EbvLaunchSizeNV,
|
||||
@ -404,6 +406,8 @@ __inline const char* GetBuiltInVariableString(TBuiltInVariable v)
|
||||
case EbvPositionPerViewNV: return "PositionPerViewNV";
|
||||
case EbvViewportMaskPerViewNV: return "ViewportMaskPerViewNV";
|
||||
case EbvFragFullyCoveredNV: return "FragFullyCoveredNV";
|
||||
case EbvFragmentSizeNV: return "FragmentSizeNV";
|
||||
case EbvInvocationsPerPixelNV: return "InvocationsPerPixelNV";
|
||||
case EbvLaunchIdNV: return "LaunchIdNVX";
|
||||
case EbvLaunchSizeNV: return "LaunchSizeNVX";
|
||||
case EbvInstanceCustomIndexNV: return "InstanceCustomIndexNVX";
|
||||
|
@ -5949,6 +5949,8 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
);
|
||||
if (version >= 450)
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"flat in ivec2 gl_FragmentSizeNV;"
|
||||
"flat in int gl_InvocationsPerPixelNV;"
|
||||
"in vec3 gl_BaryCoordNV;"
|
||||
"in vec3 gl_BaryCoordNoPerspNV;"
|
||||
);
|
||||
@ -5995,6 +5997,11 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
|
||||
"highp float gl_FragDepthEXT;" // GL_EXT_frag_depth
|
||||
);
|
||||
#ifdef NV_EXTENSIONS
|
||||
if (version >= 320)
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"flat in ivec2 gl_FragmentSizeNV;"
|
||||
"flat in int gl_InvocationsPerPixelNV;"
|
||||
);
|
||||
if (version >= 320)
|
||||
stageBuiltins[EShLangFragment].append(
|
||||
"in vec3 gl_BaryCoordNV;"
|
||||
@ -8286,6 +8293,10 @@ void TBuiltIns::identifyBuiltIns(int version, EProfile profile, const SpvVersion
|
||||
}
|
||||
if ((profile != EEsProfile && version >= 450) ||
|
||||
(profile == EEsProfile && version >= 320)) {
|
||||
symbolTable.setVariableExtensions("gl_FragmentSizeNV", 1, &E_GL_NV_shading_rate_image);
|
||||
symbolTable.setVariableExtensions("gl_InvocationsPerPixelNV", 1, &E_GL_NV_shading_rate_image);
|
||||
BuiltInVariable("gl_FragmentSizeNV", EbvFragmentSizeNV, symbolTable);
|
||||
BuiltInVariable("gl_InvocationsPerPixelNV", EbvInvocationsPerPixelNV, symbolTable);
|
||||
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);
|
||||
|
@ -235,6 +235,7 @@ void TParseVersions::initializeExtensionBehavior()
|
||||
extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shader_noperspective_interpolation] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shader_subgroup_partitioned] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_shading_rate_image] = EBhDisable;
|
||||
extensionBehavior[E_GL_NVX_raytracing] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_fragment_shader_barycentric] = EBhDisable;
|
||||
extensionBehavior[E_GL_NV_compute_shader_derivatives] = EBhDisable;
|
||||
@ -410,6 +411,7 @@ void TParseVersions::getPreamble(std::string& preamble)
|
||||
"#define GL_NV_shader_atomic_int64 1\n"
|
||||
"#define GL_NV_conservative_raster_underestimation 1\n"
|
||||
"#define GL_NV_shader_subgroup_partitioned 1\n"
|
||||
"#define GL_NV_shading_rate_image 1\n"
|
||||
"#define GL_NVX_raytracing 1\n"
|
||||
"#define GL_NV_fragment_shader_barycentric 1\n"
|
||||
"#define GL_NV_compute_shader_derivatives 1\n"
|
||||
|
@ -207,6 +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_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_shading_rate_image = "GL_NV_shading_rate_image";
|
||||
const char* const E_GL_NVX_raytracing = "GL_NVX_raytracing";
|
||||
const char* const E_GL_NV_fragment_shader_barycentric = "GL_NV_fragment_shader_barycentric";
|
||||
const char* const E_GL_NV_compute_shader_derivatives = "GL_NV_compute_shader_derivatives";
|
||||
|
@ -501,6 +501,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.multiviewPerViewAttributes.vert",
|
||||
"spv.multiviewPerViewAttributes.tesc",
|
||||
"spv.atomicInt64.comp",
|
||||
"spv.shadingRate.frag",
|
||||
"spv.RayGenShader.rgen",
|
||||
"spv.RayGenShader_Errors.rgen",
|
||||
"spv.RayConstants.rgen",
|
||||
|
Loading…
Reference in New Issue
Block a user