layers: Core Validation function name cleanup
Change-Id: I21a61327d4970c87a569644e386ac219bf2128ed
diff --git a/layers/shader_validation.cpp b/layers/shader_validation.cpp
index c61396d..c1a6f24 100644
--- a/layers/shader_validation.cpp
+++ b/layers/shader_validation.cpp
@@ -67,7 +67,7 @@
};
// SPIRV utility functions
-void shader_module::build_def_index() {
+void shader_module::BuildDefIndex() {
for (auto insn : *this) {
switch (insn.opcode()) {
// Types
@@ -130,7 +130,7 @@
}
}
-static spirv_inst_iter find_entrypoint(shader_module const *src, char const *name, VkShaderStageFlagBits stageBits) {
+static spirv_inst_iter FindEntrypoint(shader_module const *src, char const *name, VkShaderStageFlagBits stageBits) {
for (auto insn : *src) {
if (insn.opcode() == spv::OpEntryPoint) {
auto entrypointName = (char const *)&insn.word(3);
@@ -145,7 +145,7 @@
return src->end();
}
-static char const *storage_class_name(unsigned sc) {
+static char const *StorageClassName(unsigned sc) {
switch (sc) {
case spv::StorageClassInput:
return "input";
@@ -179,7 +179,7 @@
}
// Get the value of an integral constant
-unsigned get_constant_value(shader_module const *src, unsigned id) {
+unsigned GetConstantValue(shader_module const *src, unsigned id) {
auto value = src->get_def(id);
assert(value != src->end());
@@ -192,7 +192,7 @@
return value.word(3);
}
-static void describe_type_inner(std::ostringstream &ss, shader_module const *src, unsigned type) {
+static void DescribeTypeInner(std::ostringstream &ss, shader_module const *src, unsigned type) {
auto insn = src->get_def(type);
assert(insn != src->end());
@@ -208,24 +208,24 @@
break;
case spv::OpTypeVector:
ss << "vec" << insn.word(3) << " of ";
- describe_type_inner(ss, src, insn.word(2));
+ DescribeTypeInner(ss, src, insn.word(2));
break;
case spv::OpTypeMatrix:
ss << "mat" << insn.word(3) << " of ";
- describe_type_inner(ss, src, insn.word(2));
+ DescribeTypeInner(ss, src, insn.word(2));
break;
case spv::OpTypeArray:
- ss << "arr[" << get_constant_value(src, insn.word(3)) << "] of ";
- describe_type_inner(ss, src, insn.word(2));
+ ss << "arr[" << GetConstantValue(src, insn.word(3)) << "] of ";
+ DescribeTypeInner(ss, src, insn.word(2));
break;
case spv::OpTypePointer:
- ss << "ptr to " << storage_class_name(insn.word(2)) << " ";
- describe_type_inner(ss, src, insn.word(3));
+ ss << "ptr to " << StorageClassName(insn.word(2)) << " ";
+ DescribeTypeInner(ss, src, insn.word(3));
break;
case spv::OpTypeStruct: {
ss << "struct of (";
for (unsigned i = 2; i < insn.len(); i++) {
- describe_type_inner(ss, src, insn.word(i));
+ DescribeTypeInner(ss, src, insn.word(i));
if (i == insn.len() - 1) {
ss << ")";
} else {
@@ -239,7 +239,7 @@
break;
case spv::OpTypeSampledImage:
ss << "sampler+";
- describe_type_inner(ss, src, insn.word(2));
+ DescribeTypeInner(ss, src, insn.word(2));
break;
case spv::OpTypeImage:
ss << "image(dim=" << insn.word(3) << ", sampled=" << insn.word(7) << ")";
@@ -250,19 +250,19 @@
}
}
-static std::string describe_type(shader_module const *src, unsigned type) {
+static std::string DescribeType(shader_module const *src, unsigned type) {
std::ostringstream ss;
- describe_type_inner(ss, src, type);
+ DescribeTypeInner(ss, src, type);
return ss.str();
}
-static bool is_narrow_numeric_type(spirv_inst_iter type) {
+static bool IsNarrowNumericType(spirv_inst_iter type) {
if (type.opcode() != spv::OpTypeInt && type.opcode() != spv::OpTypeFloat) return false;
return type.word(2) < 64;
}
-static bool types_match(shader_module const *a, shader_module const *b, unsigned a_type, unsigned b_type, bool a_arrayed,
- bool b_arrayed, bool relaxed) {
+static bool TypesMatch(shader_module const *a, shader_module const *b, unsigned a_type, unsigned b_type, bool a_arrayed,
+ bool b_arrayed, bool relaxed) {
// Walk two type trees together, and complain about differences
auto a_insn = a->get_def(a_type);
auto b_insn = b->get_def(b_type);
@@ -270,16 +270,16 @@
assert(b_insn != b->end());
if (a_arrayed && a_insn.opcode() == spv::OpTypeArray) {
- return types_match(a, b, a_insn.word(2), b_type, false, b_arrayed, relaxed);
+ return TypesMatch(a, b, a_insn.word(2), b_type, false, b_arrayed, relaxed);
}
if (b_arrayed && b_insn.opcode() == spv::OpTypeArray) {
// We probably just found the extra level of arrayness in b_type: compare the type inside it to a_type
- return types_match(a, b, a_type, b_insn.word(2), a_arrayed, false, relaxed);
+ return TypesMatch(a, b, a_type, b_insn.word(2), a_arrayed, false, relaxed);
}
- if (a_insn.opcode() == spv::OpTypeVector && relaxed && is_narrow_numeric_type(b_insn)) {
- return types_match(a, b, a_insn.word(2), b_type, a_arrayed, b_arrayed, false);
+ if (a_insn.opcode() == spv::OpTypeVector && relaxed && IsNarrowNumericType(b_insn)) {
+ return TypesMatch(a, b, a_insn.word(2), b_type, a_arrayed, b_arrayed, false);
}
if (a_insn.opcode() != b_insn.opcode()) {
@@ -288,7 +288,7 @@
if (a_insn.opcode() == spv::OpTypePointer) {
// Match on pointee type. storage class is expected to differ
- return types_match(a, b, a_insn.word(3), b_insn.word(3), a_arrayed, b_arrayed, relaxed);
+ return TypesMatch(a, b, a_insn.word(3), b_insn.word(3), a_arrayed, b_arrayed, relaxed);
}
if (a_arrayed || b_arrayed) {
@@ -307,21 +307,21 @@
return a_insn.word(2) == b_insn.word(2);
case spv::OpTypeVector:
// Match on element type, count.
- if (!types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false)) return false;
- if (relaxed && is_narrow_numeric_type(a->get_def(a_insn.word(2)))) {
+ if (!TypesMatch(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false)) return false;
+ if (relaxed && IsNarrowNumericType(a->get_def(a_insn.word(2)))) {
return a_insn.word(3) >= b_insn.word(3);
} else {
return a_insn.word(3) == b_insn.word(3);
}
case spv::OpTypeMatrix:
// Match on element type, count.
- return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) &&
+ return TypesMatch(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) &&
a_insn.word(3) == b_insn.word(3);
case spv::OpTypeArray:
// Match on element type, count. these all have the same layout. we don't get here if b_arrayed. This differs from
// vector & matrix types in that the array size is the id of a constant instruction, * not a literal within OpTypeArray
- return types_match(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) &&
- get_constant_value(a, a_insn.word(3)) == get_constant_value(b, b_insn.word(3));
+ return TypesMatch(a, b, a_insn.word(2), b_insn.word(2), a_arrayed, b_arrayed, false) &&
+ GetConstantValue(a, a_insn.word(3)) == GetConstantValue(b, b_insn.word(3));
case spv::OpTypeStruct:
// Match on all element types
{
@@ -330,7 +330,7 @@
}
for (unsigned i = 2; i < a_insn.len(); i++) {
- if (!types_match(a, b, a_insn.word(i), b_insn.word(i), a_arrayed, b_arrayed, false)) {
+ if (!TypesMatch(a, b, a_insn.word(i), b_insn.word(i), a_arrayed, b_arrayed, false)) {
return false;
}
}
@@ -343,7 +343,7 @@
}
}
-static unsigned value_or_default(std::unordered_map<unsigned, unsigned> const &map, unsigned id, unsigned def) {
+static unsigned ValueOrDefault(std::unordered_map<unsigned, unsigned> const &map, unsigned id, unsigned def) {
auto it = map.find(id);
if (it == map.end())
return def;
@@ -351,7 +351,7 @@
return it->second;
}
-static unsigned get_locations_consumed_by_type(shader_module const *src, unsigned type, bool strip_array_level) {
+static unsigned GetLocationsConsumedByType(shader_module const *src, unsigned type, bool strip_array_level) {
auto insn = src->get_def(type);
assert(insn != src->end());
@@ -359,16 +359,16 @@
case spv::OpTypePointer:
// See through the ptr -- this is only ever at the toplevel for graphics shaders we're never actually passing
// pointers around.
- return get_locations_consumed_by_type(src, insn.word(3), strip_array_level);
+ return GetLocationsConsumedByType(src, insn.word(3), strip_array_level);
case spv::OpTypeArray:
if (strip_array_level) {
- return get_locations_consumed_by_type(src, insn.word(2), false);
+ return GetLocationsConsumedByType(src, insn.word(2), false);
} else {
- return get_constant_value(src, insn.word(3)) * get_locations_consumed_by_type(src, insn.word(2), false);
+ return GetConstantValue(src, insn.word(3)) * GetLocationsConsumedByType(src, insn.word(2), false);
}
case spv::OpTypeMatrix:
// Num locations is the dimension * element size
- return insn.word(3) * get_locations_consumed_by_type(src, insn.word(2), false);
+ return insn.word(3) * GetLocationsConsumedByType(src, insn.word(2), false);
case spv::OpTypeVector: {
auto scalar_type = src->get_def(insn.word(2));
auto bit_width =
@@ -385,7 +385,7 @@
}
}
-static unsigned get_locations_consumed_by_format(VkFormat format) {
+static unsigned GetLocationsConsumedByFormat(VkFormat format) {
switch (format) {
case VK_FORMAT_R64G64B64A64_SFLOAT:
case VK_FORMAT_R64G64B64A64_SINT:
@@ -399,7 +399,7 @@
}
}
-static unsigned get_format_type(VkFormat fmt) {
+static unsigned GetFormatType(VkFormat fmt) {
if (FormatIsSInt(fmt)) return FORMAT_TYPE_SINT;
if (FormatIsUInt(fmt)) return FORMAT_TYPE_UINT;
if (FormatIsDepthAndStencil(fmt)) return FORMAT_TYPE_FLOAT | FORMAT_TYPE_UINT;
@@ -409,7 +409,7 @@
}
// characterizes a SPIR-V type appearing in an interface to a FF stage, for comparison to a VkFormat's characterization above.
-static unsigned get_fundamental_type(shader_module const *src, unsigned type) {
+static unsigned GetFundamentalType(shader_module const *src, unsigned type) {
auto insn = src->get_def(type);
assert(insn != src->end());
@@ -419,27 +419,27 @@
case spv::OpTypeFloat:
return FORMAT_TYPE_FLOAT;
case spv::OpTypeVector:
- return get_fundamental_type(src, insn.word(2));
+ return GetFundamentalType(src, insn.word(2));
case spv::OpTypeMatrix:
- return get_fundamental_type(src, insn.word(2));
+ return GetFundamentalType(src, insn.word(2));
case spv::OpTypeArray:
- return get_fundamental_type(src, insn.word(2));
+ return GetFundamentalType(src, insn.word(2));
case spv::OpTypePointer:
- return get_fundamental_type(src, insn.word(3));
+ return GetFundamentalType(src, insn.word(3));
case spv::OpTypeImage:
- return get_fundamental_type(src, insn.word(2));
+ return GetFundamentalType(src, insn.word(2));
default:
return 0;
}
}
-static uint32_t get_shader_stage_id(VkShaderStageFlagBits stage) {
+static uint32_t GetShaderStageId(VkShaderStageFlagBits stage) {
uint32_t bit_pos = uint32_t(u_ffs(stage));
return bit_pos - 1;
}
-static spirv_inst_iter get_struct_type(shader_module const *src, spirv_inst_iter def, bool is_array_of_verts) {
+static spirv_inst_iter GetStructType(shader_module const *src, spirv_inst_iter def, bool is_array_of_verts) {
while (true) {
if (def.opcode() == spv::OpTypePointer) {
def = src->get_def(def.word(3));
@@ -454,11 +454,11 @@
}
}
-static bool collect_interface_block_members(shader_module const *src, std::map<location_t, interface_var> *out,
- std::unordered_map<unsigned, unsigned> const &blocks, bool is_array_of_verts,
- uint32_t id, uint32_t type_id, bool is_patch, int /*first_location*/) {
+static bool CollectInterfaceBlockMembers(shader_module const *src, std::map<location_t, interface_var> *out,
+ std::unordered_map<unsigned, unsigned> const &blocks, bool is_array_of_verts, uint32_t id,
+ uint32_t type_id, bool is_patch, int /*first_location*/) {
// Walk down the type_id presented, trying to determine whether it's actually an interface block.
- auto type = get_struct_type(src, src->get_def(type_id), is_array_of_verts && !is_patch);
+ auto type = GetStructType(src, src->get_def(type_id), is_array_of_verts && !is_patch);
if (type == src->end() || blocks.find(type.word(1)) == blocks.end()) {
// This isn't an interface block.
return false;
@@ -498,7 +498,7 @@
if (insn.word(3) == spv::DecorationLocation) {
unsigned location = insn.word(4);
- unsigned num_locations = get_locations_consumed_by_type(src, member_type_id, false);
+ unsigned num_locations = GetLocationsConsumedByType(src, member_type_id, false);
auto component_it = member_components.find(member_index);
unsigned component = component_it == member_components.end() ? 0 : component_it->second;
bool is_relaxed_precision = member_relaxed_precision.find(member_index) != member_relaxed_precision.end();
@@ -522,8 +522,8 @@
return true;
}
-static std::map<location_t, interface_var> collect_interface_by_location(shader_module const *src, spirv_inst_iter entrypoint,
- spv::StorageClass sinterface, bool is_array_of_verts) {
+static std::map<location_t, interface_var> CollectInterfaceByLocation(shader_module const *src, spirv_inst_iter entrypoint,
+ spv::StorageClass sinterface, bool is_array_of_verts) {
std::unordered_map<unsigned, unsigned> var_locations;
std::unordered_map<unsigned, unsigned> var_builtins;
std::unordered_map<unsigned, unsigned> var_components;
@@ -583,18 +583,18 @@
unsigned id = insn.word(2);
unsigned type = insn.word(1);
- int location = value_or_default(var_locations, id, static_cast<unsigned>(-1));
- int builtin = value_or_default(var_builtins, id, static_cast<unsigned>(-1));
- unsigned component = value_or_default(var_components, id, 0); // Unspecified is OK, is 0
+ int location = ValueOrDefault(var_locations, id, static_cast<unsigned>(-1));
+ int builtin = ValueOrDefault(var_builtins, id, static_cast<unsigned>(-1));
+ unsigned component = ValueOrDefault(var_components, id, 0); // Unspecified is OK, is 0
bool is_patch = var_patch.find(id) != var_patch.end();
bool is_relaxed_precision = var_relaxed_precision.find(id) != var_relaxed_precision.end();
if (builtin != -1)
continue;
- else if (!collect_interface_block_members(src, &out, blocks, is_array_of_verts, id, type, is_patch, location)) {
+ else if (!CollectInterfaceBlockMembers(src, &out, blocks, is_array_of_verts, id, type, is_patch, location)) {
// A user-defined interface variable, with a location. Where a variable occupied multiple locations, emit
// one result for each.
- unsigned num_locations = get_locations_consumed_by_type(src, type, is_array_of_verts && !is_patch);
+ unsigned num_locations = GetLocationsConsumedByType(src, type, is_array_of_verts && !is_patch);
for (unsigned int offset = 0; offset < num_locations; offset++) {
interface_var v = {};
v.id = id;
@@ -611,7 +611,7 @@
return out;
}
-static std::vector<std::pair<uint32_t, interface_var>> collect_interface_by_input_attachment_index(
+static std::vector<std::pair<uint32_t, interface_var>> CollectInterfaceByInputAttachmentIndex(
shader_module const *src, std::unordered_set<uint32_t> const &accessible_ids) {
std::vector<std::pair<uint32_t, interface_var>> out;
@@ -626,7 +626,7 @@
assert(def != src->end());
if (def.opcode() == spv::OpVariable && insn.word(3) == spv::StorageClassUniformConstant) {
- auto num_locations = get_locations_consumed_by_type(src, def.word(1), false);
+ auto num_locations = GetLocationsConsumedByType(src, def.word(1), false);
for (unsigned int offset = 0; offset < num_locations; offset++) {
interface_var v = {};
v.id = id;
@@ -643,7 +643,7 @@
return out;
}
-static bool is_writable_descriptor_type(shader_module const *module, uint32_t type_id) {
+static bool IsWritableDescriptorType(shader_module const *module, uint32_t type_id) {
auto type = module->get_def(type_id);
// Strip off any array or ptrs. Where we remove array levels, adjust the descriptor count for each dimension.
@@ -678,7 +678,7 @@
return false;
}
-static std::vector<std::pair<descriptor_slot_t, interface_var>> collect_interface_by_descriptor_slot(
+static std::vector<std::pair<descriptor_slot_t, interface_var>> CollectInterfaceByDescriptorSlot(
debug_report_data const *report_data, shader_module const *src, std::unordered_set<uint32_t> const &accessible_ids,
bool *has_writable_descriptor) {
std::unordered_map<unsigned, unsigned> var_sets;
@@ -712,15 +712,15 @@
if (insn.opcode() == spv::OpVariable &&
(insn.word(3) == spv::StorageClassUniform || insn.word(3) == spv::StorageClassUniformConstant ||
insn.word(3) == spv::StorageClassStorageBuffer)) {
- unsigned set = value_or_default(var_sets, insn.word(2), 0);
- unsigned binding = value_or_default(var_bindings, insn.word(2), 0);
+ unsigned set = ValueOrDefault(var_sets, insn.word(2), 0);
+ unsigned binding = ValueOrDefault(var_bindings, insn.word(2), 0);
interface_var v = {};
v.id = insn.word(2);
v.type_id = insn.word(1);
out.emplace_back(std::make_pair(set, binding), v);
- if (var_nonwritable.find(id) == var_nonwritable.end() && is_writable_descriptor_type(src, insn.word(1))) {
+ if (var_nonwritable.find(id) == var_nonwritable.end() && IsWritableDescriptorType(src, insn.word(1))) {
*has_writable_descriptor = true;
}
}
@@ -729,7 +729,7 @@
return out;
}
-static bool validate_vi_consistency(debug_report_data const *report_data, VkPipelineVertexInputStateCreateInfo const *vi) {
+static bool ValidateViConsistency(debug_report_data const *report_data, VkPipelineVertexInputStateCreateInfo const *vi) {
// Walk the binding descriptions, which describe the step rate and stride of each vertex buffer. Each binding should
// be specified only once.
std::unordered_map<uint32_t, VkVertexInputBindingDescription const *> bindings;
@@ -751,17 +751,17 @@
return skip;
}
-static bool validate_vi_against_vs_inputs(debug_report_data const *report_data, VkPipelineVertexInputStateCreateInfo const *vi,
- shader_module const *vs, spirv_inst_iter entrypoint) {
+static bool ValidateViAgainstVsInputs(debug_report_data const *report_data, VkPipelineVertexInputStateCreateInfo const *vi,
+ shader_module const *vs, spirv_inst_iter entrypoint) {
bool skip = false;
- auto inputs = collect_interface_by_location(vs, entrypoint, spv::StorageClassInput, false);
+ auto inputs = CollectInterfaceByLocation(vs, entrypoint, spv::StorageClassInput, false);
// Build index by location
std::map<uint32_t, VkVertexInputAttributeDescription const *> attribs;
if (vi) {
for (unsigned i = 0; i < vi->vertexAttributeDescriptionCount; i++) {
- auto num_locations = get_locations_consumed_by_format(vi->pVertexAttributeDescriptions[i].format);
+ auto num_locations = GetLocationsConsumedByFormat(vi->pVertexAttributeDescriptions[i].format);
for (auto j = 0u; j < num_locations; j++) {
attribs[vi->pVertexAttributeDescriptions[i].location + j] = &vi->pVertexAttributeDescriptions[i];
}
@@ -792,15 +792,15 @@
"Vertex shader consumes input at location %d but not provided", b_first);
it_b++;
} else {
- unsigned attrib_type = get_format_type(it_a->second->format);
- unsigned input_type = get_fundamental_type(vs, it_b->second.type_id);
+ unsigned attrib_type = GetFormatType(it_a->second->format);
+ unsigned input_type = GetFundamentalType(vs, it_b->second.type_id);
// Type checking
if (!(attrib_type & input_type)) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
HandleToUint64(vs->vk_shader_module), kVUID_Core_Shader_InterfaceTypeMismatch,
"Attribute type of `%s` at location %d does not match vertex shader input type of `%s`",
- string_VkFormat(it_a->second->format), a_first, describe_type(vs, it_b->second.type_id).c_str());
+ string_VkFormat(it_a->second->format), a_first, DescribeType(vs, it_b->second.type_id).c_str());
}
// OK!
@@ -812,9 +812,8 @@
return skip;
}
-static bool validate_fs_outputs_against_render_pass(debug_report_data const *report_data, shader_module const *fs,
- spirv_inst_iter entrypoint, PIPELINE_STATE const *pipeline,
- uint32_t subpass_index) {
+static bool ValidateFsOutputsAgainstRenderPass(debug_report_data const *report_data, shader_module const *fs,
+ spirv_inst_iter entrypoint, PIPELINE_STATE const *pipeline, uint32_t subpass_index) {
auto rpci = pipeline->rp_state->createInfo.ptr();
std::map<uint32_t, VkFormat> color_attachments;
@@ -831,7 +830,7 @@
// TODO: dual source blend index (spv::DecIndex, zero if not provided)
- auto outputs = collect_interface_by_location(fs, entrypoint, spv::StorageClassOutput, false);
+ auto outputs = CollectInterfaceByLocation(fs, entrypoint, spv::StorageClassOutput, false);
auto it_a = outputs.begin();
auto it_b = color_attachments.begin();
@@ -857,15 +856,15 @@
}
it_b++;
} else {
- unsigned output_type = get_fundamental_type(fs, it_a->second.type_id);
- unsigned att_type = get_format_type(it_b->second);
+ unsigned output_type = GetFundamentalType(fs, it_a->second.type_id);
+ unsigned att_type = GetFormatType(it_b->second);
// Type checking
if (!(output_type & att_type)) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
HandleToUint64(fs->vk_shader_module), kVUID_Core_Shader_InterfaceTypeMismatch,
"Attachment %d of type `%s` does not match fragment shader output type of `%s`", it_b->first,
- string_VkFormat(it_b->second), describe_type(fs, it_a->second.type_id).c_str());
+ string_VkFormat(it_b->second), DescribeType(fs, it_a->second.type_id).c_str());
}
// OK!
@@ -884,7 +883,7 @@
//
// TODO: The set of interesting opcodes here was determined by eyeballing the SPIRV spec. It might be worth
// converting parts of this to be generated from the machine-readable spec instead.
-static std::unordered_set<uint32_t> mark_accessible_ids(shader_module const *src, spirv_inst_iter entrypoint) {
+static std::unordered_set<uint32_t> MarkAccessibleIds(shader_module const *src, spirv_inst_iter entrypoint) {
std::unordered_set<uint32_t> ids;
std::unordered_set<uint32_t> worklist;
worklist.insert(entrypoint.word(2));
@@ -896,7 +895,7 @@
auto insn = src->get_def(id);
if (insn == src->end()) {
- // ID is something we didn't collect in build_def_index. that's OK -- we'll stumble across all kinds of things here
+ // ID is something we didn't collect in BuildDefIndex. that's OK -- we'll stumble across all kinds of things here
// that we may not care about.
continue;
}
@@ -995,14 +994,13 @@
return ids;
}
-static bool validate_push_constant_block_against_pipeline(debug_report_data const *report_data,
- std::vector<VkPushConstantRange> const *push_constant_ranges,
- shader_module const *src, spirv_inst_iter type,
- VkShaderStageFlagBits stage) {
+static bool ValidatePushConstantBlockAgainstPipeline(debug_report_data const *report_data,
+ std::vector<VkPushConstantRange> const *push_constant_ranges,
+ shader_module const *src, spirv_inst_iter type, VkShaderStageFlagBits stage) {
bool skip = false;
// Strip off ptrs etc
- type = get_struct_type(src, type, false);
+ type = GetStructType(src, type, false);
assert(type != src->end());
// Validate directly off the offsets. this isn't quite correct for arrays and matrices, but is a good first step.
@@ -1042,16 +1040,16 @@
return skip;
}
-static bool validate_push_constant_usage(debug_report_data const *report_data,
- std::vector<VkPushConstantRange> const *push_constant_ranges, shader_module const *src,
- std::unordered_set<uint32_t> accessible_ids, VkShaderStageFlagBits stage) {
+static bool ValidatePushConstantUsage(debug_report_data const *report_data,
+ std::vector<VkPushConstantRange> const *push_constant_ranges, shader_module const *src,
+ std::unordered_set<uint32_t> accessible_ids, VkShaderStageFlagBits stage) {
bool skip = false;
for (auto id : accessible_ids) {
auto def_insn = src->get_def(id);
if (def_insn.opcode() == spv::OpVariable && def_insn.word(3) == spv::StorageClassPushConstant) {
- skip |= validate_push_constant_block_against_pipeline(report_data, push_constant_ranges, src,
- src->get_def(def_insn.word(1)), stage);
+ skip |= ValidatePushConstantBlockAgainstPipeline(report_data, push_constant_ranges, src, src->get_def(def_insn.word(1)),
+ stage);
}
}
@@ -1059,7 +1057,7 @@
}
// Validate that data for each specialization entry is fully contained within the buffer.
-static bool validate_specialization_offsets(debug_report_data const *report_data, VkPipelineShaderStageCreateInfo const *info) {
+static bool ValidateSpecializationOffsets(debug_report_data const *report_data, VkPipelineShaderStageCreateInfo const *info) {
bool skip = false;
VkSpecializationInfo const *spec = info->pSpecializationInfo;
@@ -1081,8 +1079,8 @@
return skip;
}
-static bool descriptor_type_match(shader_module const *module, uint32_t type_id, VkDescriptorType descriptor_type,
- unsigned &descriptor_count) {
+static bool DescriptorTypeMatch(shader_module const *module, uint32_t type_id, VkDescriptorType descriptor_type,
+ unsigned &descriptor_count) {
auto type = module->get_def(type_id);
bool is_storage_buffer = false;
descriptor_count = 1;
@@ -1093,7 +1091,7 @@
descriptor_count = 0;
type = module->get_def(type.word(2));
} else if (type.opcode() == spv::OpTypeArray) {
- descriptor_count *= get_constant_value(module, type.word(3));
+ descriptor_count *= GetConstantValue(module, type.word(3));
type = module->get_def(type.word(2));
} else {
if (type.word(2) == spv::StorageClassStorageBuffer) {
@@ -1168,7 +1166,7 @@
}
}
-static bool require_feature(debug_report_data const *report_data, VkBool32 feature, char const *feature_name) {
+static bool RequireFeature(debug_report_data const *report_data, VkBool32 feature, char const *feature_name) {
if (!feature) {
if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_FeatureNotEnabled, "Shader requires %s but is not enabled on the device", feature_name)) {
@@ -1179,7 +1177,7 @@
return false;
}
-static bool require_extension(debug_report_data const *report_data, bool extension, char const *extension_name) {
+static bool RequireExtension(debug_report_data const *report_data, bool extension, char const *extension_name) {
if (!extension) {
if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_FeatureNotEnabled, "Shader requires extension %s but is not enabled on the device",
@@ -1191,8 +1189,8 @@
return false;
}
-static bool validate_shader_capabilities(layer_data *dev_data, shader_module const *src, VkShaderStageFlagBits stage,
- bool has_writable_descriptor) {
+static bool ValidateShaderCapabilities(layer_data *dev_data, shader_module const *src, VkShaderStageFlagBits stage,
+ bool has_writable_descriptor) {
bool skip = false;
auto report_data = GetReportData(dev_data);
@@ -1292,10 +1290,10 @@
auto it = capabilities.find(insn.word(1));
if (it != capabilities.end()) {
if (it->second.feature) {
- skip |= require_feature(report_data, *(it->second.feature), it->second.name);
+ skip |= RequireFeature(report_data, *(it->second.feature), it->second.name);
}
if (it->second.extension) {
- skip |= require_extension(report_data, *(it->second.extension), it->second.name);
+ skip |= RequireExtension(report_data, *(it->second.extension), it->second.name);
}
}
} else if (1 < n) { // key occurs multiple times, at least one must be enabled
@@ -1320,11 +1318,11 @@
}
if (needs_feature) {
feature_names += "]";
- skip |= require_feature(report_data, has_feature, feature_names.c_str());
+ skip |= RequireFeature(report_data, has_feature, feature_names.c_str());
}
if (needs_ext) {
extension_names += "]";
- skip |= require_extension(report_data, has_ext, extension_names.c_str());
+ skip |= RequireExtension(report_data, has_ext, extension_names.c_str());
}
}
}
@@ -1337,11 +1335,11 @@
* stage */
break;
case VK_SHADER_STAGE_FRAGMENT_BIT:
- skip |= require_feature(report_data, enabledFeatures->fragmentStoresAndAtomics, "fragmentStoresAndAtomics");
+ skip |= RequireFeature(report_data, enabledFeatures->fragmentStoresAndAtomics, "fragmentStoresAndAtomics");
break;
default:
skip |=
- require_feature(report_data, enabledFeatures->vertexPipelineStoresAndAtomics, "vertexPipelineStoresAndAtomics");
+ RequireFeature(report_data, enabledFeatures->vertexPipelineStoresAndAtomics, "vertexPipelineStoresAndAtomics");
break;
}
}
@@ -1349,7 +1347,7 @@
return skip;
}
-static uint32_t descriptor_type_to_reqs(shader_module const *module, uint32_t type_id) {
+static uint32_t DescriptorTypeToReqs(shader_module const *module, uint32_t type_id) {
auto type = module->get_def(type_id);
while (true) {
@@ -1390,8 +1388,8 @@
// For given pipelineLayout verify that the set_layout_node at slot.first
// has the requested binding at slot.second and return ptr to that binding
-static VkDescriptorSetLayoutBinding const *get_descriptor_binding(PIPELINE_LAYOUT_NODE const *pipelineLayout,
- descriptor_slot_t slot) {
+static VkDescriptorSetLayoutBinding const *GetDescriptorBinding(PIPELINE_LAYOUT_NODE const *pipelineLayout,
+ descriptor_slot_t slot) {
if (!pipelineLayout) return nullptr;
if (slot.first >= pipelineLayout->set_layouts.size()) return nullptr;
@@ -1399,7 +1397,7 @@
return pipelineLayout->set_layouts[slot.first]->GetDescriptorSetLayoutBindingPtrFromBinding(slot.second);
}
-static void process_execution_modes(shader_module const *src, spirv_inst_iter entrypoint, PIPELINE_STATE *pipeline) {
+static void ProcessExecutionModes(shader_module const *src, spirv_inst_iter entrypoint, PIPELINE_STATE *pipeline) {
auto entrypoint_id = entrypoint.word(1);
bool is_point_mode = false;
@@ -1432,9 +1430,9 @@
if (is_point_mode) pipeline->topology_at_rasterizer = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
}
-static bool validate_pipeline_shader_stage(layer_data *dev_data, VkPipelineShaderStageCreateInfo const *pStage,
- PIPELINE_STATE *pipeline, shader_module const **out_module,
- spirv_inst_iter *out_entrypoint) {
+static bool ValidatePipelineShaderStage(layer_data *dev_data, VkPipelineShaderStageCreateInfo const *pStage,
+ PIPELINE_STATE *pipeline, shader_module const **out_module,
+ spirv_inst_iter *out_entrypoint) {
bool skip = false;
auto module = *out_module = GetShaderModuleState(dev_data, pStage->module);
auto report_data = GetReportData(dev_data);
@@ -1442,7 +1440,7 @@
if (!module->has_valid_spirv) return false;
// Find the entrypoint
- auto entrypoint = *out_entrypoint = find_entrypoint(module, pStage->pName, pStage->stage);
+ auto entrypoint = *out_entrypoint = FindEntrypoint(module, pStage->pName, pStage->stage);
if (entrypoint == module->end()) {
if (log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
"VUID-VkPipelineShaderStageCreateInfo-pName-00707", "No entrypoint found named `%s` for stage %s..",
@@ -1452,59 +1450,59 @@
}
// Mark accessible ids
- auto accessible_ids = mark_accessible_ids(module, entrypoint);
- process_execution_modes(module, entrypoint, pipeline);
+ auto accessible_ids = MarkAccessibleIds(module, entrypoint);
+ ProcessExecutionModes(module, entrypoint, pipeline);
// Validate descriptor set layout against what the entrypoint actually uses
bool has_writable_descriptor = false;
- auto descriptor_uses = collect_interface_by_descriptor_slot(report_data, module, accessible_ids, &has_writable_descriptor);
+ auto descriptor_uses = CollectInterfaceByDescriptorSlot(report_data, module, accessible_ids, &has_writable_descriptor);
// Validate shader capabilities against enabled device features
- skip |= validate_shader_capabilities(dev_data, module, pStage->stage, has_writable_descriptor);
+ skip |= ValidateShaderCapabilities(dev_data, module, pStage->stage, has_writable_descriptor);
- skip |= validate_specialization_offsets(report_data, pStage);
- skip |= validate_push_constant_usage(report_data, pipeline->pipeline_layout.push_constant_ranges.get(), module, accessible_ids,
- pStage->stage);
+ skip |= ValidateSpecializationOffsets(report_data, pStage);
+ skip |= ValidatePushConstantUsage(report_data, pipeline->pipeline_layout.push_constant_ranges.get(), module, accessible_ids,
+ pStage->stage);
// Validate descriptor use
for (auto use : descriptor_uses) {
// While validating shaders capture which slots are used by the pipeline
auto &reqs = pipeline->active_slots[use.first.first][use.first.second];
- reqs = descriptor_req(reqs | descriptor_type_to_reqs(module, use.second.type_id));
+ reqs = descriptor_req(reqs | DescriptorTypeToReqs(module, use.second.type_id));
// Verify given pipelineLayout has requested setLayout with requested binding
- const auto &binding = get_descriptor_binding(&pipeline->pipeline_layout, use.first);
+ const auto &binding = GetDescriptorBinding(&pipeline->pipeline_layout, use.first);
unsigned required_descriptor_count;
if (!binding) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_MissingDescriptor,
"Shader uses descriptor slot %u.%u (used as type `%s`) but not declared in pipeline layout",
- use.first.first, use.first.second, describe_type(module, use.second.type_id).c_str());
+ use.first.first, use.first.second, DescribeType(module, use.second.type_id).c_str());
} else if (~binding->stageFlags & pStage->stage) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, 0,
kVUID_Core_Shader_DescriptorNotAccessibleFromStage,
"Shader uses descriptor slot %u.%u (used as type `%s`) but descriptor not accessible from stage %s",
- use.first.first, use.first.second, describe_type(module, use.second.type_id).c_str(),
+ use.first.first, use.first.second, DescribeType(module, use.second.type_id).c_str(),
string_VkShaderStageFlagBits(pStage->stage));
- } else if (!descriptor_type_match(module, use.second.type_id, binding->descriptorType, required_descriptor_count)) {
+ } else if (!DescriptorTypeMatch(module, use.second.type_id, binding->descriptorType, required_descriptor_count)) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_DescriptorTypeMismatch,
"Type mismatch on descriptor slot %u.%u (used as type `%s`) but descriptor of type %s", use.first.first,
- use.first.second, describe_type(module, use.second.type_id).c_str(),
+ use.first.second, DescribeType(module, use.second.type_id).c_str(),
string_VkDescriptorType(binding->descriptorType));
} else if (binding->descriptorCount < required_descriptor_count) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_DescriptorTypeMismatch,
"Shader expects at least %u descriptors for binding %u.%u (used as type `%s`) but only %u provided",
required_descriptor_count, use.first.first, use.first.second,
- describe_type(module, use.second.type_id).c_str(), binding->descriptorCount);
+ DescribeType(module, use.second.type_id).c_str(), binding->descriptorCount);
}
}
// Validate use of input attachments against subpass structure
if (pStage->stage == VK_SHADER_STAGE_FRAGMENT_BIT) {
- auto input_attachment_uses = collect_interface_by_input_attachment_index(module, accessible_ids);
+ auto input_attachment_uses = CollectInterfaceByInputAttachmentIndex(module, accessible_ids);
auto rpci = pipeline->rp_state->createInfo.ptr();
auto subpass = pipeline->graphicsPipelineCI.subpass;
@@ -1519,12 +1517,12 @@
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_MissingInputAttachment,
"Shader consumes input attachment index %d but not provided in subpass", use.first);
- } else if (!(get_format_type(rpci->pAttachments[index].format) & get_fundamental_type(module, use.second.type_id))) {
+ } else if (!(GetFormatType(rpci->pAttachments[index].format) & GetFundamentalType(module, use.second.type_id))) {
skip |=
log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, 0,
kVUID_Core_Shader_InputAttachmentTypeMismatch,
"Subpass input attachment %u format of %s does not match type used in shader `%s`", use.first,
- string_VkFormat(rpci->pAttachments[index].format), describe_type(module, use.second.type_id).c_str());
+ string_VkFormat(rpci->pAttachments[index].format), DescribeType(module, use.second.type_id).c_str());
}
}
}
@@ -1532,16 +1530,15 @@
return skip;
}
-static bool validate_interface_between_stages(debug_report_data const *report_data, shader_module const *producer,
- spirv_inst_iter producer_entrypoint, shader_stage_attributes const *producer_stage,
- shader_module const *consumer, spirv_inst_iter consumer_entrypoint,
- shader_stage_attributes const *consumer_stage) {
+static bool ValidateInterfaceBetweenStages(debug_report_data const *report_data, shader_module const *producer,
+ spirv_inst_iter producer_entrypoint, shader_stage_attributes const *producer_stage,
+ shader_module const *consumer, spirv_inst_iter consumer_entrypoint,
+ shader_stage_attributes const *consumer_stage) {
bool skip = false;
auto outputs =
- collect_interface_by_location(producer, producer_entrypoint, spv::StorageClassOutput, producer_stage->arrayed_output);
- auto inputs =
- collect_interface_by_location(consumer, consumer_entrypoint, spv::StorageClassInput, consumer_stage->arrayed_input);
+ CollectInterfaceByLocation(producer, producer_entrypoint, spv::StorageClassOutput, producer_stage->arrayed_output);
+ auto inputs = CollectInterfaceByLocation(consumer, consumer_entrypoint, spv::StorageClassInput, consumer_stage->arrayed_input);
auto a_it = outputs.begin();
auto b_it = inputs.begin();
@@ -1570,14 +1567,14 @@
// - if is_patch, then the member is not arrayed, even though the interface may be.
// - if is_block_member, then the extra array level of an arrayed interface is not
// expressed in the member type -- it's expressed in the block type.
- if (!types_match(producer, consumer, a_it->second.type_id, b_it->second.type_id,
- producer_stage->arrayed_output && !a_it->second.is_patch && !a_it->second.is_block_member,
- consumer_stage->arrayed_input && !b_it->second.is_patch && !b_it->second.is_block_member, true)) {
+ if (!TypesMatch(producer, consumer, a_it->second.type_id, b_it->second.type_id,
+ producer_stage->arrayed_output && !a_it->second.is_patch && !a_it->second.is_block_member,
+ consumer_stage->arrayed_input && !b_it->second.is_patch && !b_it->second.is_block_member, true)) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
HandleToUint64(producer->vk_shader_module), kVUID_Core_Shader_InterfaceTypeMismatch,
"Type mismatch on location %u.%u: '%s' vs '%s'", a_first.first, a_first.second,
- describe_type(producer, a_it->second.type_id).c_str(),
- describe_type(consumer, b_it->second.type_id).c_str());
+ DescribeType(producer, a_it->second.type_id).c_str(),
+ DescribeType(consumer, b_it->second.type_id).c_str());
}
if (a_it->second.is_patch != b_it->second.is_patch) {
skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
@@ -1602,10 +1599,10 @@
// Validate that the shaders used by the given pipeline and store the active_slots
// that are actually used by the pipeline into pPipeline->active_slots
-bool validate_and_capture_pipeline_shader_state(layer_data *dev_data, PIPELINE_STATE *pipeline) {
+bool ValidateAndCapturePipelineShaderState(layer_data *dev_data, PIPELINE_STATE *pipeline) {
auto pCreateInfo = pipeline->graphicsPipelineCI.ptr();
- int vertex_stage = get_shader_stage_id(VK_SHADER_STAGE_VERTEX_BIT);
- int fragment_stage = get_shader_stage_id(VK_SHADER_STAGE_FRAGMENT_BIT);
+ int vertex_stage = GetShaderStageId(VK_SHADER_STAGE_VERTEX_BIT);
+ int fragment_stage = GetShaderStageId(VK_SHADER_STAGE_FRAGMENT_BIT);
auto report_data = GetReportData(dev_data);
shader_module const *shaders[5];
@@ -1616,8 +1613,8 @@
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
auto pStage = &pCreateInfo->pStages[i];
- auto stage_id = get_shader_stage_id(pStage->stage);
- skip |= validate_pipeline_shader_stage(dev_data, pStage, pipeline, &shaders[stage_id], &entrypoints[stage_id]);
+ auto stage_id = GetShaderStageId(pStage->stage);
+ skip |= ValidatePipelineShaderStage(dev_data, pStage, pipeline, &shaders[stage_id], &entrypoints[stage_id]);
}
// if the shader stages are no good individually, cross-stage validation is pointless.
@@ -1626,15 +1623,15 @@
auto vi = pCreateInfo->pVertexInputState;
if (vi) {
- skip |= validate_vi_consistency(report_data, vi);
+ skip |= ValidateViConsistency(report_data, vi);
}
if (shaders[vertex_stage] && shaders[vertex_stage]->has_valid_spirv) {
- skip |= validate_vi_against_vs_inputs(report_data, vi, shaders[vertex_stage], entrypoints[vertex_stage]);
+ skip |= ValidateViAgainstVsInputs(report_data, vi, shaders[vertex_stage], entrypoints[vertex_stage]);
}
- int producer = get_shader_stage_id(VK_SHADER_STAGE_VERTEX_BIT);
- int consumer = get_shader_stage_id(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
+ int producer = GetShaderStageId(VK_SHADER_STAGE_VERTEX_BIT);
+ int consumer = GetShaderStageId(VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT);
while (!shaders[producer] && producer != fragment_stage) {
producer++;
@@ -1645,9 +1642,9 @@
assert(shaders[producer]);
if (shaders[consumer]) {
if (shaders[consumer]->has_valid_spirv && shaders[producer]->has_valid_spirv) {
- skip |= validate_interface_between_stages(report_data, shaders[producer], entrypoints[producer],
- &shader_stage_attribs[producer], shaders[consumer], entrypoints[consumer],
- &shader_stage_attribs[consumer]);
+ skip |= ValidateInterfaceBetweenStages(report_data, shaders[producer], entrypoints[producer],
+ &shader_stage_attribs[producer], shaders[consumer], entrypoints[consumer],
+ &shader_stage_attribs[consumer]);
}
producer = consumer;
@@ -1655,20 +1652,20 @@
}
if (shaders[fragment_stage] && shaders[fragment_stage]->has_valid_spirv) {
- skip |= validate_fs_outputs_against_render_pass(report_data, shaders[fragment_stage], entrypoints[fragment_stage], pipeline,
- pCreateInfo->subpass);
+ skip |= ValidateFsOutputsAgainstRenderPass(report_data, shaders[fragment_stage], entrypoints[fragment_stage], pipeline,
+ pCreateInfo->subpass);
}
return skip;
}
-bool validate_compute_pipeline(layer_data *dev_data, PIPELINE_STATE *pipeline) {
+bool ValidateComputePipeline(layer_data *dev_data, PIPELINE_STATE *pipeline) {
auto pCreateInfo = pipeline->computePipelineCI.ptr();
shader_module const *module;
spirv_inst_iter entrypoint;
- return validate_pipeline_shader_stage(dev_data, &pCreateInfo->stage, pipeline, &module, &entrypoint);
+ return ValidatePipelineShaderStage(dev_data, &pCreateInfo->stage, pipeline, &module, &entrypoint);
}
uint32_t ValidationCache::MakeShaderHash(VkShaderModuleCreateInfo const *smci) { return XXH32(smci->pCode, smci->codeSize, 0); }