GL_EXT_ray_query updates
This commit is contained in:
committed by
Neslisah Torosdagli
parent
3f7c957e0a
commit
06c2eee720
@@ -2,6 +2,7 @@
|
||||
// Copyright (C) 2014-2016 LunarG, Inc.
|
||||
// Copyright (C) 2015-2020 Google, Inc.
|
||||
// Copyright (C) 2017 ARM Limited.
|
||||
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
@@ -1181,6 +1182,8 @@ spv::LoopControlMask TGlslangToSpvTraverser::TranslateLoopControl(const glslang:
|
||||
// Translate glslang type to SPIR-V storage class.
|
||||
spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::TType& type)
|
||||
{
|
||||
if (type.getBasicType() == glslang::EbtRayQuery)
|
||||
return spv::StorageClassFunction;
|
||||
if (type.getQualifier().isPipeInput())
|
||||
return spv::StorageClassInput;
|
||||
if (type.getQualifier().isPipeOutput())
|
||||
@@ -2703,6 +2706,13 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
|
||||
noReturnValue = true;
|
||||
break;
|
||||
case glslang::EOpRayQueryInitialize:
|
||||
case glslang::EOpRayQueryTerminate:
|
||||
case glslang::EOpRayQueryGenerateIntersection:
|
||||
case glslang::EOpRayQueryConfirmIntersection:
|
||||
noReturnValue = true;
|
||||
break;
|
||||
|
||||
case glslang::EOpCooperativeMatrixLoad:
|
||||
case glslang::EOpCooperativeMatrixStore:
|
||||
noReturnValue = true;
|
||||
@@ -2769,6 +2779,25 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
lvalue = true;
|
||||
break;
|
||||
|
||||
case glslang::EOpRayQueryInitialize:
|
||||
case glslang::EOpRayQueryGenerateIntersection:
|
||||
case glslang::EOpRayQueryGetIntersectionType:
|
||||
case glslang::EOpRayQueryGetIntersectionT:
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceCustomIndex:
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceId:
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset:
|
||||
case glslang::EOpRayQueryGetIntersectionGeometryIndex:
|
||||
case glslang::EOpRayQueryGetIntersectionPrimitiveIndex:
|
||||
case glslang::EOpRayQueryGetIntersectionBarycentrics:
|
||||
case glslang::EOpRayQueryGetIntersectionFrontFace:
|
||||
case glslang::EOpRayQueryGetIntersectionObjectRayDirection:
|
||||
case glslang::EOpRayQueryGetIntersectionObjectRayOrigin:
|
||||
case glslang::EOpRayQueryGetIntersectionObjectToWorld:
|
||||
case glslang::EOpRayQueryGetIntersectionWorldToObject:
|
||||
if (arg == 0)
|
||||
lvalue = true;
|
||||
break;
|
||||
|
||||
case glslang::EOpAtomicAdd:
|
||||
case glslang::EOpAtomicMin:
|
||||
case glslang::EOpAtomicMax:
|
||||
@@ -2913,7 +2942,29 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
|
||||
lvalueCoherentFlags |= TranslateCoherent(glslangOperands[arg]->getAsTyped()->getType());
|
||||
} else {
|
||||
builder.setLine(node->getLoc().line, node->getLoc().getFilename());
|
||||
operands.push_back(accessChainLoad(glslangOperands[arg]->getAsTyped()->getType()));
|
||||
glslang::TOperator glslangOp = node->getOp();
|
||||
if (arg == 1 &&
|
||||
(glslangOp == glslang::EOpRayQueryGetIntersectionType ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionT ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionInstanceCustomIndex ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionInstanceId ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionGeometryIndex ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionPrimitiveIndex ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionBarycentrics ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionFrontFace ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionObjectRayDirection ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionObjectRayOrigin ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionObjectToWorld ||
|
||||
glslangOp == glslang::EOpRayQueryGetIntersectionWorldToObject
|
||||
)) {
|
||||
bool cond = glslangOperands[arg]->getAsConstantUnion()->getConstArray()[0].getBConst();
|
||||
operands.push_back(builder.makeIntConstant(cond ? 1 : 0));
|
||||
}
|
||||
else {
|
||||
operands.push_back(accessChainLoad(glslangOperands[arg]->getAsTyped()->getType()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3549,6 +3600,9 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
|
||||
case glslang::EbtAccStruct:
|
||||
spvType = builder.makeAccelerationStructureType();
|
||||
break;
|
||||
case glslang::EbtRayQuery:
|
||||
spvType = builder.makeRayQueryType();
|
||||
break;
|
||||
case glslang::EbtReference:
|
||||
{
|
||||
// Make the forward pointer, then recurse to convert the structure type, then
|
||||
@@ -7615,6 +7669,103 @@ spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case glslang::EOpRayQueryInitialize: {
|
||||
builder.createNoResultOp(spv::OpRayQueryInitializeKHR, operands);
|
||||
return 0;
|
||||
} break;
|
||||
case glslang::EOpRayQueryTerminate: {
|
||||
builder.createNoResultOp(spv::OpRayQueryTerminateKHR, operands);
|
||||
return 0;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGenerateIntersection: {
|
||||
builder.createNoResultOp(spv::OpRayQueryGenerateIntersectionKHR, operands);
|
||||
return 0;
|
||||
} break;
|
||||
case glslang::EOpRayQueryConfirmIntersection: {
|
||||
builder.createNoResultOp(spv::OpRayQueryConfirmIntersectionKHR, operands);
|
||||
return 0;
|
||||
} break;
|
||||
case glslang::EOpRayQueryProceed: {
|
||||
typeId = builder.makeBoolType();
|
||||
opCode = spv::OpRayQueryProceedKHR;
|
||||
}
|
||||
break;
|
||||
case glslang::EOpRayQueryGetIntersectionType: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionTypeKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetRayTMin: {
|
||||
typeId = builder.makeFloatType(32);
|
||||
opCode = spv::OpRayQueryGetRayTMinKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetRayFlags: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetRayFlagsKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionT: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionTKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceCustomIndex: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionInstanceCustomIndexKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceId: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionInstanceIdKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffset: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionGeometryIndex: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionGeometryIndexKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionPrimitiveIndex: {
|
||||
typeId = builder.makeIntType(32);
|
||||
opCode = spv::OpRayQueryGetIntersectionPrimitiveIndexKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionBarycentrics: {
|
||||
typeId = builder.makeVectorType(builder.makeFloatType(32), 2);
|
||||
opCode = spv::OpRayQueryGetIntersectionBarycentricsKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionFrontFace: {
|
||||
typeId = builder.makeBoolType();
|
||||
opCode = spv::OpRayQueryGetIntersectionFrontFaceKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionCandidateAABBOpaque: {
|
||||
typeId = builder.makeBoolType();
|
||||
opCode = spv::OpRayQueryGetIntersectionCandidateAABBOpaqueKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionObjectRayDirection: {
|
||||
typeId = builder.makeVectorType(builder.makeFloatType(32), 3);
|
||||
opCode = spv::OpRayQueryGetIntersectionObjectRayDirectionKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionObjectRayOrigin: {
|
||||
typeId = builder.makeVectorType(builder.makeFloatType(32), 3);
|
||||
opCode = spv::OpRayQueryGetIntersectionObjectRayOriginKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetWorldRayDirection: {
|
||||
typeId = builder.makeVectorType(builder.makeFloatType(32), 3);
|
||||
opCode = spv::OpRayQueryGetWorldRayDirectionKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetWorldRayOrigin: {
|
||||
typeId = builder.makeVectorType(builder.makeFloatType(32), 3);
|
||||
opCode = spv::OpRayQueryGetWorldRayOriginKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionObjectToWorld: {
|
||||
typeId = builder.makeMatrixType(builder.makeFloatType(32), 4, 3);
|
||||
// https://gitlab.khronos.org/spirv/spirv-extensions/blob/cdf44fd4b854a5297bf2191d4f57f9bccbc49098/SPV_KHR_ray_query.asciidoc#ray_query_candidate_intersection_type
|
||||
// or per description is it typeId = builder.makeVectorType(builder.makeVectorType(builder.makeFloatType(32), 3), 4);
|
||||
opCode = spv::OpRayQueryGetIntersectionObjectToWorldKHR;
|
||||
} break;
|
||||
case glslang::EOpRayQueryGetIntersectionWorldToObject: {
|
||||
typeId = builder.makeMatrixType(builder.makeFloatType(32), 4, 3);
|
||||
// https://gitlab.khronos.org/spirv/spirv-extensions/blob/cdf44fd4b854a5297bf2191d4f57f9bccbc49098/SPV_KHR_ray_query.asciidoc#ray_query_candidate_intersection_type
|
||||
// or per description is it typeId = builder.makeVectorType(builder.makeVectorType(builder.makeFloatType(32), 3), 4);
|
||||
opCode = spv::OpRayQueryGetIntersectionWorldToObjectKHR;
|
||||
} break;
|
||||
case glslang::EOpWritePackedPrimitiveIndices4x8NV:
|
||||
builder.createNoResultOp(spv::OpWritePackedPrimitiveIndices4x8NV, operands);
|
||||
return 0;
|
||||
@@ -7817,7 +7968,18 @@ spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv:
|
||||
case glslang::EOpTerminateRay:
|
||||
builder.createNoResultOp(spv::OpTerminateRayKHR);
|
||||
return 0;
|
||||
|
||||
case glslang::EOpRayQueryInitialize:
|
||||
builder.createNoResultOp(spv::OpRayQueryInitializeKHR);
|
||||
return 0;
|
||||
case glslang::EOpRayQueryTerminate:
|
||||
builder.createNoResultOp(spv::OpRayQueryTerminateKHR);
|
||||
return 0;
|
||||
case glslang::EOpRayQueryGenerateIntersection:
|
||||
builder.createNoResultOp(spv::OpRayQueryGenerateIntersectionKHR);
|
||||
return 0;
|
||||
case glslang::EOpRayQueryConfirmIntersection:
|
||||
builder.createNoResultOp(spv::OpRayQueryConfirmIntersectionKHR);
|
||||
return 0;
|
||||
case glslang::EOpBeginInvocationInterlock:
|
||||
builder.createNoResultOp(spv::OpBeginInvocationInterlockEXT);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user