Add-support-for-SPV_NV_compute_shader_derivatives

This commit is contained in:
Chao Chen
2018-09-19 11:40:45 -07:00
parent 9eada4b971
commit beae2251b7
14 changed files with 1257 additions and 154 deletions

View File

@@ -33,7 +33,7 @@ enum Op;
enum Capability;
static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 6;
static const int GLSLextNVRevision = 7;
//SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
@@ -57,4 +57,7 @@ const char* const E_SPV_NV_shader_subgroup_partitioned = "SPV_NV_shader_subgroup
//SPV_NV_fragment_shader_barycentric
const char* const E_SPV_NV_fragment_shader_barycentric = "SPV_NV_fragment_shader_barycentric";
//SPV_NV_compute_shader_derivatives
const char* const E_SPV_NV_compute_shader_derivatives = "SPV_NV_compute_shader_derivatives";
#endif // #ifndef GLSLextNV_H

View File

@@ -1300,6 +1300,17 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const gl
builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSize(0),
glslangIntermediate->getLocalSize(1),
glslangIntermediate->getLocalSize(2));
#ifdef NV_EXTENSIONS
if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupQuads) {
builder.addCapability(spv::CapabilityComputeDerivativeGroupQuadsNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeDerivativeGroupQuadsNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
} else if (glslangIntermediate->getLayoutDerivativeModeNone() == glslang::LayoutDerivativeGroupLinear) {
builder.addCapability(spv::CapabilityComputeDerivativeGroupLinearNV);
builder.addExecutionMode(shaderEntry, spv::ExecutionModeDerivativeGroupLinearNV);
builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives);
}
#endif
break;
default:
@@ -4093,7 +4104,13 @@ spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermO
if (cracked.lod) {
params.lod = arguments[2 + extraArgs];
++extraArgs;
} else if (glslangIntermediate->getStage() != EShLangFragment) {
} else if (glslangIntermediate->getStage() != EShLangFragment
#ifdef NV_EXTENSIONS
// NV_compute_shader_derivatives layout qualifiers allow for implicit LODs
&& !(glslangIntermediate->getStage() == EShLangCompute &&
(glslangIntermediate->getLayoutDerivativeModeNone() != glslang::LayoutDerivativeNone))
#endif
) {
// we need to invent the default lod for an explicit lod instruction for a non-fragment stage
noImplicitLod = true;
}

View File

@@ -166,6 +166,12 @@ const char* ExecutionModeString(int mode)
case 32: return "Bad";
case 4446: return "PostDepthCoverage";
#ifdef NV_EXTENSIONS
case ExecutionModeDerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV";
case ExecutionModeDerivativeGroupLinearNV: return "DerivativeGroupLinearNV";
#endif
case ExecutionModeCeiling:
default: return "Bad";
}
@@ -823,13 +829,15 @@ const char* CapabilityString(int info)
case CapabilitySampleMaskPostDepthCoverage: return "SampleMaskPostDepthCoverage";
#ifdef NV_EXTENSIONS
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
case CapabilityShaderViewportIndexLayerNV: return "ShaderViewportIndexLayerNV";
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
case CapabilityShaderViewportIndexLayerNV: return "ShaderViewportIndexLayerNV";
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV";
case CapabilityComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV";
case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
#endif
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";