|
@@ -853,17 +853,18 @@ spv_result_t CheckDecorationsOfEntryPoints(ValidationState_t& vstate) {
|
|
|
(models->size() > 1 || has_vert)) {
|
|
(models->size() > 1 || has_vert)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, var_instr)
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, var_instr)
|
|
|
<< vstate.VkErrorID(6202)
|
|
<< vstate.VkErrorID(6202)
|
|
|
- << "OpEntryPoint interfaces variable must not be vertex "
|
|
|
|
|
- "execution model with an input storage class for "
|
|
|
|
|
- "Entry Point id "
|
|
|
|
|
|
|
+ << vstate.SpvDecorationString(decoration.dec_type())
|
|
|
|
|
+ << " decorated variable must not be used in vertex "
|
|
|
|
|
+ "execution model as an Input storage class for Entry "
|
|
|
|
|
+ "Point id "
|
|
|
<< entry_point << ".";
|
|
<< entry_point << ".";
|
|
|
} else if (storage_class == SpvStorageClassOutput &&
|
|
} else if (storage_class == SpvStorageClassOutput &&
|
|
|
(models->size() > 1 || has_frag)) {
|
|
(models->size() > 1 || has_frag)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, var_instr)
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, var_instr)
|
|
|
<< vstate.VkErrorID(6201)
|
|
<< vstate.VkErrorID(6201)
|
|
|
- << "OpEntryPoint interfaces variable must not be "
|
|
|
|
|
- "fragment "
|
|
|
|
|
- "execution model with an output storage class for "
|
|
|
|
|
|
|
+ << vstate.SpvDecorationString(decoration.dec_type())
|
|
|
|
|
+ << " decorated variable must not be used in fragment "
|
|
|
|
|
+ "execution model as an Output storage class for "
|
|
|
"Entry Point id "
|
|
"Entry Point id "
|
|
|
<< entry_point << ".";
|
|
<< entry_point << ".";
|
|
|
}
|
|
}
|
|
@@ -1217,57 +1218,58 @@ spv_result_t CheckDecorationsOfBuffers(ValidationState_t& vstate) {
|
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
|
<< " must be explicitly laid out with Offset "
|
|
<< " must be explicitly laid out with Offset "
|
|
|
"decorations.";
|
|
"decorations.";
|
|
|
- } else if (hasDecoration(id, SpvDecorationGLSLShared, vstate)) {
|
|
|
|
|
- return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
|
|
|
- << "Structure id " << id << " decorated as " << deco_str
|
|
|
|
|
- << " must not use GLSLShared decoration.";
|
|
|
|
|
- } else if (hasDecoration(id, SpvDecorationGLSLPacked, vstate)) {
|
|
|
|
|
- return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
|
|
|
- << "Structure id " << id << " decorated as " << deco_str
|
|
|
|
|
- << " must not use GLSLPacked decoration.";
|
|
|
|
|
- } else if (!checkForRequiredDecoration(
|
|
|
|
|
- id,
|
|
|
|
|
- [](SpvDecoration d) {
|
|
|
|
|
- return d == SpvDecorationArrayStride;
|
|
|
|
|
- },
|
|
|
|
|
- SpvOpTypeArray, vstate)) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!checkForRequiredDecoration(id,
|
|
|
|
|
+ [](SpvDecoration d) {
|
|
|
|
|
+ return d ==
|
|
|
|
|
+ SpvDecorationArrayStride;
|
|
|
|
|
+ },
|
|
|
|
|
+ SpvOpTypeArray, vstate)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
|
<< " must be explicitly laid out with ArrayStride "
|
|
<< " must be explicitly laid out with ArrayStride "
|
|
|
"decorations.";
|
|
"decorations.";
|
|
|
- } else if (!checkForRequiredDecoration(
|
|
|
|
|
- id,
|
|
|
|
|
- [](SpvDecoration d) {
|
|
|
|
|
- return d == SpvDecorationMatrixStride;
|
|
|
|
|
- },
|
|
|
|
|
- SpvOpTypeMatrix, vstate)) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!checkForRequiredDecoration(id,
|
|
|
|
|
+ [](SpvDecoration d) {
|
|
|
|
|
+ return d ==
|
|
|
|
|
+ SpvDecorationMatrixStride;
|
|
|
|
|
+ },
|
|
|
|
|
+ SpvOpTypeMatrix, vstate)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
|
<< " must be explicitly laid out with MatrixStride "
|
|
<< " must be explicitly laid out with MatrixStride "
|
|
|
"decorations.";
|
|
"decorations.";
|
|
|
- } else if (!checkForRequiredDecoration(
|
|
|
|
|
- id,
|
|
|
|
|
- [](SpvDecoration d) {
|
|
|
|
|
- return d == SpvDecorationRowMajor ||
|
|
|
|
|
- d == SpvDecorationColMajor;
|
|
|
|
|
- },
|
|
|
|
|
- SpvOpTypeMatrix, vstate)) {
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!checkForRequiredDecoration(
|
|
|
|
|
+ id,
|
|
|
|
|
+ [](SpvDecoration d) {
|
|
|
|
|
+ return d == SpvDecorationRowMajor ||
|
|
|
|
|
+ d == SpvDecorationColMajor;
|
|
|
|
|
+ },
|
|
|
|
|
+ SpvOpTypeMatrix, vstate)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, vstate.FindDef(id))
|
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
<< "Structure id " << id << " decorated as " << deco_str
|
|
|
<< " must be explicitly laid out with RowMajor or "
|
|
<< " must be explicitly laid out with RowMajor or "
|
|
|
"ColMajor decorations.";
|
|
"ColMajor decorations.";
|
|
|
- } else if (blockRules &&
|
|
|
|
|
- (SPV_SUCCESS !=
|
|
|
|
|
- (recursive_status = checkLayout(
|
|
|
|
|
- id, sc_str, deco_str, true, scalar_block_layout, 0,
|
|
|
|
|
- constraints, vstate)))) {
|
|
|
|
|
- return recursive_status;
|
|
|
|
|
- } else if (bufferRules &&
|
|
|
|
|
- (SPV_SUCCESS !=
|
|
|
|
|
- (recursive_status = checkLayout(
|
|
|
|
|
- id, sc_str, deco_str, false, scalar_block_layout,
|
|
|
|
|
- 0, constraints, vstate)))) {
|
|
|
|
|
- return recursive_status;
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (spvIsVulkanEnv(vstate.context()->target_env)) {
|
|
|
|
|
+ if (blockRules && (SPV_SUCCESS != (recursive_status = checkLayout(
|
|
|
|
|
+ id, sc_str, deco_str, true,
|
|
|
|
|
+ scalar_block_layout, 0,
|
|
|
|
|
+ constraints, vstate)))) {
|
|
|
|
|
+ return recursive_status;
|
|
|
|
|
+ } else if (bufferRules &&
|
|
|
|
|
+ (SPV_SUCCESS !=
|
|
|
|
|
+ (recursive_status = checkLayout(
|
|
|
|
|
+ id, sc_str, deco_str, false, scalar_block_layout,
|
|
|
|
|
+ 0, constraints, vstate)))) {
|
|
|
|
|
+ return recursive_status;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1625,6 +1627,8 @@ spv_result_t CheckComponentDecoration(ValidationState_t& vstate,
|
|
|
const Instruction& inst,
|
|
const Instruction& inst,
|
|
|
const Decoration& decoration) {
|
|
const Decoration& decoration) {
|
|
|
assert(inst.id() && "Parser ensures the target of the decoration has an ID");
|
|
assert(inst.id() && "Parser ensures the target of the decoration has an ID");
|
|
|
|
|
+ assert(decoration.params().size() == 1 &&
|
|
|
|
|
+ "Grammar ensures Component has one parameter");
|
|
|
|
|
|
|
|
uint32_t type_id;
|
|
uint32_t type_id;
|
|
|
if (decoration.struct_member_index() == Decoration::kInvalidMember) {
|
|
if (decoration.struct_member_index() == Decoration::kInvalidMember) {
|
|
@@ -1673,23 +1677,48 @@ spv_result_t CheckComponentDecoration(ValidationState_t& vstate,
|
|
|
if (!vstate.IsIntScalarOrVectorType(type_id) &&
|
|
if (!vstate.IsIntScalarOrVectorType(type_id) &&
|
|
|
!vstate.IsFloatScalarOrVectorType(type_id)) {
|
|
!vstate.IsFloatScalarOrVectorType(type_id)) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << vstate.VkErrorID(4924)
|
|
|
<< "Component decoration specified for type "
|
|
<< "Component decoration specified for type "
|
|
|
<< vstate.getIdName(type_id) << " that is not a scalar or vector";
|
|
<< vstate.getIdName(type_id) << " that is not a scalar or vector";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // For 16-, and 32-bit types, it is invalid if this sequence of components
|
|
|
|
|
- // gets larger than 3.
|
|
|
|
|
|
|
+ const auto component = decoration.params()[0];
|
|
|
|
|
+ if (component > 3) {
|
|
|
|
|
+ return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << vstate.VkErrorID(4920)
|
|
|
|
|
+ << "Component decoration value must not be greater than 3";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const auto dimension = vstate.GetDimension(type_id);
|
|
|
const auto bit_width = vstate.GetBitWidth(type_id);
|
|
const auto bit_width = vstate.GetBitWidth(type_id);
|
|
|
if (bit_width == 16 || bit_width == 32) {
|
|
if (bit_width == 16 || bit_width == 32) {
|
|
|
- assert(decoration.params().size() == 1 &&
|
|
|
|
|
- "Grammar ensures Component has one parameter");
|
|
|
|
|
-
|
|
|
|
|
- const auto component = decoration.params()[0];
|
|
|
|
|
- const auto last_component = component + vstate.GetDimension(type_id) - 1;
|
|
|
|
|
- if (last_component > 3) {
|
|
|
|
|
|
|
+ const auto sum_component = component + dimension;
|
|
|
|
|
+ if (sum_component > 4) {
|
|
|
|
|
+ return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << vstate.VkErrorID(4921)
|
|
|
|
|
+ << "Sequence of components starting with " << component
|
|
|
|
|
+ << " and ending with " << (sum_component - 1)
|
|
|
|
|
+ << " gets larger than 3";
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (bit_width == 64) {
|
|
|
|
|
+ if (dimension > 2) {
|
|
|
|
|
+ return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << "Component decoration only allowed on 64-bit scalar and "
|
|
|
|
|
+ "2-component vector";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (component == 1 || component == 3) {
|
|
|
|
|
+ return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << vstate.VkErrorID(4923)
|
|
|
|
|
+ << "Component decoration value must not be 1 or 3 for 64-bit "
|
|
|
|
|
+ "data types";
|
|
|
|
|
+ }
|
|
|
|
|
+ // 64-bit is double per component dimension
|
|
|
|
|
+ const auto sum_component = component + (2 * dimension);
|
|
|
|
|
+ if (sum_component > 4) {
|
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
return vstate.diag(SPV_ERROR_INVALID_ID, &inst)
|
|
|
|
|
+ << vstate.VkErrorID(4922)
|
|
|
<< "Sequence of components starting with " << component
|
|
<< "Sequence of components starting with " << component
|
|
|
- << " and ending with " << last_component
|
|
|
|
|
|
|
+ << " and ending with " << (sum_component - 1)
|
|
|
<< " gets larger than 3";
|
|
<< " gets larger than 3";
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|