Multiple features and misc fixes for final raytracing non experimental version.

This commit is contained in:
Ashwin Lele
2018-10-22 16:41:44 -07:00
parent b2b3d81e9b
commit ff1783db87
48 changed files with 5168 additions and 4850 deletions

View File

@@ -66,8 +66,8 @@ const char* const E_SPV_NV_shader_image_footprint = "SPV_NV_shader_image_footpri
//SPV_NV_mesh_shader
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_raytracing
const char* const E_SPV_NV_ray_tracing = "SPV_NV_ray_tracing";
//SPV_NV_shading_rate
const char* const E_SPV_NV_shading_rate = "SPV_NV_shading_rate";

View File

@@ -276,12 +276,12 @@ spv::ExecutionModel TranslateExecutionModel(EShLanguage stage)
case EShLangFragment: return spv::ExecutionModelFragment;
case EShLangCompute: return spv::ExecutionModelGLCompute;
#ifdef NV_EXTENSIONS
case EShLangRayGenNV: return spv::ExecutionModelRayGenerationNVX;
case EShLangIntersectNV: return spv::ExecutionModelIntersectionNVX;
case EShLangAnyHitNV: return spv::ExecutionModelAnyHitNVX;
case EShLangClosestHitNV: return spv::ExecutionModelClosestHitNVX;
case EShLangMissNV: return spv::ExecutionModelMissNVX;
case EShLangCallableNV: return spv::ExecutionModelCallableNVX;
case EShLangRayGenNV: return spv::ExecutionModelRayGenerationNV;
case EShLangIntersectNV: return spv::ExecutionModelIntersectionNV;
case EShLangAnyHitNV: return spv::ExecutionModelAnyHitNV;
case EShLangClosestHitNV: return spv::ExecutionModelClosestHitNV;
case EShLangMissNV: return spv::ExecutionModelMissNV;
case EShLangCallableNV: return spv::ExecutionModelCallableNV;
case EShLangTaskNV: return spv::ExecutionModelTaskNV;
case EShLangMeshNV: return spv::ExecutionModelMeshNV;
#endif
@@ -338,6 +338,8 @@ spv::Decoration TranslateBlockDecoration(const glslang::TType& type, bool useSto
case glslang::EvqPayloadNV: return spv::DecorationBlock;
case glslang::EvqPayloadInNV: return spv::DecorationBlock;
case glslang::EvqHitAttrNV: return spv::DecorationBlock;
case glslang::EvqCallableDataNV: return spv::DecorationBlock;
case glslang::EvqCallableDataInNV: return spv::DecorationBlock;
#endif
default:
assert(0);
@@ -411,6 +413,8 @@ spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::T
case glslang::EvqPayloadNV:
case glslang::EvqPayloadInNV:
case glslang::EvqHitAttrNV:
case glslang::EvqCallableDataNV:
case glslang::EvqCallableDataInNV:
return spv::DecorationMax;
#endif
default:
@@ -875,31 +879,33 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
// raytracing
case glslang::EbvLaunchIdNV:
return spv::BuiltInLaunchIdNVX;
return spv::BuiltInLaunchIdNV;
case glslang::EbvLaunchSizeNV:
return spv::BuiltInLaunchSizeNVX;
return spv::BuiltInLaunchSizeNV;
case glslang::EbvWorldRayOriginNV:
return spv::BuiltInWorldRayOriginNVX;
return spv::BuiltInWorldRayOriginNV;
case glslang::EbvWorldRayDirectionNV:
return spv::BuiltInWorldRayDirectionNVX;
return spv::BuiltInWorldRayDirectionNV;
case glslang::EbvObjectRayOriginNV:
return spv::BuiltInObjectRayOriginNVX;
return spv::BuiltInObjectRayOriginNV;
case glslang::EbvObjectRayDirectionNV:
return spv::BuiltInObjectRayDirectionNVX;
return spv::BuiltInObjectRayDirectionNV;
case glslang::EbvRayTminNV:
return spv::BuiltInRayTminNVX;
return spv::BuiltInRayTminNV;
case glslang::EbvRayTmaxNV:
return spv::BuiltInRayTmaxNVX;
return spv::BuiltInRayTmaxNV;
case glslang::EbvInstanceCustomIndexNV:
return spv::BuiltInInstanceCustomIndexNVX;
return spv::BuiltInInstanceCustomIndexNV;
case glslang::EbvHitTNV:
return spv::BuiltInHitTNVX;
return spv::BuiltInHitTNV;
case glslang::EbvHitKindNV:
return spv::BuiltInHitKindNVX;
return spv::BuiltInHitKindNV;
case glslang::EbvObjectToWorldNV:
return spv::BuiltInObjectToWorldNVX;
return spv::BuiltInObjectToWorldNV;
case glslang::EbvWorldToObjectNV:
return spv::BuiltInWorldToObjectNVX;
return spv::BuiltInWorldToObjectNV;
case glslang::EbvIncomingRayFlagsNV:
return spv::BuiltInIncomingRayFlagsNV;
case glslang::EbvBaryCoordNV:
builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
builder.addCapability(spv::CapabilityFragmentBarycentricNV);
@@ -1082,7 +1088,7 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
return spv::StorageClassPushConstant;
#ifdef NV_EXTENSIONS
if (type.getQualifier().layoutShaderRecordNV)
return spv::StorageClassShaderRecordBufferNVX;
return spv::StorageClassShaderRecordBufferNV;
#endif
if (type.getBasicType() == glslang::EbtBlock)
return spv::StorageClassUniform;
@@ -1095,9 +1101,11 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
case glslang::EvqConstReadOnly: return spv::StorageClassFunction;
case glslang::EvqTemporary: return spv::StorageClassFunction;
#ifdef NV_EXTENSIONS
case glslang::EvqPayloadNV: return spv::StorageClassRayPayloadNVX;
case glslang::EvqPayloadInNV: return spv::StorageClassIncomingRayPayloadNVX;
case glslang::EvqHitAttrNV: return spv::StorageClassHitAttributeNVX;
case glslang::EvqPayloadNV: return spv::StorageClassRayPayloadNV;
case glslang::EvqPayloadInNV: return spv::StorageClassIncomingRayPayloadNV;
case glslang::EvqHitAttrNV: return spv::StorageClassHitAttributeNV;
case glslang::EvqCallableDataNV: return spv::StorageClassCallableDataNV;
case glslang::EvqCallableDataInNV: return spv::StorageClassIncomingCallableDataNV;
#endif
default:
assert(0);
@@ -1430,8 +1438,8 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const gl
case EShLangClosestHitNV:
case EShLangMissNV:
case EShLangCallableNV:
builder.addCapability(spv::CapabilityRaytracingNVX);
builder.addExtension("SPV_NVX_raytracing");
builder.addCapability(spv::CapabilityRayTracingNV);
builder.addExtension("SPV_NV_ray_tracing");
break;
case EShLangTaskNV:
case EShLangMeshNV:
@@ -2267,6 +2275,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
case glslang::EOpIgnoreIntersectionNV:
case glslang::EOpTerminateRayNV:
case glslang::EOpTraceNV:
case glslang::EOpExecuteCallableNV:
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
noReturnValue = true;
break;
@@ -6871,12 +6880,18 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
case glslang::EOpReportIntersectionNV:
{
typeId = builder.makeBoolType();
opCode = spv::OpReportIntersectionNVX;
opCode = spv::OpReportIntersectionNV;
}
break;
case glslang::EOpTraceNV:
{
builder.createNoResultOp(spv::OpTraceNVX, operands);
builder.createNoResultOp(spv::OpTraceNV, operands);
return 0;
}
break;
case glslang::EOpExecuteCallableNV:
{
builder.createNoResultOp(spv::OpExecuteCallableNV, operands);
return 0;
}
break;
@@ -7060,10 +7075,10 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv:
#endif
#ifdef NV_EXTENSIONS
case glslang::EOpIgnoreIntersectionNV:
builder.createNoResultOp(spv::OpIgnoreIntersectionNVX);
builder.createNoResultOp(spv::OpIgnoreIntersectionNV);
return 0;
case glslang::EOpTerminateRayNV:
builder.createNoResultOp(spv::OpTerminateRayNVX);
builder.createNoResultOp(spv::OpTerminateRayNV);
return 0;
#endif
default:

View File

@@ -507,12 +507,12 @@ Id Builder::makeSampledImageType(Id imageType)
Id Builder::makeAccelerationStructureNVType()
{
Instruction *type;
if (groupedTypes[OpTypeAccelerationStructureNVX].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeAccelerationStructureNVX);
if (groupedTypes[OpTypeAccelerationStructureNV].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeAccelerationStructureNV);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else {
type = groupedTypes[OpTypeAccelerationStructureNVX].back();
type = groupedTypes[OpTypeAccelerationStructureNV].back();
}
return type->getResultId();

View File

@@ -106,12 +106,12 @@ const char* ExecutionModelString(int model)
default: return "Bad";
#ifdef NV_EXTENSIONS
case ExecutionModelRayGenerationNVX: return "RayGenerationNVX";
case ExecutionModelIntersectionNVX: return "IntersectionNVX";
case ExecutionModelAnyHitNVX: return "AnyHitNVX";
case ExecutionModelClosestHitNVX: return "ClosestHitNVX";
case ExecutionModelMissNVX: return "MissNVX";
case ExecutionModelCallableNVX: return "CallableNVX";
case ExecutionModelRayGenerationNV: return "RayGenerationNV";
case ExecutionModelIntersectionNV: return "IntersectionNV";
case ExecutionModelAnyHitNV: return "AnyHitNV";
case ExecutionModelClosestHitNV: return "ClosestHitNV";
case ExecutionModelMissNV: return "MissNV";
case ExecutionModelCallableNV: return "CallableNV";
#endif
}
@@ -212,10 +212,12 @@ const char* StorageClassString(int StorageClass)
case 12: return "StorageBuffer";
#ifdef NV_EXTENSIONS
case StorageClassRayPayloadNVX: return "RayPayloadNVX";
case StorageClassHitAttributeNVX: return "HitAttributeNVX";
case StorageClassIncomingRayPayloadNVX: return "IncomingRayPayloadNVX";
case StorageClassShaderRecordBufferNVX: return "ShaderRecordBufferNVX";
case StorageClassRayPayloadNV: return "RayPayloadNV";
case StorageClassHitAttributeNV: return "HitAttributeNV";
case StorageClassIncomingRayPayloadNV: return "IncomingRayPayloadNV";
case StorageClassShaderRecordBufferNV: return "ShaderRecordBufferNV";
case StorageClassCallableDataNV: return "CallableDataNV";
case StorageClassIncomingCallableDataNV: return "IncomingCallableDataNV";
#endif
default: return "Bad";
@@ -367,19 +369,20 @@ const char* BuiltInString(int builtIn)
#endif
#ifdef NV_EXTENSIONS
case BuiltInLaunchIdNVX: return "LaunchIdNVX";
case BuiltInLaunchSizeNVX: return "LaunchSizeNVX";
case BuiltInWorldRayOriginNVX: return "WorldRayOriginNVX";
case BuiltInWorldRayDirectionNVX: return "WorldRayDirectionNVX";
case BuiltInObjectRayOriginNVX: return "ObjectRayOriginNVX";
case BuiltInObjectRayDirectionNVX: return "ObjectRayDirectionNVX";
case BuiltInRayTminNVX: return "RayTminNVX";
case BuiltInRayTmaxNVX: return "RayTmaxNVX";
case BuiltInInstanceCustomIndexNVX: return "InstanceCustomIndexNVX";
case BuiltInObjectToWorldNVX: return "ObjectToWorldNVX";
case BuiltInWorldToObjectNVX: return "WorldToObjectNVX";
case BuiltInHitTNVX: return "HitTNVX";
case BuiltInHitKindNVX: return "HitKindNVX";
case BuiltInLaunchIdNV: return "LaunchIdNV";
case BuiltInLaunchSizeNV: return "LaunchSizeNV";
case BuiltInWorldRayOriginNV: return "WorldRayOriginNV";
case BuiltInWorldRayDirectionNV: return "WorldRayDirectionNV";
case BuiltInObjectRayOriginNV: return "ObjectRayOriginNV";
case BuiltInObjectRayDirectionNV: return "ObjectRayDirectionNV";
case BuiltInRayTminNV: return "RayTminNV";
case BuiltInRayTmaxNV: return "RayTmaxNV";
case BuiltInInstanceCustomIndexNV: return "InstanceCustomIndexNV";
case BuiltInObjectToWorldNV: return "ObjectToWorldNV";
case BuiltInWorldToObjectNV: return "WorldToObjectNV";
case BuiltInHitTNV: return "HitTNV";
case BuiltInHitKindNV: return "HitKindNV";
case BuiltInIncomingRayFlagsNV: return "IncomingRayFlagsNV";
case BuiltInViewportMaskNV: return "ViewportMaskNV";
case BuiltInSecondaryPositionNV: return "SecondaryPositionNV";
case BuiltInSecondaryViewportMaskNV: return "SecondaryViewportMaskNV";
@@ -889,7 +892,7 @@ const char* CapabilityString(int info)
case CapabilityShaderStereoViewNV: return "ShaderStereoViewNV";
case CapabilityPerViewAttributesNV: return "PerViewAttributesNV";
case CapabilityGroupNonUniformPartitionedNV: return "GroupNonUniformPartitionedNV";
case CapabilityRaytracingNVX: return "RaytracingNVX";
case CapabilityRayTracingNV: return "RayTracingNV";
case CapabilityComputeDerivativeGroupQuadsNV: return "ComputeDerivativeGroupQuadsNV";
case CapabilityComputeDerivativeGroupLinearNV: return "ComputeDerivativeGroupLinearNV";
case CapabilityFragmentBarycentricNV: return "FragmentBarycentricNV";
@@ -1308,11 +1311,12 @@ const char* OpcodeString(int op)
#ifdef NV_EXTENSIONS
case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV";
case OpReportIntersectionNVX: return "OpReportIntersectionNVX";
case OpIgnoreIntersectionNVX: return "OpIgnoreIntersectionNVX";
case OpTerminateRayNVX: return "OpTerminateRayNVX";
case OpTraceNVX: return "OpTraceNVX";
case OpTypeAccelerationStructureNVX: return "OpTypeAccelerationStructureNVX";
case OpReportIntersectionNV: return "OpReportIntersectionNV";
case OpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV";
case OpTerminateRayNV: return "OpTerminateRayNV";
case OpTraceNV: return "OpTraceNV";
case OpTypeAccelerationStructureNV: return "OpTypeAccelerationStructureNV";
case OpExecuteCallableNV: return "OpExecuteCallableNV";
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
#endif
@@ -2662,28 +2666,32 @@ void Parameterize()
#ifdef NV_EXTENSIONS
InstructionDesc[OpGroupNonUniformPartitionNV].operands.push(OperandId, "X");
InstructionDesc[OpTypeAccelerationStructureNVX].setResultAndType(true, false);
InstructionDesc[OpTypeAccelerationStructureNV].setResultAndType(true, false);
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'NV Acceleration Structure'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Ray Flags'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Cull Mask'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'SBT Record Offset'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'SBT Record Stride'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Miss Index'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Ray Origin'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'TMin'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Ray Direction'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'TMax'");
InstructionDesc[OpTraceNVX].operands.push(OperandId, "'Payload'");
InstructionDesc[OpTraceNVX].setResultAndType(false, false);
InstructionDesc[OpTraceNV].operands.push(OperandId, "'NV Acceleration Structure'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Ray Flags'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Cull Mask'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'SBT Record Offset'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'SBT Record Stride'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Miss Index'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Ray Origin'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'TMin'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Ray Direction'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'TMax'");
InstructionDesc[OpTraceNV].operands.push(OperandId, "'Payload'");
InstructionDesc[OpTraceNV].setResultAndType(false, false);
InstructionDesc[OpReportIntersectionNVX].operands.push(OperandId, "'Hit Parameter'");
InstructionDesc[OpReportIntersectionNVX].operands.push(OperandId, "'Hit Kind'");
InstructionDesc[OpReportIntersectionNV].operands.push(OperandId, "'Hit Parameter'");
InstructionDesc[OpReportIntersectionNV].operands.push(OperandId, "'Hit Kind'");
InstructionDesc[OpIgnoreIntersectionNVX].setResultAndType(false, false);
InstructionDesc[OpIgnoreIntersectionNV].setResultAndType(false, false);
InstructionDesc[OpTerminateRayNVX].setResultAndType(false, false);
InstructionDesc[OpTerminateRayNV].setResultAndType(false, false);
InstructionDesc[OpExecuteCallableNV].operands.push(OperandId, "SBT Record Index");
InstructionDesc[OpExecuteCallableNV].operands.push(OperandId, "CallableData ID");
InstructionDesc[OpExecuteCallableNV].setResultAndType(false, false);
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Sampled Image'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Coordinate'");
InstructionDesc[OpImageSampleFootprintNV].operands.push(OperandId, "'Granularity'");

View File

@@ -75,12 +75,12 @@ enum ExecutionModel {
ExecutionModelKernel = 6,
ExecutionModelTaskNV = 5267,
ExecutionModelMeshNV = 5268,
ExecutionModelRayGenerationNVX = 5313,
ExecutionModelIntersectionNVX = 5314,
ExecutionModelAnyHitNVX = 5315,
ExecutionModelClosestHitNVX = 5316,
ExecutionModelMissNVX = 5317,
ExecutionModelCallableNVX = 5318,
ExecutionModelRayGenerationNV = 5313,
ExecutionModelIntersectionNV = 5314,
ExecutionModelAnyHitNV = 5315,
ExecutionModelClosestHitNV = 5316,
ExecutionModelMissNV = 5317,
ExecutionModelCallableNV = 5318,
ExecutionModelMax = 0x7fffffff,
};
@@ -162,10 +162,12 @@ enum StorageClass {
StorageClassAtomicCounter = 10,
StorageClassImage = 11,
StorageClassStorageBuffer = 12,
StorageClassRayPayloadNVX = 5338,
StorageClassHitAttributeNVX = 5339,
StorageClassIncomingRayPayloadNVX = 5342,
StorageClassShaderRecordBufferNVX = 5343,
StorageClassCallableDataNV = 5328,
StorageClassIncomingCallableDataNV = 5329,
StorageClassRayPayloadNV = 5338,
StorageClassHitAttributeNV = 5339,
StorageClassIncomingRayPayloadNV = 5342,
StorageClassShaderRecordBufferNV = 5343,
StorageClassMax = 0x7fffffff,
};
@@ -512,19 +514,20 @@ enum BuiltIn {
BuiltInBaryCoordNoPerspNV = 5287,
BuiltInFragmentSizeNV = 5292,
BuiltInInvocationsPerPixelNV = 5293,
BuiltInLaunchIdNVX = 5319,
BuiltInLaunchSizeNVX = 5320,
BuiltInWorldRayOriginNVX = 5321,
BuiltInWorldRayDirectionNVX = 5322,
BuiltInObjectRayOriginNVX = 5323,
BuiltInObjectRayDirectionNVX = 5324,
BuiltInRayTminNVX = 5325,
BuiltInRayTmaxNVX = 5326,
BuiltInInstanceCustomIndexNVX = 5327,
BuiltInObjectToWorldNVX = 5330,
BuiltInWorldToObjectNVX = 5331,
BuiltInHitTNVX = 5332,
BuiltInHitKindNVX = 5333,
BuiltInLaunchIdNV = 5319,
BuiltInLaunchSizeNV = 5320,
BuiltInWorldRayOriginNV = 5321,
BuiltInWorldRayDirectionNV = 5322,
BuiltInObjectRayOriginNV = 5323,
BuiltInObjectRayDirectionNV = 5324,
BuiltInRayTminNV = 5325,
BuiltInRayTmaxNV = 5326,
BuiltInInstanceCustomIndexNV = 5327,
BuiltInObjectToWorldNV = 5330,
BuiltInWorldToObjectNV = 5331,
BuiltInHitTNV = 5332,
BuiltInHitKindNV = 5333,
BuiltInIncomingRayFlagsNV = 5351,
BuiltInMax = 0x7fffffff,
};
@@ -781,7 +784,7 @@ enum Capability {
CapabilityInputAttachmentArrayNonUniformIndexingEXT = 5310,
CapabilityUniformTexelBufferArrayNonUniformIndexingEXT = 5311,
CapabilityStorageTexelBufferArrayNonUniformIndexingEXT = 5312,
CapabilityRaytracingNVX = 5340,
CapabilityRayTracingNV = 5340,
CapabilityVulkanMemoryModelKHR = 5345,
CapabilityVulkanMemoryModelDeviceScopeKHR = 5346,
CapabilityComputeDerivativeGroupLinearNV = 5350,
@@ -1151,11 +1154,12 @@ enum Op {
OpImageSampleFootprintNV = 5283,
OpGroupNonUniformPartitionNV = 5296,
OpWritePackedPrimitiveIndices4x8NV = 5299,
OpReportIntersectionNVX = 5334,
OpIgnoreIntersectionNVX = 5335,
OpTerminateRayNVX = 5336,
OpTraceNVX = 5337,
OpTypeAccelerationStructureNVX = 5341,
OpReportIntersectionNV = 5334,
OpIgnoreIntersectionNV = 5335,
OpTerminateRayNV = 5336,
OpTraceNV = 5337,
OpTypeAccelerationStructureNV = 5341,
OpExecuteCallableNV = 5344,
OpSubgroupShuffleINTEL = 5571,
OpSubgroupShuffleDownINTEL = 5572,
OpSubgroupShuffleUpINTEL = 5573,