|
@@ -543,8 +543,8 @@ SpirvFunctionParameter *
|
|
|
DeclResultIdMapper::createFnParam(const ParmVarDecl *param) {
|
|
|
const auto type = getTypeOrFnRetType(param);
|
|
|
const auto loc = param->getLocation();
|
|
|
- SpirvFunctionParameter *fnParamInstr =
|
|
|
- spvBuilder.addFnParam(type, loc, param->getName());
|
|
|
+ SpirvFunctionParameter *fnParamInstr = spvBuilder.addFnParam(
|
|
|
+ type, param->hasAttr<HLSLPreciseAttr>(), loc, param->getName());
|
|
|
|
|
|
bool isAlias = false;
|
|
|
(void)getTypeAndCreateCounterForPotentialAliasVar(param, &isAlias);
|
|
@@ -574,8 +574,9 @@ DeclResultIdMapper::createFnVar(const VarDecl *var,
|
|
|
const auto type = getTypeOrFnRetType(var);
|
|
|
const auto loc = var->getLocation();
|
|
|
const auto name = var->getName();
|
|
|
+ const bool isPrecise = var->hasAttr<HLSLPreciseAttr>();
|
|
|
SpirvVariable *varInstr = spvBuilder.addFnVar(
|
|
|
- type, loc, name, init.hasValue() ? init.getValue() : nullptr);
|
|
|
+ type, loc, name, isPrecise, init.hasValue() ? init.getValue() : nullptr);
|
|
|
|
|
|
bool isAlias = false;
|
|
|
(void)getTypeAndCreateCounterForPotentialAliasVar(var, &isAlias);
|
|
@@ -593,7 +594,8 @@ DeclResultIdMapper::createFileVar(const VarDecl *var,
|
|
|
const auto type = getTypeOrFnRetType(var);
|
|
|
const auto loc = var->getLocation();
|
|
|
SpirvVariable *varInstr = spvBuilder.addModuleVar(
|
|
|
- type, spv::StorageClass::Private, var->getName(), init, loc);
|
|
|
+ type, spv::StorageClass::Private, var->hasAttr<HLSLPreciseAttr>(),
|
|
|
+ var->getName(), init, loc);
|
|
|
|
|
|
bool isAlias = false;
|
|
|
(void)getTypeAndCreateCounterForPotentialAliasVar(var, &isAlias);
|
|
@@ -651,7 +653,8 @@ SpirvVariable *DeclResultIdMapper::createExternVar(const VarDecl *var) {
|
|
|
const auto type = var->getType();
|
|
|
const auto loc = var->getLocation();
|
|
|
SpirvVariable *varInstr = spvBuilder.addModuleVar(
|
|
|
- type, storageClass, var->getName(), llvm::None, loc);
|
|
|
+ type, storageClass, var->hasAttr<HLSLPreciseAttr>(), var->getName(),
|
|
|
+ llvm::None, loc);
|
|
|
varInstr->setLayoutRule(rule);
|
|
|
DeclSpirvInfo info(varInstr);
|
|
|
astDecls[var] = info;
|
|
@@ -716,7 +719,8 @@ SpirvVariable *DeclResultIdMapper::createStructOrStructArrayVarOfExplicitLayout(
|
|
|
varType.removeLocalConst();
|
|
|
HybridStructType::FieldInfo info(varType, declDecl->getName(),
|
|
|
declDecl->getAttr<VKOffsetAttr>(),
|
|
|
- getPackOffset(declDecl), registerC);
|
|
|
+ getPackOffset(declDecl), registerC,
|
|
|
+ declDecl->hasAttr<HLSLPreciseAttr>());
|
|
|
fields.push_back(info);
|
|
|
}
|
|
|
|
|
@@ -743,7 +747,10 @@ SpirvVariable *DeclResultIdMapper::createStructOrStructArrayVarOfExplicitLayout(
|
|
|
forPC ? spv::StorageClass::PushConstant : spv::StorageClass::Uniform;
|
|
|
|
|
|
// Create the variable for the whole struct / struct array.
|
|
|
- SpirvVariable *var = spvBuilder.addModuleVar(resultType, sc, varName);
|
|
|
+ // The fields may be 'precise', but the structure itself is not.
|
|
|
+ SpirvVariable *var =
|
|
|
+ spvBuilder.addModuleVar(resultType, sc, /*isPrecise*/ false, varName);
|
|
|
+
|
|
|
const SpirvLayoutRule layoutRule =
|
|
|
(forCBuffer || forGlobals)
|
|
|
? spirvOptions.cBufferLayoutRule
|
|
@@ -889,9 +896,10 @@ SpirvFunction *DeclResultIdMapper::getOrRegisterFn(const FunctionDecl *fn) {
|
|
|
bool isAlias = false;
|
|
|
(void)getTypeAndCreateCounterForPotentialAliasVar(fn, &isAlias);
|
|
|
|
|
|
- SpirvFunction *spirvFunction = new (spvContext) SpirvFunction(
|
|
|
- fn->getReturnType(), /*functionType*/ nullptr,
|
|
|
- spv::FunctionControlMask::MaskNone, fn->getLocation(), fn->getName());
|
|
|
+ const bool isPrecise = fn->hasAttr<HLSLPreciseAttr>();
|
|
|
+ SpirvFunction *spirvFunction = new (spvContext)
|
|
|
+ SpirvFunction(fn->getReturnType(), /*functionType*/ nullptr,
|
|
|
+ fn->getLocation(), fn->getName(), isPrecise);
|
|
|
|
|
|
// No need to dereference to get the pointer. Function returns that are
|
|
|
// stand-alone aliases are already pointers to values. All other cases should
|
|
@@ -965,8 +973,8 @@ void DeclResultIdMapper::createCounterVar(
|
|
|
spvContext.getPointerType(counterType, spv::StorageClass::Uniform);
|
|
|
}
|
|
|
|
|
|
- SpirvVariable *counterInstr =
|
|
|
- spvBuilder.addModuleVar(counterType, sc, counterName);
|
|
|
+ SpirvVariable *counterInstr = spvBuilder.addModuleVar(
|
|
|
+ counterType, sc, /*isPrecise*/ false, counterName);
|
|
|
|
|
|
if (!isAlias) {
|
|
|
// Non-alias counter variables should be put in to resourceVars so that
|
|
@@ -2218,7 +2226,7 @@ SpirvVariable *DeclResultIdMapper::getBuiltinVar(spv::BuiltIn builtIn,
|
|
|
|
|
|
// Create a dummy StageVar for this builtin variable
|
|
|
auto var = spvBuilder.addStageBuiltinVar(type, spv::StorageClass::Input,
|
|
|
- builtIn, loc);
|
|
|
+ builtIn, /*isPrecise*/ false, loc);
|
|
|
|
|
|
const hlsl::SigPoint *sigPoint =
|
|
|
hlsl::SigPoint::GetSigPoint(hlsl::SigPointFromInputQual(
|
|
@@ -2246,6 +2254,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
const auto semanticKind = stageVar->getSemanticInfo().getKind();
|
|
|
const auto sigPointKind = sigPoint->GetKind();
|
|
|
const auto type = stageVar->getAstType();
|
|
|
+ const auto isPrecise = decl->hasAttr<HLSLPreciseAttr>();
|
|
|
|
|
|
spv::StorageClass sc = getStorageClassForSigPoint(sigPoint);
|
|
|
if (sc == spv::StorageClass::Max)
|
|
@@ -2265,7 +2274,8 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
.Default(BuiltIn::Max);
|
|
|
|
|
|
assert(spvBuiltIn != BuiltIn::Max); // The frontend should guarantee this.
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, spvBuiltIn, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, spvBuiltIn, isPrecise,
|
|
|
+ srcLoc);
|
|
|
}
|
|
|
|
|
|
// The following translation assumes that semantic validity in the current
|
|
@@ -2281,7 +2291,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::VSIn:
|
|
|
case hlsl::SigPoint::Kind::PCOut:
|
|
|
case hlsl::SigPoint::Kind::DSIn:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
case hlsl::SigPoint::Kind::VSOut:
|
|
|
case hlsl::SigPoint::Kind::HSCPIn:
|
|
|
case hlsl::SigPoint::Kind::HSCPOut:
|
|
@@ -2290,11 +2300,12 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::GSVIn:
|
|
|
case hlsl::SigPoint::Kind::GSOut:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Position, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Position,
|
|
|
+ isPrecise, srcLoc);
|
|
|
case hlsl::SigPoint::Kind::PSIn:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FragCoord,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
default:
|
|
|
llvm_unreachable("invalid usage of SV_Position sneaked in");
|
|
|
}
|
|
@@ -2305,7 +2316,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::VertexID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::VertexIndex,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the InstanceID SV can be used by VSIn, VSOut,
|
|
|
// HSCPIn, HSCPOut, DSCPIn, DSOut, GSVIn, GSOut, PSIn.
|
|
@@ -2316,7 +2327,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::VSIn:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::InstanceIndex,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
case hlsl::SigPoint::Kind::VSOut:
|
|
|
case hlsl::SigPoint::Kind::HSCPIn:
|
|
|
case hlsl::SigPoint::Kind::HSCPOut:
|
|
@@ -2325,7 +2336,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::GSVIn:
|
|
|
case hlsl::SigPoint::Kind::GSOut:
|
|
|
case hlsl::SigPoint::Kind::PSIn:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
default:
|
|
|
llvm_unreachable("invalid usage of SV_InstanceID sneaked in");
|
|
|
}
|
|
@@ -2346,7 +2357,8 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
else if (semanticKind == hlsl::Semantic::Kind::DepthLessEqual)
|
|
|
spvBuilder.addExecutionMode(entryFunction, spv::ExecutionMode::DepthLess,
|
|
|
{});
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FragDepth, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FragDepth,
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the ClipDistance/CullDistance SV can be used by all
|
|
|
// SigPoints other than PCIn, HSIn, GSIn, PSOut, CSIn.
|
|
@@ -2358,7 +2370,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::VSIn:
|
|
|
case hlsl::SigPoint::Kind::PCOut:
|
|
|
case hlsl::SigPoint::Kind::DSIn:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
case hlsl::SigPoint::Kind::VSOut:
|
|
|
case hlsl::SigPoint::Kind::HSCPIn:
|
|
|
case hlsl::SigPoint::Kind::HSCPOut:
|
|
@@ -2379,11 +2391,11 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::IsFrontFace: {
|
|
|
switch (sigPointKind) {
|
|
|
case hlsl::SigPoint::Kind::GSOut:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
case hlsl::SigPoint::Kind::PSIn:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FrontFacing,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
default:
|
|
|
llvm_unreachable("invalid usage of SV_IsFrontFace sneaked in");
|
|
|
}
|
|
@@ -2395,7 +2407,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
// An arbitrary semantic is defined by users. Generate normal Vulkan stage
|
|
|
// input/output variables.
|
|
|
case hlsl::Semantic::Kind::Arbitrary: {
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
// TODO: patch constant function in hull shader
|
|
|
}
|
|
|
// According to DXIL spec, the DispatchThreadID SV can only be used by CSIn.
|
|
@@ -2403,29 +2415,29 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::DispatchThreadID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::GlobalInvocationId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the GroupID SV can only be used by CSIn.
|
|
|
// According to Vulkan spec, the WorkgroupId can only be used in CSIn.
|
|
|
case hlsl::Semantic::Kind::GroupID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::WorkgroupId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the GroupThreadID SV can only be used by CSIn.
|
|
|
// According to Vulkan spec, the LocalInvocationId can only be used in CSIn.
|
|
|
case hlsl::Semantic::Kind::GroupThreadID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::LocalInvocationId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the GroupIndex SV can only be used by CSIn.
|
|
|
// According to Vulkan spec, the LocalInvocationIndex can only be used in
|
|
|
// CSIn.
|
|
|
case hlsl::Semantic::Kind::GroupIndex: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc,
|
|
|
- BuiltIn::LocalInvocationIndex, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(
|
|
|
+ type, sc, BuiltIn::LocalInvocationIndex, isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the OutputControlID SV can only be used by HSIn.
|
|
|
// According to Vulkan spec, the InvocationId BuiltIn can only be used in
|
|
@@ -2433,7 +2445,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::OutputControlPointID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::InvocationId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the PrimitiveID SV can only be used by PCIn, HSIn,
|
|
|
// DSIn, GSIn, GSOut, and PSIn.
|
|
@@ -2443,7 +2455,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
// Translate to PrimitiveId BuiltIn for all valid SigPoints.
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::PrimitiveId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the TessFactor SV can only be used by PCOut and
|
|
|
// DSIn.
|
|
@@ -2452,7 +2464,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::TessFactor: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::TessLevelOuter,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the InsideTessFactor SV can only be used by PCOut
|
|
|
// and DSIn.
|
|
@@ -2461,13 +2473,14 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::InsideTessFactor: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::TessLevelInner,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the DomainLocation SV can only be used by DSIn.
|
|
|
// According to Vulkan spec, the TessCoord BuiltIn can only be used in DSIn.
|
|
|
case hlsl::Semantic::Kind::DomainLocation: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::TessCoord, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::TessCoord,
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the GSInstanceID SV can only be used by GSIn.
|
|
|
// According to Vulkan spec, the InvocationId BuiltIn can only be used in
|
|
@@ -2475,19 +2488,20 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::GSInstanceID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::InvocationId,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the SampleIndex SV can only be used by PSIn.
|
|
|
// According to Vulkan spec, the SampleId BuiltIn can only be used in PSIn.
|
|
|
case hlsl::Semantic::Kind::SampleIndex: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::SampleId, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::SampleId, isPrecise,
|
|
|
+ srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the StencilRef SV can only be used by PSOut.
|
|
|
case hlsl::Semantic::Kind::StencilRef: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FragStencilRefEXT,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the Barycentrics SV can only be used by PSIn.
|
|
|
case hlsl::Semantic::Kind::Barycentrics: {
|
|
@@ -2513,7 +2527,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, bi, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, bi, isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the RenderTargetArrayIndex SV can only be used by
|
|
|
// VSIn, VSOut, HSCPIn, HSCPOut, DSIn, DSOut, GSVIn, GSOut, PSIn.
|
|
@@ -2528,15 +2542,17 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::DSIn:
|
|
|
case hlsl::SigPoint::Kind::DSCPIn:
|
|
|
case hlsl::SigPoint::Kind::GSVIn:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
case hlsl::SigPoint::Kind::VSOut:
|
|
|
case hlsl::SigPoint::Kind::DSOut:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Layer, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Layer, isPrecise,
|
|
|
+ srcLoc);
|
|
|
case hlsl::SigPoint::Kind::GSOut:
|
|
|
case hlsl::SigPoint::Kind::PSIn:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Layer, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::Layer, isPrecise,
|
|
|
+ srcLoc);
|
|
|
default:
|
|
|
llvm_unreachable("invalid usage of SV_RenderTargetArrayIndex sneaked in");
|
|
|
}
|
|
@@ -2554,17 +2570,17 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::SigPoint::Kind::DSIn:
|
|
|
case hlsl::SigPoint::Kind::DSCPIn:
|
|
|
case hlsl::SigPoint::Kind::GSVIn:
|
|
|
- return spvBuilder.addStageIOVar(type, sc, name.str());
|
|
|
+ return spvBuilder.addStageIOVar(type, sc, name.str(), isPrecise);
|
|
|
case hlsl::SigPoint::Kind::VSOut:
|
|
|
case hlsl::SigPoint::Kind::DSOut:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::ViewportIndex,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
case hlsl::SigPoint::Kind::GSOut:
|
|
|
case hlsl::SigPoint::Kind::PSIn:
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::ViewportIndex,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
default:
|
|
|
llvm_unreachable("invalid usage of SV_ViewportArrayIndex sneaked in");
|
|
|
}
|
|
@@ -2574,7 +2590,8 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
// PSIn and PSOut.
|
|
|
case hlsl::Semantic::Kind::Coverage: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::SampleMask, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::SampleMask,
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the ViewID SV can only be used by VSIn, PCIn,
|
|
|
// HSIn, DSIn, GSIn, PSIn.
|
|
@@ -2582,7 +2599,8 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
// VS/HS/DS/GS/PS input.
|
|
|
case hlsl::Semantic::Kind::ViewID: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
- return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::ViewIndex, srcLoc);
|
|
|
+ return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::ViewIndex,
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
// According to DXIL spec, the InnerCoverage SV can only be used as PSIn.
|
|
|
// According to Vulkan spec, the FullyCoveredEXT BuiltIn can only be used as
|
|
@@ -2590,7 +2608,7 @@ SpirvVariable *DeclResultIdMapper::createSpirvStageVar(
|
|
|
case hlsl::Semantic::Kind::InnerCoverage: {
|
|
|
stageVar->setIsSpirvBuiltin();
|
|
|
return spvBuilder.addStageBuiltinVar(type, sc, BuiltIn::FullyCoveredEXT,
|
|
|
- srcLoc);
|
|
|
+ isPrecise, srcLoc);
|
|
|
}
|
|
|
default:
|
|
|
emitError("semantic %0 unimplemented", srcLoc)
|
|
@@ -2820,7 +2838,8 @@ DeclResultIdMapper::createRayTracingNVStageVar(spv::StorageClass sc,
|
|
|
case spv::StorageClass::HitAttributeNV:
|
|
|
case spv::StorageClass::RayPayloadNV:
|
|
|
case spv::StorageClass::CallableDataNV:
|
|
|
- retVal = spvBuilder.addModuleVar(type, sc, name.str());
|
|
|
+ retVal = spvBuilder.addModuleVar(type, sc, decl->hasAttr<HLSLPreciseAttr>(),
|
|
|
+ name.str());
|
|
|
break;
|
|
|
|
|
|
default:
|