@@ -306,6 +306,8 @@ getExecutionModel(const SPIRVSubtarget &STI, const Function &F) {
306
306
return SPIRV::ExecutionModel::GLCompute;
307
307
if (value == " vertex" )
308
308
return SPIRV::ExecutionModel::Vertex;
309
+ if (value == " pixel" )
310
+ return SPIRV::ExecutionModel::Fragment;
309
311
310
312
report_fatal_error (" This HLSL entry point is not supported by this backend." );
311
313
}
@@ -471,10 +473,21 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
471
473
// environment if we need to.
472
474
const SPIRVSubtarget *ST =
473
475
static_cast <const SPIRVSubtarget *>(&MIRBuilder.getMF ().getSubtarget ());
476
+ SPIRV::ExecutionModel::ExecutionModel ExecutionModel =
477
+ getExecutionModel (*ST, F);
474
478
auto MIB = MIRBuilder.buildInstr (SPIRV::OpEntryPoint)
475
- .addImm (static_cast <uint32_t >(getExecutionModel (*ST, F) ))
479
+ .addImm (static_cast <uint32_t >(ExecutionModel ))
476
480
.addUse (FuncVReg);
477
481
addStringImm (F.getName (), MIB);
482
+
483
+ if (ExecutionModel == SPIRV::ExecutionModel::Fragment) {
484
+ // SPIR-V common validation: Fragment requires OriginUpperLeft or
485
+ // OriginLowerLeft VUID-StandaloneSpirv-OriginLowerLeft-04653: Fragment
486
+ // must declare OriginUpperLeft.
487
+ MIRBuilder.buildInstr (SPIRV::OpExecutionMode)
488
+ .addUse (FuncVReg)
489
+ .addImm (static_cast <uint32_t >(SPIRV::ExecutionMode::OriginUpperLeft));
490
+ }
478
491
} else if (F.getLinkage () != GlobalValue::InternalLinkage &&
479
492
F.getLinkage () != GlobalValue::PrivateLinkage) {
480
493
SPIRV::LinkageType::LinkageType LnkTy =
0 commit comments