Add support for Nvidia Turing extensions

This commit is contained in:
Chao Chen 2018-09-19 11:53:33 -07:00 committed by David Neto
parent 9fbcce4ca1
commit 6e2dab2ffd
11 changed files with 122 additions and 19 deletions

View File

@ -324,6 +324,7 @@ int32_t spvOpcodeGeneratesType(SpvOp op) {
case SpvOpTypePipe: case SpvOpTypePipe:
case SpvOpTypePipeStorage: case SpvOpTypePipeStorage:
case SpvOpTypeNamedBarrier: case SpvOpTypeNamedBarrier:
case SpvOpTypeAccelerationStructureNVX:
return true; return true;
default: default:
// In particular, OpTypeForwardPointer does not generate a type, // In particular, OpTypeForwardPointer does not generate a type,

View File

@ -749,6 +749,12 @@ void AggressiveDCEPass::InitExtensions() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }

View File

@ -573,6 +573,12 @@ void CommonUniformElimPass::InitExtensions() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }

View File

@ -339,6 +339,12 @@ void LocalAccessChainConvertPass::InitExtensions() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }

View File

@ -248,6 +248,12 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }

View File

@ -113,6 +113,12 @@ void LocalSingleStoreElimPass::InitExtensionWhiteList() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }
bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) { bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) {

View File

@ -98,6 +98,12 @@ void LocalMultiStoreElimPass::InitExtensions() {
"SPV_GOOGLE_hlsl_functionality1", "SPV_GOOGLE_hlsl_functionality1",
"SPV_NV_shader_subgroup_partitioned", "SPV_NV_shader_subgroup_partitioned",
"SPV_EXT_descriptor_indexing", "SPV_EXT_descriptor_indexing",
"SPV_NV_fragment_shader_barycentric",
"SPV_NV_compute_shader_derivatives",
"SPV_NV_shader_image_footprint",
"SPV_NV_shading_rate",
"SPV_NV_mesh_shader",
"SPV_NVX_raytracing",
}); });
} }

View File

