mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-25 04:50:04 +00:00
Add support for Nvidia Turing extensions
This commit is contained in:
parent
9fbcce4ca1
commit
6e2dab2ffd
@ -324,6 +324,7 @@ int32_t spvOpcodeGeneratesType(SpvOp op) {
|
||||
case SpvOpTypePipe:
|
||||
case SpvOpTypePipeStorage:
|
||||
case SpvOpTypeNamedBarrier:
|
||||
case SpvOpTypeAccelerationStructureNVX:
|
||||
return true;
|
||||
default:
|
||||
// In particular, OpTypeForwardPointer does not generate a type,
|
||||
|
@ -749,6 +749,12 @@ void AggressiveDCEPass::InitExtensions() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -573,6 +573,12 @@ void CommonUniformElimPass::InitExtensions() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -339,6 +339,12 @@ void LocalAccessChainConvertPass::InitExtensions() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -248,6 +248,12 @@ void LocalSingleBlockLoadStoreElimPass::InitExtensions() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,12 @@ void LocalSingleStoreElimPass::InitExtensionWhiteList() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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) {
|
||||
|
@ -98,6 +98,12 @@ void LocalMultiStoreElimPass::InitExtensions() {
|
||||
"SPV_GOOGLE_hlsl_functionality1",
|
||||
"SPV_NV_shader_subgroup_partitioned",
|
||||
"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",
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,9 @@ spv_result_t BarriersPass(ValidationState_t& _, const Instruction* inst) {
|
||||
[](SpvExecutionModel model, std::string* message) {
|
||||
if (model != SpvExecutionModelTessellationControl &&
|
||||
model != SpvExecutionModelGLCompute &&
|
||||
model != SpvExecutionModelKernel) {
|
||||
model != SpvExecutionModelKernel &&
|
||||
model != SpvExecutionModelTaskNV &&
|
||||
model != SpvExecutionModelMeshNV) {
|
||||
if (message) {
|
||||
*message =
|
||||
"OpControlBarrier requires one of the following "
|
||||
|
@ -863,7 +863,8 @@ spv_result_t BuiltInsValidator::ValidateClipOrCullDistanceAtReference(
|
||||
}
|
||||
case SpvExecutionModelTessellationControl:
|
||||
case SpvExecutionModelTessellationEvaluation:
|
||||
case SpvExecutionModelGeometry: {
|
||||
case SpvExecutionModelGeometry:
|
||||
case SpvExecutionModelMeshNV: {
|
||||
if (decoration.struct_member_index() != Decoration::kInvalidMember) {
|
||||
// The outer level of array is applied on the variable.
|
||||
if (spv_result_t error = ValidateF32Arr(
|
||||
@ -1445,7 +1446,8 @@ spv_result_t BuiltInsValidator::ValidatePointSizeAtReference(
|
||||
}
|
||||
case SpvExecutionModelTessellationControl:
|
||||
case SpvExecutionModelTessellationEvaluation:
|
||||
case SpvExecutionModelGeometry: {
|
||||
case SpvExecutionModelGeometry:
|
||||
case SpvExecutionModelMeshNV: {
|
||||
// PointSize can be a per-vertex variable for tessellation control,
|
||||
// tessellation evaluation and geometry shader stages. In such cases
|
||||
// variables will have an array of 32-bit floats.
|
||||
@ -1556,10 +1558,12 @@ spv_result_t BuiltInsValidator::ValidatePositionAtReference(
|
||||
}
|
||||
case SpvExecutionModelGeometry:
|
||||
case SpvExecutionModelTessellationControl:
|
||||
case SpvExecutionModelTessellationEvaluation: {
|
||||
case SpvExecutionModelTessellationEvaluation:
|
||||
case SpvExecutionModelMeshNV: {
|
||||
// Position can be a per-vertex variable for tessellation control,
|
||||
// tessellation evaluation and geometry shader stages. In such cases
|
||||
// variables will have an array of 4-component 32-bit float vectors.
|
||||
// tessellation evaluation, geometry and mesh shader stages. In such
|
||||
// cases variables will have an array of 4-component 32-bit float
|
||||
// vectors.
|
||||
if (decoration.struct_member_index() != Decoration::kInvalidMember) {
|
||||
// The array is on the variable, so this must be a 4-component
|
||||
// 32-bit float vector.
|
||||
@ -1682,7 +1686,13 @@ spv_result_t BuiltInsValidator::ValidatePrimitiveIdAtReference(
|
||||
case SpvExecutionModelFragment:
|
||||
case SpvExecutionModelTessellationControl:
|
||||
case SpvExecutionModelTessellationEvaluation:
|
||||
case SpvExecutionModelGeometry: {
|
||||
case SpvExecutionModelGeometry:
|
||||
case SpvExecutionModelMeshNV:
|
||||
case SpvExecutionModelRayGenerationNVX:
|
||||
case SpvExecutionModelIntersectionNVX:
|
||||
case SpvExecutionModelAnyHitNVX:
|
||||
case SpvExecutionModelClosestHitNVX:
|
||||
case SpvExecutionModelMissNVX: {
|
||||
// Ok.
|
||||
break;
|
||||
}
|
||||
@ -2187,7 +2197,8 @@ spv_result_t BuiltInsValidator::ValidateLayerOrViewportIndexAtReference(
|
||||
for (const SpvExecutionModel execution_model : execution_models_) {
|
||||
switch (execution_model) {
|
||||
case SpvExecutionModelGeometry:
|
||||
case SpvExecutionModelFragment: {
|
||||
case SpvExecutionModelFragment:
|
||||
case SpvExecutionModelMeshNV: {
|
||||
// Ok.
|
||||
break;
|
||||
case SpvExecutionModelVertex:
|
||||
@ -2270,7 +2281,9 @@ spv_result_t BuiltInsValidator::ValidateComputeShaderI32Vec3InputAtReference(
|
||||
}
|
||||
|
||||
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)
|
||||
<< "Vulkan spec allows BuiltIn "
|
||||
<< _.grammar().lookupOperandName(SPV_OPERAND_TYPE_BUILT_IN,
|
||||
@ -2464,7 +2477,32 @@ spv_result_t BuiltInsValidator::ValidateSingleBuiltInAtDefinition(
|
||||
case SpvBuiltInPositionPerViewNV:
|
||||
case SpvBuiltInViewportMaskPerViewNV:
|
||||
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).
|
||||
break;
|
||||
}
|
||||
|
@ -54,12 +54,36 @@ spv_result_t DerivativesPass(ValidationState_t& _, const Instruction* inst) {
|
||||
<< spvOpcodeString(opcode);
|
||||
}
|
||||
|
||||
_.function(inst->function()->id())
|
||||
->RegisterExecutionModelLimitation(
|
||||
SpvExecutionModelFragment,
|
||||
std::string("Derivative instructions require Fragment execution "
|
||||
const spvtools::Extension compute_shader_derivatives_extension =
|
||||
kSPV_NV_compute_shader_derivatives;
|
||||
ExtensionSet exts(1, &compute_shader_derivatives_extension);
|
||||
|
||||
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: ") +
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -161,9 +161,10 @@ INSTANTIATE_TEST_CASE_P(
|
||||
Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeQuads, Tessellation),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeIsolines, Tessellation),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry,
|
||||
Tessellation),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry),
|
||||
CASE3(EXECUTION_MODE, ExecutionModeOutputVertices, Geometry,
|
||||
Tessellation, MeshShadingNV),
|
||||
CASE2(EXECUTION_MODE, ExecutionModeOutputPoints, Geometry,
|
||||
MeshShadingNV),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputLineStrip, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeOutputTriangleStrip, Geometry),
|
||||
CASE1(EXECUTION_MODE, ExecutionModeVecTypeHint, Kernel),
|
||||
@ -490,7 +491,8 @@ INSTANTIATE_TEST_CASE_P(
|
||||
CASE1(BUILT_IN, BuiltInCullDistance, CullDistance), // Bug 1407, 15234
|
||||
CASE1(BUILT_IN, BuiltInVertexId, 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),
|
||||
CASE1(BUILT_IN, BuiltInLayer, Geometry),
|
||||
CASE1(BUILT_IN, BuiltInViewportIndex, MultiViewport), // Bug 15234
|
||||
|
Loading…
Reference in New Issue
Block a user