mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-10-10 19:15:24 +00:00
Updated spirv-tools.
This commit is contained in:
committed by
Branimir Karadžić
parent
c02ebda27d
commit
a3df232816
@@ -170,6 +170,34 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _,
|
||||
<< "s type does not match Function <id> "
|
||||
<< _.getIdName(return_type->id()) << "s return type.";
|
||||
}
|
||||
if (!_.options()->relax_logical_pointer &&
|
||||
(_.addressing_model() == spv::AddressingModel::Logical ||
|
||||
_.addressing_model() == spv::AddressingModel::PhysicalStorageBuffer64)) {
|
||||
if (return_type->opcode() == spv::Op::OpTypePointer ||
|
||||
return_type->opcode() == spv::Op::OpTypeUntypedPointerKHR) {
|
||||
const auto sc = return_type->GetOperandAs<spv::StorageClass>(1);
|
||||
if (sc != spv::StorageClass::PhysicalStorageBuffer) {
|
||||
if (!_.HasCapability(spv::Capability::VariablePointersStorageBuffer) &&
|
||||
sc == spv::StorageClass::StorageBuffer) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "In Logical addressing, functions may only return a "
|
||||
"storage buffer pointer if the "
|
||||
"VariablePointersStorageBuffer capability is declared";
|
||||
} else if (!_.HasCapability(spv::Capability::VariablePointers) &&
|
||||
sc == spv::StorageClass::Workgroup) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "In Logical addressing, functions may only return a "
|
||||
"workgroup pointer if the VariablePointers capability is "
|
||||
"declared";
|
||||
} else if (sc != spv::StorageClass::StorageBuffer &&
|
||||
sc != spv::StorageClass::Workgroup) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "In Logical addressing, functions may not return a pointer "
|
||||
"in this storage class";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto function_type_id = function->GetOperandAs<uint32_t>(3);
|
||||
const auto function_type = _.FindDef(function_type_id);
|
||||
@@ -216,51 +244,59 @@ spv_result_t ValidateFunctionCall(ValidationState_t& _,
|
||||
}
|
||||
}
|
||||
|
||||
if (_.addressing_model() == spv::AddressingModel::Logical) {
|
||||
if (_.addressing_model() == spv::AddressingModel::Logical ||
|
||||
_.addressing_model() == spv::AddressingModel::PhysicalStorageBuffer64) {
|
||||
if ((parameter_type->opcode() == spv::Op::OpTypePointer ||
|
||||
parameter_type->opcode() == spv::Op::OpTypeUntypedPointerKHR) &&
|
||||
!_.options()->relax_logical_pointer) {
|
||||
spv::StorageClass sc =
|
||||
parameter_type->GetOperandAs<spv::StorageClass>(1u);
|
||||
// Validate which storage classes can be pointer operands.
|
||||
switch (sc) {
|
||||
case spv::StorageClass::UniformConstant:
|
||||
case spv::StorageClass::Function:
|
||||
case spv::StorageClass::Private:
|
||||
case spv::StorageClass::Workgroup:
|
||||
case spv::StorageClass::AtomicCounter:
|
||||
// These are always allowed.
|
||||
break;
|
||||
case spv::StorageClass::StorageBuffer:
|
||||
if (!_.features().variable_pointers) {
|
||||
if (sc != spv::StorageClass::PhysicalStorageBuffer) {
|
||||
// Validate which storage classes can be pointer operands.
|
||||
switch (sc) {
|
||||
case spv::StorageClass::UniformConstant:
|
||||
case spv::StorageClass::Function:
|
||||
case spv::StorageClass::Private:
|
||||
case spv::StorageClass::Workgroup:
|
||||
case spv::StorageClass::AtomicCounter:
|
||||
// SPV_EXT_tile_image
|
||||
case spv::StorageClass::TileImageEXT:
|
||||
// SPV_KHR_ray_tracing
|
||||
case spv::StorageClass::ShaderRecordBufferKHR:
|
||||
// These are always allowed.
|
||||
break;
|
||||
case spv::StorageClass::StorageBuffer:
|
||||
if (!_.features().variable_pointers) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "StorageBuffer pointer operand "
|
||||
<< _.getIdName(argument_id)
|
||||
<< " requires a variable pointers capability";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "StorageBuffer pointer operand "
|
||||
<< _.getIdName(argument_id)
|
||||
<< " requires a variable pointers capability";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "Invalid storage class for pointer operand "
|
||||
<< _.getIdName(argument_id);
|
||||
}
|
||||
<< "Invalid storage class for pointer operand "
|
||||
<< _.getIdName(argument_id);
|
||||
}
|
||||
|
||||
// Validate memory object declaration requirements.
|
||||
if (argument->opcode() != spv::Op::OpVariable &&
|
||||
argument->opcode() != spv::Op::OpUntypedVariableKHR &&
|
||||
argument->opcode() != spv::Op::OpFunctionParameter) {
|
||||
const bool ssbo_vptr =
|
||||
_.HasCapability(spv::Capability::VariablePointersStorageBuffer) &&
|
||||
sc == spv::StorageClass::StorageBuffer;
|
||||
const bool wg_vptr =
|
||||
_.HasCapability(spv::Capability::VariablePointers) &&
|
||||
sc == spv::StorageClass::Workgroup;
|
||||
const bool uc_ptr = sc == spv::StorageClass::UniformConstant;
|
||||
if (!_.options()->before_hlsl_legalization && !ssbo_vptr &&
|
||||
!wg_vptr && !uc_ptr) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "Pointer operand " << _.getIdName(argument_id)
|
||||
<< " must be a memory object declaration";
|
||||
// Validate memory object declaration requirements.
|
||||
if (argument->opcode() != spv::Op::OpVariable &&
|
||||
argument->opcode() != spv::Op::OpUntypedVariableKHR &&
|
||||
argument->opcode() != spv::Op::OpFunctionParameter) {
|
||||
const bool ssbo_vptr =
|
||||
_.HasCapability(
|
||||
spv::Capability::VariablePointersStorageBuffer) &&
|
||||
sc == spv::StorageClass::StorageBuffer;
|
||||
const bool wg_vptr =
|
||||
_.HasCapability(spv::Capability::VariablePointers) &&
|
||||
sc == spv::StorageClass::Workgroup;
|
||||
const bool uc_ptr = sc == spv::StorageClass::UniformConstant;
|
||||
if (!_.options()->before_hlsl_legalization && !ssbo_vptr &&
|
||||
!wg_vptr && !uc_ptr) {
|
||||
return _.diag(SPV_ERROR_INVALID_ID, inst)
|
||||
<< "Pointer operand " << _.getIdName(argument_id)
|
||||
<< " must be a memory object declaration";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user