@ -206,7 +206,9 @@ spv_result_t BarriersPass(ValidationState_t& _, const Instruction* inst) {
[](SpvExecutionModel model, std::string* message) { [](SpvExecutionModel model, std::string* message) {
if (model != SpvExecutionModelTessellationControl && if (model != SpvExecutionModelTessellationControl &&
model != SpvExecutionModelGLCompute && model != SpvExecutionModelGLCompute &&
model != SpvExecutionModelKernel) { model != SpvExecutionModelKernel &&
model != SpvExecutionModelTaskNV &&
model != SpvExecutionModelMeshNV) {
if (message) { if (message) {
*message = *message =
"OpControlBarrier requires one of the following " "OpControlBarrier requires one of the following "

View File

@ -863,7 +863,8 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference(
} }
case SpvExecutionModelTessellationControl: case SpvExecutionModelTessellationControl:
case SpvExecutionModelTessellationEvaluation: case SpvExecutionModelTessellationEvaluation:
case SpvExecutionModelGeometry: { case SpvExecutionModelGeometry:
case SpvExecutionModelMeshNV: {
if (decoration.struct_member_index() != Decoration::kInvalidMember) { if (decoration.struct_member_index() != Decoration::kInvalidMember) {
// The outer level of array is applied on the variable. // The outer level of array is applied on the variable.
if (spv_result_t error = ValidateF32Arr( if (spv_result_t error = ValidateF32Arr(
@ -1445,7 +1446,8 @@ spv_result_t BuiltInsValidator::ValidatePointSizeAtReference(
} }
case SpvExecutionModelTessellationControl: case SpvExecutionModelTessellationControl:
case SpvExecutionModelTessellationEvaluation: case SpvExecutionModelTessellationEvaluation:
case SpvExecutionModelGeometry: { case SpvExecutionModelGeometry:
case SpvExecutionModelMeshNV: {
// PointSize can be a per-vertex variable for tessellation control, // PointSize can be a per-vertex variable for tessellation control,
// tessellation evaluation and geometry shader stages. In such cases // tessellation evaluation and geometry shader stages. In such cases
// variables will have an array of 32-bit floats. // variables will have an array of 32-bit floats.
@ -1556,10 +1558,12 @@ spv_result_t BuiltInsValidator::ValidatePositionAtReference(
} }
case SpvExecutionModelGeometry: case SpvExecutionModelGeometry:
case SpvExecutionModelTessellationControl: case SpvExecutionModelTessellationControl:
case SpvExecutionModelTessellationEvaluation: { case SpvExecutionModelTessellationEvaluation:
case SpvExecutionModelMeshNV: {
// Position can be a per-vertex variable for tessellation control, // Position can be a per-vertex variable for tessellation control,
// tessellation evaluation and geometry shader stages. In such cases // tessellation evaluation, geometry and mesh shader stages. In such
// variables will have an array of 4-component 32-bit float vectors. // cases variables will have an array of 4-component 32-bit float
// vectors.
if (decoration.struct_member_index() != Decoration::kInvalidMember) { if (decoration.struct_member_index() != Decoration::kInvalidMember) {
// The array is on the variable, so this must be a 4-component // The array is on the variable, so this must be a 4-component
// 32-bit float vector. // 32-bit float vector.
@ -1682,7 +1686,13 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveIdAtReference(
case SpvExecutionModelFragment: case SpvExecutionModelFragment:
case SpvExecutionModelTessellationControl: case SpvExecutionModelTessellationControl:
case SpvExecutionModelTessellationEvaluation: case SpvExecutionModelTessellationEvaluation:
case SpvExecutionModelGeometry: { case SpvExecutionModelGeometry:
case SpvExecutionModelMeshNV:
case SpvExecutionModelRayGenerationNVX:
case SpvExecutionModelIntersectionNVX:
case SpvExecutionModelAnyHitNVX:
case SpvExecutionModelClosestHitNVX:
case SpvExecutionModelMissNVX: {
// Ok. // Ok.
break; break;
} }
@ -2187,7 +2197,8 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference(
for (const SpvExecutionModel execution_model : execution_models_) { for (const SpvExecutionModel execution_model : execution_models_) {
switch (execution_model) { switch (execution_model) {
case SpvExecutionModelGeometry: case SpvExecutionModelGeometry:
case SpvExecutionModelFragment: { case SpvExecutionModelFragment:
case SpvExecutionModelMeshNV: {
// Ok. // Ok.
break; break;
case SpvExecutionModelVertex: case SpvExecutionModelVertex:
@ -2270,7 +2281,9 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference(
} }
for (const SpvExecutionModel execution_model : execution_models_) { for (const SpvExecutionModel execution_model : execution_models_) {
if (execution_model != SpvExecutionModelGLCompute) { if (execution_model != SpvExecutionModelGLCompute &&
execution_model != SpvExecutionModelTaskNV &&
execution_model != SpvExecutionModelMeshNV) {
return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst) return _.diag(SPV_ERROR_INVALID_DATA, &referenced_from_inst)
<< "Vulkan spec allows BuiltIn " << "Vulkan spec allows BuiltIn "
<< _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN, << _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
@ -2464,7 +2477,32 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition(
case SpvBuiltInPositionPerViewNV: case SpvBuiltInPositionPerViewNV:
case SpvBuiltInViewportMaskPerViewNV: case SpvBuiltInViewportMaskPerViewNV:
case SpvBuiltInFullyCoveredEXT: case SpvBuiltInFullyCoveredEXT:
case SpvBuiltInMax: { case SpvBuiltInMax:
case SpvBuiltInTaskCountNV:
case SpvBuiltInPrimitiveCountNV:
case SpvBuiltInPrimitiveIndicesNV:
case SpvBuiltInClipDistancePerViewNV:
case SpvBuiltInCullDistancePerViewNV:
case SpvBuiltInLayerPerViewNV:
case SpvBuiltInMeshViewCountNV:
case SpvBuiltInMeshViewIndicesNV:
case SpvBuiltInBaryCoordNV:
case SpvBuiltInBaryCoordNoPerspNV:
case SpvBuiltInFragmentSizeNV:
case SpvBuiltInInvocationsPerPixelNV:
case SpvBuiltInLaunchIdNVX:
case SpvBuiltInLaunchSizeNVX:
case SpvBuiltInWorldRayOriginNVX:
case SpvBuiltInWorldRayDirectionNVX:
case SpvBuiltInObjectRayOriginNVX:
case SpvBuiltInObjectRayDirectionNVX:
case SpvBuiltInRayTminNVX:
case SpvBuiltInRayTmaxNVX:
case SpvBuiltInInstanceCustomIndexNVX:
case SpvBuiltInObjectToWorldNVX:
case SpvBuiltInWorldToObjectNVX:
case SpvBuiltInHitTNVX:
case SpvBuiltInHitKindNVX: {
// No validation rules (for the moment). // No validation rules (for the moment).
break; break;
} }

View File

@ -54,12 +54,36 @@ spv_result_t DerivativesPass(ValidationState_t& _, const Instruction* inst) {
<< spvOpcodeString(opcode); << spvOpcodeString(opcode);
} }
_.function(inst->function()->id()) const spvtools::Extension compute_shader_derivatives_extension =
->RegisterExecutionModelLimitation( kSPV_NV_compute_shader_derivatives;
SpvExecutionModelFragment, ExtensionSet exts(1, &compute_shader_derivatives_extension);
std::string("Derivative instructions require Fragment execution "
if (_.HasAnyOfExtensions(exts)) {
_.function(inst->function()->id())
->RegisterExecutionModelLimitation([opcode](SpvExecutionModel model,
std::string* message) {
if (model != SpvExecutionModelFragment &&
model != SpvExecutionModelGLCompute) {
if (message) {
*message =
std::string(
"Derivative instructions require Fragment execution "
"model: ") + "model: ") +
spvOpcodeString(opcode)); spvOpcodeString(opcode);
}
return false;
}
return true;
});
} else {
_.function(inst->function()->id())
->RegisterExecutionModelLimitation(
SpvExecutionModelFragment,
std::string(
"Derivative instructions require Fragment execution "
"model: ") +
spvOpcodeString(opcode));
}
break; break;
} }

View File

@ -161,9 +161,10 @@ INSTANTIATE_TEST_CASE_P(
Geometry), Geometry),
CASE1(EXECUTION_MODE, ExecutionModeQuads, Tessellation), CASE1(EXECUTION_MODE, ExecutionModeQuads, Tessellation),
CASE1(EXECUTION_MODE, ExecutionModeIsolines, Tessellation), CASE1(EXECUTION_MODE, ExecutionModeIsolines, Tessellation),
CASE2(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry, CASE3(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry,
Tessellation), Tessellation, MeshShadingNV),
CASE1(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry), CASE2(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry,
MeshShadingNV),
CASE1(EXECUTION_MODE, ExecutionModeOutputLineStrip, Geometry), CASE1(EXECUTION_MODE, ExecutionModeOutputLineStrip, Geometry),
CASE1(EXECUTION_MODE, ExecutionModeOutputTriangleStrip, Geometry), CASE1(EXECUTION_MODE, ExecutionModeOutputTriangleStrip, Geometry),
CASE1(EXECUTION_MODE, ExecutionModeVecTypeHint, Kernel), CASE1(EXECUTION_MODE, ExecutionModeVecTypeHint, Kernel),
@ -490,7 +491,8 @@ INSTANTIATE_TEST_CASE_P(
CASE1(BUILT_IN, BuiltInCullDistance, CullDistance), // Bug 1407, 15234 CASE1(BUILT_IN, BuiltInCullDistance, CullDistance), // Bug 1407, 15234
CASE1(BUILT_IN, BuiltInVertexId, Shader), CASE1(BUILT_IN, BuiltInVertexId, Shader),
CASE1(BUILT_IN, BuiltInInstanceId, Shader), CASE1(BUILT_IN, BuiltInInstanceId, Shader),
CASE2(BUILT_IN, BuiltInPrimitiveId, Geometry, Tessellation), CASE3(BUILT_IN, BuiltInPrimitiveId, Geometry, Tessellation,
RaytracingNVX),
CASE2(BUILT_IN, BuiltInInvocationId, Geometry, Tessellation), CASE2(BUILT_IN, BuiltInInvocationId, Geometry, Tessellation),
CASE1(BUILT_IN, BuiltInLayer, Geometry), CASE1(BUILT_IN, BuiltInLayer, Geometry),
CASE1(BUILT_IN, BuiltInViewportIndex, MultiViewport), // Bug 15234 CASE1(BUILT_IN, BuiltInViewportIndex, MultiViewport), // Bug 15234