Skip to content

Commit fdda95c

Browse files
committed
Add support for QCOM tile shading
1 parent f050bb7 commit fdda95c

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

source/val/validate_decorations.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ spv_result_t CheckNonWritableDecoration(ValidationState_t& vstate,
17651765
var_storage_class == spv::StorageClass::Private) &&
17661766
vstate.features().nonwritable_var_in_function_or_private) {
17671767
// New permitted feature in SPIR-V 1.4.
1768+
} else if (var_storage_class == spv::StorageClass::TileAttachmentQCOM) {
17681769
} else if (
17691770
// It may point to a UBO, SSBO, storage image, or raw access chain.
17701771
vstate.IsPointerToUniformBlock(type_id) ||

source/val/validate_memory.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,53 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
937937
}
938938
}
939939

940+
if (_.HasCapability(spv::Capability::TileShadingQCOM) &&
941+
storage_class == spv::StorageClass::TileAttachmentQCOM) {
942+
if (result_type->opcode() == spv::Op::OpTypeImage) {
943+
spv::Dim dim = static_cast<spv::Dim>(inst->word(3));
944+
if (dim != spv::Dim::Dim2D) {
945+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
946+
<< "Any OpTpeImage variable in the TileAttachmentQCOM Storage Class must "
947+
"have 2D as its dimension";
948+
}
949+
unsigned sampled = inst->word(7);
950+
if (sampled != 1 && sampled != 2) {
951+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
952+
<< "Any OpTpeImage variable in the TileAttachmentQCOM Storage Class must "
953+
"have 1 or 2 as Image 'Sampled' parameter";
954+
}
955+
for (const auto& pair : inst->uses()) {
956+
const auto* use_inst = pair.first;
957+
switch (use_inst->opcode()) {
958+
case spv::Op::OpImageQueryFormat:
959+
case spv::Op::OpImageQueryOrder:
960+
case spv::Op::OpImageQuerySizeLod:
961+
case spv::Op::OpImageQuerySize:
962+
case spv::Op::OpImageQueryLod:
963+
case spv::Op::OpImageQueryLevels:
964+
case spv::Op::OpImageQuerySamples:
965+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
966+
<< "Any variable in the TileAttachmentQCOM Storage Class must "
967+
"not be consumed by an OpImageQuery* instruction";
968+
default:
969+
break;
970+
}
971+
}
972+
}
973+
974+
if (!(_.HasDecoration(inst->id(), spv::Decoration::DescriptorSet) &&
975+
_.HasDecoration(inst->id(), spv::Decoration::Binding))) {
976+
return _.diag(SPV_ERROR_INVALID_ID, inst)
977+
<< "Any variable in the TileAttachmentQCOM Storage Class must "
978+
"be decorated with DescriptorSet and Binding";
979+
}
980+
if (_.HasDecoration(inst->id(), spv::Decoration::Component)) {
981+
return _.diag(SPV_ERROR_INVALID_ID, inst)
982+
<< "Any variable in the TileAttachmentQCOM Storage Class must "
983+
"not be decorated with Component decoration";
984+
}
985+
}
986+
940987
return SPV_SUCCESS;
941988
}
942989

source/val/validate_mode_setting.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,15 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) {
286286

287287
// TODO - Need to add TileShadingRateQCOM support
288288
if (spvIsVulkanEnv(_.context()->target_env)) {
289+
bool ok = false;
290+
bool foundLocalSizeId = false;
289291
switch (execution_model) {
290292
case spv::ExecutionModel::GLCompute:
291-
if (!execution_modes ||
292-
!execution_modes->count(spv::ExecutionMode::LocalSize)) {
293-
bool ok = false;
293+
if (_.HasCapability(spv::Capability::TileShadingQCOM)) {
294+
ok = (execution_modes && execution_modes->count(spv::ExecutionMode::TileShadingRateQCOM));
295+
}
296+
if (!ok && (!execution_modes ||
297+
!execution_modes->count(spv::ExecutionMode::LocalSize))) {
294298
for (auto& i : _.ordered_instructions()) {
295299
if (i.opcode() == spv::Op::OpDecorate) {
296300
if (i.operands().size() > 2) {
@@ -307,6 +311,7 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) {
307311
const auto mode = i.GetOperandAs<spv::ExecutionMode>(1);
308312
if (mode == spv::ExecutionMode::LocalSizeId) {
309313
ok = true;
314+
foundLocalSizeId = true;
310315
break;
311316
}
312317
}
@@ -315,9 +320,21 @@ spv_result_t ValidateEntryPoint(ValidationState_t& _, const Instruction* inst) {
315320
return _.diag(SPV_ERROR_INVALID_DATA, inst)
316321
<< _.VkErrorID(10685)
317322
<< "In the Vulkan environment, GLCompute execution model "
318-
"entry points require either the LocalSize or "
319-
"LocalSizeId execution mode or an object decorated with "
320-
"WorkgroupSize must be specified.";
323+
"entry points require either the "
324+
<< (_.HasCapability(spv::Capability::TileShadingQCOM) ? "TileShadingRateQCOM, " : "")
325+
<< "LocalSize or LocalSizeId execution mode or an object "
326+
"decorated with WorkgroupSize must be specified.";
327+
}
328+
}
329+
330+
if (_.HasCapability(spv::Capability::TileShadingQCOM)) {
331+
if (execution_modes) {
332+
if (execution_modes->count(spv::ExecutionMode::TileShadingRateQCOM) &&
333+
(execution_modes->count(spv::ExecutionMode::LocalSize) || foundLocalSizeId)) {
334+
return _.diag(SPV_ERROR_INVALID_DATA, inst)
335+
<< "If the TileShadingRateQCOM Execution Mode is used, "
336+
<< "LocalSize and LocalSizeId must not be specified.";
337+
}
321338
}
322339
}
323340
break;

0 commit comments

Comments
 (0)