Skip to content

Commit

Permalink
merge in code changes from issue 3 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
mich-dy committed Dec 18, 2023
1 parent 4d6b437 commit 5f2124b
Show file tree
Hide file tree
Showing 789 changed files with 5,936 additions and 6,024 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you feel this book is for you, get your [copy](https://www.amazon.com/dp/1803
alt="https://www.packtpub.com/" border="5" /></a>

## Instructions and Navigations
All of the code is organized into folders.:w
All of the code is organized into folders.


**Following is what you need for this book:**
Expand Down
2 changes: 2 additions & 0 deletions chapter03/vulkan_renderer/vulkan/CommandBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "CommandBuffer.h"
#include "Logger.h"

#include <VkBootstrap.h>

bool CommandBuffer::init(VkRenderData &renderData, VkCommandBuffer &commandBuffer) {
VkCommandBufferAllocateInfo bufferAllocInfo{};
bufferAllocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
Expand Down
1 change: 0 additions & 1 deletion chapter03/vulkan_renderer/vulkan/CommandBuffer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Vulkan command buffers */
#pragma once

#include <vector>
#include <vulkan/vulkan.h>

#include "VkRenderData.h"
Expand Down
2 changes: 2 additions & 0 deletions chapter03/vulkan_renderer/vulkan/CommandPool.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "CommandPool.h"
#include "Logger.h"

#include <VkBootstrap.h>

bool CommandPool::init(VkRenderData &renderData) {
VkCommandPoolCreateInfo poolCreateInfo{};
poolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
Expand Down
1 change: 0 additions & 1 deletion chapter03/vulkan_renderer/vulkan/CommandPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#pragma once

#include <vulkan/vulkan.h>
#include <VkBootstrap.h>

#include "VkRenderData.h"

Expand Down
2 changes: 1 addition & 1 deletion chapter03/vulkan_renderer/vulkan/Framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bool Framebuffer::init(VkRenderData &renderData) {
FboInfo.layers = 1;

if (vkCreateFramebuffer(renderData.rdVkbDevice.device, &FboInfo, nullptr, &renderData.rdFramebuffers[i]) != VK_SUCCESS) {
Logger::log(1, "%s error: failed to create framebuffer %i", __FUNCTION__, i);
Logger::log(1, "%s error: failed to create framebuffer %i\n", __FUNCTION__, i);
return false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions chapter03/vulkan_renderer/vulkan/Pipeline.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <vector>

#include <VkBootstrap.h>

#include "Pipeline.h"
#include "Logger.h"
#include "Shader.h"
Expand Down
2 changes: 2 additions & 0 deletions chapter03/vulkan_renderer/vulkan/Renderpass.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "Renderpass.h"
#include "Logger.h"

#include <VkBootstrap.h>

bool Renderpass::init(VkRenderData &renderData) {
VkAttachmentDescription colorAtt{};
colorAtt.format = renderData.rdVkbSwapchain.image_format;
Expand Down
2 changes: 0 additions & 2 deletions chapter03/vulkan_renderer/vulkan/Renderpass.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* Renderpass as separate object */
#pragma once

/* Vulkan also before GLFW */
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>

#include "VkRenderData.h"

Expand Down
1 change: 0 additions & 1 deletion chapter03/vulkan_renderer/vulkan/Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <string>
#include <vulkan/vulkan.h>
#include <GLFW/glfw3.h>

class Shader {
public:
Expand Down
2 changes: 2 additions & 0 deletions chapter03/vulkan_renderer/vulkan/SyncObjects.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "SyncObjects.h"
#include "Logger.h"

#include <VkBootstrap.h>

bool SyncObjects::init(VkRenderData &renderData) {
VkFenceCreateInfo fenceInfo{};
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
Expand Down
12 changes: 7 additions & 5 deletions chapter03/vulkan_renderer/vulkan/Texture.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#include <cstring>

#include "CommandBuffer.h"
#include "Texture.h"
#include "Logger.h"

Expand Down Expand Up @@ -61,7 +63,7 @@ bool Texture::loadTexture(VkRenderData &renderData, std::string textureFilename)

void* data;
vmaMapMemory(renderData.rdAllocator, stagingBufferAlloc, &data);
memcpy(data, textureData, static_cast<uint32_t>(imageSize));
std::memcpy(data, textureData, static_cast<uint32_t>(imageSize));
vmaUnmapMemory(renderData.rdAllocator, stagingBufferAlloc);

stbi_image_free(textureData);
Expand Down Expand Up @@ -156,22 +158,22 @@ bool Texture::loadTexture(VkRenderData &renderData, std::string textureFilename)
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;

if (vkCreateFence(renderData.rdVkbDevice.device, &fenceInfo, nullptr, &stagingBufferFence) != VK_SUCCESS) {
Logger::log(1, "%s error: failed to staging buffer fence\n", __FUNCTION__);
Logger::log(1, "%s error: failed to create staging buffer fence\n", __FUNCTION__);
return false;
}

if (vkResetFences(renderData.rdVkbDevice.device, 1, &stagingBufferFence) != VK_SUCCESS) {
Logger::log(1, "%s error: staging buffer fence reset failed", __FUNCTION__);
Logger::log(1, "%s error: staging buffer fence reset failed\n", __FUNCTION__);
return false;
}

if (vkQueueSubmit(renderData.rdGraphicsQueue, 1, &submitInfo, stagingBufferFence) != VK_SUCCESS) {
Logger::log(1, "%s error: failed to staging buffer copy command buffer\n", __FUNCTION__);
Logger::log(1, "%s error: failed to submit staging buffer copy command buffer\n", __FUNCTION__);
return false;
}

if (vkWaitForFences(renderData.rdVkbDevice.device, 1, &stagingBufferFence, VK_TRUE, UINT64_MAX) != VK_SUCCESS) {
Logger::log(1, "%s error: waiting for staging buffer copy fence failed", __FUNCTION__);
Logger::log(1, "%s error: waiting for staging buffer copy fence failed\n", __FUNCTION__);
return false;
}

Expand Down
1 change: 0 additions & 1 deletion chapter03/vulkan_renderer/vulkan/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <vulkan/vulkan.h>

#include "VkRenderData.h"
#include "CommandBuffer.h"

class Texture {
public:
Expand Down
Loading

0 comments on commit 5f2124b

Please sign in to comment.