Skip to content

Commit

Permalink
Revert BackendAccessor
Browse files Browse the repository at this point in the history
  • Loading branch information
nekoffski committed Apr 25, 2024
1 parent 28aaf10 commit 63eb611
Show file tree
Hide file tree
Showing 33 changed files with 147 additions and 197 deletions.
15 changes: 0 additions & 15 deletions engine/src/starlight/renderer/gpu/vulkan/VKBackendAccessor.h

This file was deleted.

8 changes: 4 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
namespace sl::vk {

VKBuffer::VKBuffer(
VKBackendAccessor& backendAccessor, const VKBuffer::Properties& props
VKContext& context, VKLogicalDevice& device, const VKBuffer::Properties& props
) :
m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()), m_totalSize(props.size),
m_usageFlags(props.usageFlags), m_memoryPropertyFlags(props.memoryPropertyFlags),
m_context(context),
m_device(device), m_totalSize(props.size), m_usageFlags(props.usageFlags),
m_memoryPropertyFlags(props.memoryPropertyFlags),
m_useFreeList(props.useFreeList) {
if (m_useFreeList) m_bufferFreeList.emplace(props.size);

Expand Down
5 changes: 3 additions & 2 deletions engine/src/starlight/renderer/gpu/vulkan/VKBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "starlight/core/memory/Memory.hpp"
#include "starlight/core/utils/FreeList.h"

#include "VKBackendAccessor.h"
#include "VKLogicalDevice.h"
#include "VKContext.h"

Expand All @@ -27,7 +26,9 @@ class VKBuffer : public kc::core::Countable<VKBuffer> {
bool useFreeList = true;
};

explicit VKBuffer(VKBackendAccessor& backendAccessor, const Properties& props);
explicit VKBuffer(
VKContext& context, VKLogicalDevice& device, const Properties& props
);
~VKBuffer();

VkBuffer getHandle() const { return m_handle; }
Expand Down
5 changes: 0 additions & 5 deletions engine/src/starlight/renderer/gpu/vulkan/VKCommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

namespace sl::vk {

VKCommandBuffer::VKCommandBuffer(
VKBackendAccessor& backendAccessor, VkCommandPool commandPool, Severity severity
) :
VKCommandBuffer(*backendAccessor.getLogicalDevice(), commandPool, severity) {}

VKCommandBuffer::VKCommandBuffer(
VKLogicalDevice& device, VkCommandPool commandPool, Severity severity
) :
Expand Down
6 changes: 0 additions & 6 deletions engine/src/starlight/renderer/gpu/vulkan/VKCommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "starlight/renderer/gpu/CommandBuffer.h"

#include "VKBackendAccessor.h"
#include "VKLogicalDevice.h"
#include "fwd.h"

Expand All @@ -17,11 +16,6 @@ class VKCommandBuffer : public CommandBuffer {
Severity severity = Severity::primary
);

explicit VKCommandBuffer(
VKBackendAccessor& backendAccessor, VkCommandPool commandPool,
Severity severity = Severity::primary
);

~VKCommandBuffer();

VkCommandBufferAllocateInfo createAllocateInfo(Severity severity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <vector>

#include "VKCommandBuffer.h"
#include "VKBackendAccessor.h"
#include "VKLogicalDevice.h"

#include "starlight/renderer/gpu/CommandBufferPool.h"
Expand All @@ -12,9 +11,11 @@ namespace sl::vk {

class VKCommandBufferPool : public CommandBufferPool {
public:
explicit VKCommandBufferPool(VKBackendAccessor& backendAccessor, u64 size) :
m_device(*backendAccessor.getLogicalDevice()), m_frameImageIndex(0u),
m_size(size) {
explicit VKCommandBufferPool(
VKContext& context, VKLogicalDevice& device, u64 size
) :
m_device(device),
m_frameImageIndex(0u), m_size(size) {
create();
}

Expand Down
5 changes: 2 additions & 3 deletions engine/src/starlight/renderer/gpu/vulkan/VKFence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ VkFenceCreateInfo createFenceCreateInfo(VKFence::State state) {
return fenceCreateInfo;
}

VKFence::VKFence(VKBackendAccessor& backendAccessor, State state) :
m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()), m_state(state) {
VKFence::VKFence(VKContext& context, VKLogicalDevice& device, State state) :
m_context(context), m_device(device), m_state(state) {
auto fenceCreateInfo = createFenceCreateInfo(state);

VK_ASSERT(vkCreateFence(
Expand Down
5 changes: 2 additions & 3 deletions engine/src/starlight/renderer/gpu/vulkan/VKFence.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
#include "Vulkan.h"
#include "fwd.h"

#include "VKPhysicalDevice.h"
#include "VKLogicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"

namespace sl::vk {

class VKFence {
public:
enum class State : unsigned char { signaled, notSignaled };

explicit VKFence(VKBackendAccessor& backendAccessor, State state);
explicit VKFence(VKContext& context, VKLogicalDevice& device, State state);
~VKFence();

bool wait(Nanoseconds timeout);
Expand Down
8 changes: 4 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKFramebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ VkFramebufferCreateInfo createFramebufferCreateInfo(
VkFramebuffer VKFramebuffer::getHandle() { return m_handle; }

VKFramebuffer::VKFramebuffer(
VKBackendAccessor& backendAccessor, VkRenderPass renderPass, u32 width, u32 height,
const std::vector<VkImageView>& attachments
VKContext& context, VKLogicalDevice& device, VkRenderPass renderPass, u32 width,
u32 height, const std::vector<VkImageView>& attachments
) :
m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()), m_attachments(attachments) {
m_context(context),
m_device(device), m_attachments(attachments) {
const auto createInfo =
createFramebufferCreateInfo(m_attachments, renderPass, width, height);

Expand Down
8 changes: 4 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKFramebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "starlight/core/Core.h"
#include "starlight/core/math/Size.hpp"

#include "VKPhysicalDevice.h"
#include "VKLogicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"

#include "Vulkan.h"
#include "fwd.h"

Expand All @@ -16,8 +16,8 @@ namespace sl::vk {
class VKFramebuffer {
public:
explicit VKFramebuffer(
VKBackendAccessor& backendAccessor, VkRenderPass renderPass, u32 width,
u32 height, const std::vector<VkImageView>& attachments
VKContext& context, VKLogicalDevice& device, VkRenderPass renderPass,
u32 width, u32 height, const std::vector<VkImageView>& attachments
);

VkFramebuffer getHandle();
Expand Down
27 changes: 12 additions & 15 deletions engine/src/starlight/renderer/gpu/vulkan/VKImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@
namespace sl::vk {

VKImage::VKImage(
VKBackendAccessor& backendAccesor, const VKImage::Properties& properties
VKContext& context, VKLogicalDevice& device, const VKImage::Properties& properties
) :
m_backendAccesor(backendAccesor),
m_context(*backendAccesor.getContext()),
m_device(*backendAccesor.getLogicalDevice()), m_props(properties),
m_handle(VK_NULL_HANDLE), m_memory(VK_NULL_HANDLE), m_view(VK_NULL_HANDLE),
m_destroyImage(true) {
m_context(context),
m_device(device), m_props(properties), m_handle(VK_NULL_HANDLE),
m_memory(VK_NULL_HANDLE), m_view(VK_NULL_HANDLE), m_destroyImage(true) {
create();
}

VKImage::VKImage(
VKBackendAccessor& backendAccesor, const Properties& properties,
VKContext& context, VKLogicalDevice& device, const Properties& properties,
const std::span<u8> pixels
) :
VKImage(backendAccesor, properties) {
VKImage(context, device, properties) {
write(0, pixels);
}

VKImage::VKImage(
VKBackendAccessor& backendAccesor, const Properties& properties, VkImage handle
VKContext& context, VKLogicalDevice& device, const Properties& properties,
VkImage handle
) :
m_backendAccesor(backendAccesor),
m_context(*backendAccesor.getContext()),
m_device(*backendAccesor.getLogicalDevice()), m_props(properties),
m_handle(handle), m_memory(VK_NULL_HANDLE), m_view(VK_NULL_HANDLE),
m_destroyImage(false) {
m_context(context),
m_device(device), m_props(properties), m_handle(handle),
m_memory(VK_NULL_HANDLE), m_view(VK_NULL_HANDLE), m_destroyImage(false) {
if (m_props.createView) createView();
}

Expand Down Expand Up @@ -87,7 +84,7 @@ void VKImage::write(u32 offset, std::span<u8> pixels) {
.useFreeList = false
};

VKBuffer stagingBuffer(m_backendAccesor, stagingBufferProperties);
VKBuffer stagingBuffer(m_context, m_device, stagingBufferProperties);

stagingBuffer.loadData(0, imageSize, 0, pixels.data());

Expand Down
9 changes: 4 additions & 5 deletions engine/src/starlight/renderer/gpu/vulkan/VKImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include "VKPhysicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"
#include "VKBuffer.h"
#include "VKCommandBuffer.h"

Expand All @@ -34,14 +33,15 @@ class VKImage {
};

explicit VKImage(
VKBackendAccessor& backendAccesor, const Properties& properties
VKContext& context, VKLogicalDevice&, const Properties& properties
);
explicit VKImage(
VKBackendAccessor& backendAccesor, const Properties& properties,
VKContext& context, VKLogicalDevice&, const Properties& properties,
const std::span<u8> pixels
);
explicit VKImage(
VKBackendAccessor& backendAccesor, const Properties& properties, VkImage handle
VKContext& context, VKLogicalDevice&, const Properties& properties,
VkImage handle
);

~VKImage();
Expand Down Expand Up @@ -81,7 +81,6 @@ class VKImage {

Properties m_props;

VKBackendAccessor& m_backendAccesor;
VKContext& m_context;
VKLogicalDevice& m_device;

Expand Down
7 changes: 3 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace sl::vk {

VKMesh::VKMesh(
u32 id, VKBackendAccessor& backendAccessor, VKBuffer& vertexBuffer,
u32 id, VKContext& context, VKLogicalDevice& device, VKBuffer& vertexBuffer,
VKBuffer& indexBuffer, const Properties& props, const Data& data
) :
Mesh(props, data, id),
m_backendAccessor(backendAccessor), m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()) {
m_context(context), m_device(device) {
LOG_TRACE("Creating Mesh");
LOG_DEBUG(
"Mesh data vertexSize={}, vertexCount={}, "
Expand Down Expand Up @@ -42,7 +41,7 @@ u64 VKMesh::uploadDataRange(
VkMemoryPropertyFlags flags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
VKBuffer stagingBuffer(
m_backendAccessor,
m_context, m_device,
VKBuffer::Properties{ size, flags, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true }
);

Expand Down
4 changes: 1 addition & 3 deletions engine/src/starlight/renderer/gpu/vulkan/VKMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "VKPhysicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"
#include "VKBuffer.h"
#include "starlight/renderer/gpu/Mesh.h"

Expand All @@ -17,7 +16,7 @@ class VKMesh : public Mesh {
struct BufferData {};

explicit VKMesh(
u32 id, VKBackendAccessor& backendAccessor, VKBuffer& vertexBuffer,
u32 id, VKContext& context, VKLogicalDevice& device, VKBuffer& vertexBuffer,
VKBuffer& indexBuffer, const Properties& props, const Data& data
);
~VKMesh();
Expand All @@ -30,7 +29,6 @@ class VKMesh : public Mesh {
u64 size, const void* data
);

VKBackendAccessor& m_backendAccessor;
VKContext& m_context;
VKLogicalDevice& m_device;
};
Expand Down
9 changes: 5 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "VKPhysicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"

#include "VKContext.h"
#include "VKCommandBuffer.h"
#include "VKRenderPass.h"
Expand Down Expand Up @@ -39,10 +39,11 @@ class VKPipeline {
};

explicit VKPipeline(
VKBackendAccessor& backendAccessor, VKRenderPass& renderPass, Properties props
VKContext& context, VKLogicalDevice& device, VKRenderPass& renderPass,
Properties props
) :
m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()) {
m_context(context),
m_device(device) {
VkPipelineViewportStateCreateInfo viewportState = {
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
};
Expand Down
9 changes: 5 additions & 4 deletions engine/src/starlight/renderer/gpu/vulkan/VKRenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ struct RenderPassCreateInfo {
};

VKRenderPass::VKRenderPass(
u32 id, VKBackendAccessor& backendAccessor, const VKSwapchain& swapchain,
u32 id, VKContext& context, VKLogicalDevice& device, const VKSwapchain& swapchain,
const Properties& properties
) :
RenderPass(id, properties),
m_context(*backendAccessor.getContext()),
m_device(*backendAccessor.getLogicalDevice()) {
m_context(context), m_device(device) {
LOG_TRACE("Creating VKRenderPass instance");

RenderPassCreateInfo createInfo(
Expand All @@ -158,7 +157,9 @@ VKRenderPass::VKRenderPass(
LOG_WARN("Render pass with no render targets created");

for (auto& renderTarget : properties.targets) {
m_renderTargets.emplace_back(id * 1000, backendAccessor, this, renderTarget);
m_renderTargets.emplace_back(
id * 1000, m_context, m_device, this, renderTarget
);
}
}

Expand Down
6 changes: 3 additions & 3 deletions engine/src/starlight/renderer/gpu/vulkan/VKRenderPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "VKPhysicalDevice.h"
#include "VKContext.h"
#include "VKBackendAccessor.h"

#include "Vulkan.h"
#include "fwd.h"

Expand All @@ -26,8 +26,8 @@ class VKRenderPass : public RenderPass {
};

explicit VKRenderPass(
u32 id, VKBackendAccessor& backendAccessor, const VKSwapchain& swapchain,
const Properties& properties
u32 id, VKContext& context, VKLogicalDevice& device,
const VKSwapchain& swapchain, const Properties& properties
);

~VKRenderPass();
Expand Down
Loading

0 comments on commit 63eb611

Please sign in to comment.