Skip to content

Commit ce9b481

Browse files
refactor: Use clang-tidy on layers/*.cpp files
This change was automatically generated with the following clang-tidy checks: - -* - google* - readability-identifier-naming - -google-readability-todo Plus the following check options: - readability-identifier-naming.VariableCase - readability-identifier-naming.GlobalConstantCase - readability-identifier-naming.GlobalConstantPrefix Plus the following "one-time regex fixups": - s/(^+.*\W)p_(semaphore|fence|cb|queue)(\W)/\1\2_state\3/g: fix duplicate variable names - s/(^+.*\W)p_([a-z])/\1\2/g: fix non-function-parameter variable names with p prefix Change-Id: I518ef21643e1850f9dd5539d5fb5e039ce31eeb5
1 parent a6c67fb commit ce9b481

21 files changed

+2080
-1957
lines changed

.clang-tidy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Checks: '-*,google*,readability-identifier-naming,-google-readability-todo'
2+
CheckOptions:
3+
- { key: readability-identifier-naming.VariableCase, value: lower_case }
4+
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
5+
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k }

layers/best_practices_utils.cpp

Lines changed: 66 additions & 57 deletions
Large diffs are not rendered by default.

layers/buffer_validation.cpp

Lines changed: 132 additions & 123 deletions
Large diffs are not rendered by default.

layers/convert_to_renderpass2.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,30 +188,30 @@ void ConvertVkRenderPassCreateInfoToV2KHR(const VkRenderPassCreateInfo& in_struc
188188
for (uint32_t i = 0; i < input_attachment_aspect_info->aspectReferenceCount; ++i) {
189189
const uint32_t subpass = input_attachment_aspect_info->pAspectReferences[i].subpass;
190190
const uint32_t input_attachment = input_attachment_aspect_info->pAspectReferences[i].inputAttachmentIndex;
191-
const VkImageAspectFlags aspectMask = input_attachment_aspect_info->pAspectReferences[i].aspectMask;
191+
const VkImageAspectFlags aspect_mask = input_attachment_aspect_info->pAspectReferences[i].aspectMask;
192192

193193
if (subpass < input_attachment_aspect_masks.size() &&
194194
input_attachment < input_attachment_aspect_masks[subpass].size()) {
195-
input_attachment_aspect_masks[subpass][input_attachment] = aspectMask;
195+
input_attachment_aspect_masks[subpass][input_attachment] = aspect_mask;
196196
}
197197
}
198198
}
199199

200-
const bool has_viewMask = multiview_info && multiview_info->subpassCount && multiview_info->pViewMasks;
200+
const bool has_view_mask = multiview_info && multiview_info->subpassCount && multiview_info->pViewMasks;
201201
if (out_struct->subpassCount && in_struct.pSubpasses) {
202202
out_struct->pSubpasses = new safe_VkSubpassDescription2[out_struct->subpassCount];
203203
for (uint32_t i = 0; i < out_struct->subpassCount; ++i) {
204-
const uint32_t viewMask = has_viewMask ? multiview_info->pViewMasks[i] : 0;
205-
out_struct->pSubpasses[i] = ToV2KHR(in_struct.pSubpasses[i], viewMask, input_attachment_aspect_masks[i].data());
204+
const uint32_t view_mask = has_view_mask ? multiview_info->pViewMasks[i] : 0;
205+
out_struct->pSubpasses[i] = ToV2KHR(in_struct.pSubpasses[i], view_mask, input_attachment_aspect_masks[i].data());
206206
}
207207
}
208208

209-
const bool has_viewOffset = multiview_info && multiview_info->dependencyCount && multiview_info->pViewOffsets;
209+
const bool has_view_offset = multiview_info && multiview_info->dependencyCount && multiview_info->pViewOffsets;
210210
if (out_struct->dependencyCount && in_struct.pDependencies) {
211211
out_struct->pDependencies = new safe_VkSubpassDependency2[out_struct->dependencyCount];
212212
for (uint32_t i = 0; i < out_struct->dependencyCount; ++i) {
213-
const int32_t viewOffset = has_viewOffset ? multiview_info->pViewOffsets[i] : 0;
214-
out_struct->pDependencies[i] = ToV2KHR(in_struct.pDependencies[i], viewOffset);
213+
const int32_t view_offset = has_view_offset ? multiview_info->pViewOffsets[i] : 0;
214+
out_struct->pDependencies[i] = ToV2KHR(in_struct.pDependencies[i], view_offset);
215215
}
216216
}
217217

layers/core_validation.cpp

Lines changed: 804 additions & 750 deletions
Large diffs are not rendered by default.

layers/debug_printf.cpp

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ bool DebugPrintf::InstrumentShader(const VkShaderModuleCreateInfo *pCreateInfo,
285285
opt_options.set_run_validator(true);
286286
opt_options.set_validator_options(val_options);
287287
Optimizer optimizer(target_env);
288-
const spvtools::MessageConsumer DebugPrintfConsoleMessageConsumer =
288+
const spvtools::MessageConsumer debug_printf_console_message_consumer =
289289
[this](spv_message_level_t level, const char *, const spv_position_t &position, const char *message) -> void {
290290
switch (level) {
291291
case SPV_MSG_FATAL:
@@ -298,7 +298,7 @@ bool DebugPrintf::InstrumentShader(const VkShaderModuleCreateInfo *pCreateInfo,
298298
break;
299299
}
300300
};
301-
optimizer.SetMessageConsumer(DebugPrintfConsoleMessageConsumer);
301+
optimizer.SetMessageConsumer(debug_printf_console_message_consumer);
302302
optimizer.RegisterPass(CreateInstDebugPrintfPass(desc_set_bind_index, unique_shader_module_id));
303303
bool pass = optimizer.Run(new_pgm.data(), new_pgm.size(), &new_pgm, opt_options);
304304
if (!pass) {
@@ -372,10 +372,10 @@ std::vector<DPFSubstring> DebugPrintf::ParseFormatString(const std::string forma
372372
}
373373
// Find the type of the value
374374
pos = format_string.find_first_of(types, pos);
375-
if (pos == format_string.npos)
375+
if (pos == format_string.npos) {
376376
// This really shouldn't happen with a legal value string
377377
pos = format_string.length();
378-
else {
378+
} else {
379379
char tempstring[32];
380380
int count = 0;
381381
std::string specifier = {};
@@ -537,13 +537,14 @@ void DebugPrintf::AnalyzeAndGenerateMessages(VkCommandBuffer command_buffer, VkQ
537537
break;
538538
}
539539
values = static_cast<uint32_t *>(values) + 1;
540-
} else
540+
} else {
541541
needed = snprintf(temp_string, static_size, substring.string.c_str());
542+
}
542543
}
543544

544-
if (needed < static_size)
545+
if (needed < static_size) {
545546
shader_message << temp_string;
546-
else {
547+
} else {
547548
// Static buffer not big enough for message, use malloc to get enough
548549
snprintf_with_malloc(shader_message, substring, needed, values);
549550
}
@@ -601,8 +602,8 @@ void DebugPrintf::PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount,
601602
for (uint32_t i = 0; i < submit->commandBufferCount; i++) {
602603
auto cb_node = GetCBState(submit->pCommandBuffers[i]);
603604
if (GetBufferInfo(cb_node->commandBuffer).size()) buffers_present = true;
604-
for (auto secondaryCmdBuffer : cb_node->linkedCommandBuffers) {
605-
if (GetBufferInfo(secondaryCmdBuffer->commandBuffer).size()) buffers_present = true;
605+
for (auto secondary_cmd_buffer : cb_node->linkedCommandBuffers) {
606+
if (GetBufferInfo(secondary_cmd_buffer->commandBuffer).size()) buffers_present = true;
606607
}
607608
}
608609
}
@@ -617,8 +618,8 @@ void DebugPrintf::PostCallRecordQueueSubmit(VkQueue queue, uint32_t submitCount,
617618
for (uint32_t i = 0; i < submit->commandBufferCount; i++) {
618619
auto cb_node = GetCBState(submit->pCommandBuffers[i]);
619620
UtilProcessInstrumentationBuffer(queue, cb_node, this);
620-
for (auto secondaryCmdBuffer : cb_node->linkedCommandBuffers) {
621-
UtilProcessInstrumentationBuffer(queue, secondaryCmdBuffer, this);
621+
for (auto secondary_cmd_buffer : cb_node->linkedCommandBuffers) {
622+
UtilProcessInstrumentationBuffer(queue, secondary_cmd_buffer, this);
622623
}
623624
}
624625
}
@@ -814,23 +815,23 @@ void DebugPrintf::AllocateDebugPrintfResources(const VkCommandBuffer cmd_buffer,
814815

815816
// Allocate memory for the output block that the gpu will use to return values for printf
816817
DPFDeviceMemoryBlock output_block = {};
817-
VkBufferCreateInfo bufferInfo = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
818-
bufferInfo.size = output_buffer_size;
819-
bufferInfo.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
820-
VmaAllocationCreateInfo allocInfo = {};
821-
allocInfo.usage = VMA_MEMORY_USAGE_GPU_TO_CPU;
822-
result = vmaCreateBuffer(vmaAllocator, &bufferInfo, &allocInfo, &output_block.buffer, &output_block.allocation, nullptr);
818+
VkBufferCreateInfo buffer_info = {VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
819+
buffer_info.size = output_buffer_size;
820+
buffer_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
821+
VmaAllocationCreateInfo alloc_info = {};
822+
alloc_info.usage = VMA_MEMORY_USAGE_GPU_TO_CPU;
823+
result = vmaCreateBuffer(vmaAllocator, &buffer_info, &alloc_info, &output_block.buffer, &output_block.allocation, nullptr);
823824
if (result != VK_SUCCESS) {
824825
ReportSetupProblem(device, "Unable to allocate device memory. Device could become unstable.");
825826
aborted = true;
826827
return;
827828
}
828829

829830
// Clear the output block to zeros so that only printf values from the gpu will be present
830-
uint32_t *pData;
831-
result = vmaMapMemory(vmaAllocator, output_block.allocation, (void **)&pData);
831+
uint32_t *data;
832+
result = vmaMapMemory(vmaAllocator, output_block.allocation, reinterpret_cast<void **>(&data));
832833
if (result == VK_SUCCESS) {
833-
memset(pData, 0, output_buffer_size);
834+
memset(data, 0, output_buffer_size);
834835
vmaUnmapMemory(vmaAllocator, output_block.allocation);
835836
}
836837

0 commit comments

Comments
 (0)