Skip to content

Commit 16826ac

Browse files
committed
Removed Vulkan API leakage from Render module
1 parent 1d19298 commit 16826ac

File tree

26 files changed

+133
-377
lines changed

26 files changed

+133
-377
lines changed

engine/render/renderer/Renderer.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "platform/vulkan/Font.h"
1212
#include "platform/vulkan/utils/Types.h"
1313
#include "statics/Statics.h"
14+
#include "platform/vulkan/utils/Viewport.h"
1415

1516
namespace Siege
1617
{
@@ -173,6 +174,11 @@ void Renderer::EndFrame()
173174
renderer2D.Flush();
174175
}
175176

177+
void Renderer::ClearDeviceQueue()
178+
{
179+
Vulkan::Context::GetCurrentDevice()->WaitIdle();
180+
}
181+
176182
void Renderer::BeginSwapChainRenderPass()
177183
{
178184
auto& swapchain = context.GetSwapchain();
@@ -183,17 +189,10 @@ void Renderer::BeginSwapChainRenderPass()
183189

184190
swapchain.BeginRenderPass(commandBuffers, currentImageIndex, {0.96f, 0.96f, 0.96f, 1.f});
185191

186-
VkViewport viewport {};
187-
viewport.x = 0.0f;
188-
viewport.y = 0.0f;
189-
viewport.width = static_cast<float>(swapExtent.width);
190-
viewport.height = static_cast<float>(swapExtent.height);
191-
viewport.minDepth = 0.0f;
192-
viewport.maxDepth = 1.0f;
193-
VkRect2D scissor {{0, 0}, {swapExtent.width, swapExtent.height}};
194-
195-
vkCmdSetViewport(commandBuffers.GetActiveCommandBuffer(), 0, 1, &viewport);
196-
vkCmdSetScissor(commandBuffers.GetActiveCommandBuffer(), 0, 1, &scissor);
192+
using namespace Vulkan::Utils;
193+
194+
SetViewport(commandBuffers.GetActiveCommandBuffer(), static_cast<float>(swapExtent.width), static_cast<float>(swapExtent.height));
195+
SetScissor(commandBuffers.GetActiveCommandBuffer(), swapExtent.width, swapExtent.height);
197196
}
198197

199198
void Renderer::EndSwapChainRenderPass()

engine/render/renderer/Renderer.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,7 @@ class Renderer
5050
bool StartFrame();
5151
void EndFrame();
5252

53-
void ClearDeviceQueue()
54-
{
55-
vkDeviceWaitIdle(Context().GetVkLogicalDevice());
56-
}
57-
58-
void SetClearValue(float r, float g, float b, float a)
59-
{
60-
clearValue = {{r, g, b, a}};
61-
}
53+
void ClearDeviceQueue();
6254

6355
void DrawQuad(const Vec2 position,
6456
const Vec2 scale = {1.f, 1.f},
@@ -101,9 +93,6 @@ class Renderer
10193
static Vulkan::CommandBuffer commandBuffers;
10294
static uint32_t currentFrameIndex;
10395

104-
// Make this adjustable in the window, not the renderer.
105-
VkClearColorValue clearValue {{0.96f, 0.96f, 0.96f, 1.f}};
106-
10796
void RecreateSwapChain();
10897

10998
void BeginSwapChainRenderPass();

engine/render/renderer/framebuffer/Framebuffer.cpp

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)