Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SaschaWillems committed Nov 2, 2024
1 parent 29e939b commit fb6c953
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions examples/triangle/triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class VulkanExample : public VulkanExampleBase
struct {
StagingBuffer vertices;
StagingBuffer indices;
} stagingBuffers;
} stagingBuffers{};

void* data;

Expand Down Expand Up @@ -373,7 +373,7 @@ class VulkanExample : public VulkanExampleBase
void createDescriptorPool()
{
// We need to tell the API the number of max. requested descriptors per type
VkDescriptorPoolSize descriptorTypeCounts[1];
VkDescriptorPoolSize descriptorTypeCounts[1]{};
// This example only one descriptor type (uniform buffer)
descriptorTypeCounts[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
// We have one buffer (and as such descriptor) per frame
Expand Down Expand Up @@ -508,7 +508,7 @@ class VulkanExample : public VulkanExampleBase
frameBuffers.resize(swapChain.imageCount);
for (size_t i = 0; i < frameBuffers.size(); i++)
{
std::array<VkImageView, 2> attachments;
std::array<VkImageView, 2> attachments{};
// Color attachment is the view of the swapchain image
attachments[0] = swapChain.buffers[i].view;
// Depth/Stencil attachment is the same for all frame buffers due to how depth works with current GPUs
Expand Down Expand Up @@ -587,7 +587,7 @@ class VulkanExample : public VulkanExampleBase
// Each subpass dependency will introduce a memory and execution dependency between the source and dest subpass described by
// srcStageMask, dstStageMask, srcAccessMask, dstAccessMask (and dependencyFlags is set)
// Note: VK_SUBPASS_EXTERNAL is a special constant that refers to all commands executed outside of the actual renderpass)
std::array<VkSubpassDependency, 2> dependencies;
std::array<VkSubpassDependency, 2> dependencies{};

// Does the transition from final to initial layout for the depth an color attachments
// Depth attachment
Expand Down Expand Up @@ -943,7 +943,7 @@ class VulkanExample : public VulkanExampleBase

// Set clear values for all framebuffer attachments with loadOp set to clear
// We use two attachments (color and depth) that are cleared at the start of the subpass and as such we need to set clear values for both
VkClearValue clearValues[2];
VkClearValue clearValues[2]{};
clearValues[0].color = { { 0.0f, 0.0f, 0.2f, 1.0f } };
clearValues[1].depthStencil = { 1.0f, 0 };

Expand Down Expand Up @@ -1056,7 +1056,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow)
int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR, _In_ int)
{
for (size_t i = 0; i < __argc; i++) { VulkanExample::args.push_back(__argv[i]); };
vulkanExample = new VulkanExample();
Expand Down
2 changes: 1 addition & 1 deletion examples/trianglevulkan13/trianglevulkan13.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class VulkanExample : public VulkanExampleBase
VK_CHECK_RESULT(vkAllocateMemory(device, &memAlloc, nullptr, &stagingBuffer.memory));
VK_CHECK_RESULT(vkBindBufferMemory(device, stagingBuffer.handle, stagingBuffer.memory, 0));
// Map the buffer and copy vertices and indices into it, this way we can use a single buffer as the source for both vertex and index GPU buffers
uint8_t* data;
uint8_t* data{ nullptr };
VK_CHECK_RESULT(vkMapMemory(device, stagingBuffer.memory, 0, memAlloc.allocationSize, 0, (void**)&data));
memcpy(data, vertices.data(), vertexBufferSize);
memcpy(((char*)data) + vertexBufferSize, indices.data(), vertexBufferSize);
Expand Down

0 comments on commit fb6c953

Please sign in to comment.