Compare commits
No commits in common. "564f6cc2051810316700b65bd73fc52252b54793" and "a3dcf22fa579656866951cf8b1ba6299585b0a7b" have entirely different histories.
564f6cc205
...
a3dcf22fa5
|
|
@ -1,5 +0,0 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=Bookmark5/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=Bookmark5/Coords/@EntryValue">(Doc Ln 10 Col 4)</s:String>
|
||||
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=Bookmark5/FileId/@EntryValue">DB94C55F-6B9A-4AAE-80D7-29FD8153E6B5/d:aster/f:window.h</s:String>
|
||||
<s:String x:Key="/Default/Housekeeping/Bookmarks/NumberedBookmarks/=Bookmark5/Owner/@EntryValue">NumberedBookmarkManager</s:String></wpf:ResourceDictionary>
|
||||
|
|
@ -22,7 +22,7 @@ set(HEADER_FILES
|
|||
swapchain.h
|
||||
pipeline.h
|
||||
queue_allocation.h
|
||||
buffer.h "surface.h" "size.h")
|
||||
buffer.h)
|
||||
|
||||
set(SOURCE_FILES
|
||||
logger.cpp
|
||||
|
|
@ -35,7 +35,7 @@ set(SOURCE_FILES
|
|||
pipeline.cpp
|
||||
buffer.cpp
|
||||
image.cpp
|
||||
image.h "surface.cpp")
|
||||
image.h)
|
||||
|
||||
add_library(aster_core STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
set_property(TARGET aster_core PROPERTY CXX_STANDARD 20)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ Context::Context(const cstr appName, const Version version, bool enableValidatio
|
|||
{
|
||||
INFO_IF(enableValidation, "Validation Layers enabled");
|
||||
|
||||
if (!glfwInit())
|
||||
{
|
||||
const char *error = nullptr;
|
||||
const auto code = glfwGetError(&error);
|
||||
ERROR("GLFW Init failed. Cause: ({}) {}", code, error)
|
||||
THEN_ABORT(code);
|
||||
}
|
||||
|
||||
// TODO Get/Check API Version
|
||||
|
||||
// Creating Instance
|
||||
|
|
@ -111,6 +119,8 @@ Context::~Context()
|
|||
}
|
||||
m_Instance.destroy(nullptr);
|
||||
DEBUG("Instance destroyed");
|
||||
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
Context::Context(Context &&other) noexcept
|
||||
|
|
|
|||
|
|
@ -14,80 +14,16 @@
|
|||
// NOTE: Vulkan Dispatch Loader Storage - Should only appear once.
|
||||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
||||
|
||||
struct MemorySize
|
||||
{
|
||||
u16 m_Gigabytes;
|
||||
u16 m_Megabytes;
|
||||
u16 m_Kilobytes;
|
||||
u16 m_Bytes;
|
||||
|
||||
MemorySize &
|
||||
operator+=(usize bytes)
|
||||
{
|
||||
usize totalBytes = bytes + m_Bytes;
|
||||
m_Bytes = totalBytes % 1024;
|
||||
const usize totalKb = m_Kilobytes + totalBytes / 1024;
|
||||
m_Kilobytes = totalKb % 1024;
|
||||
const usize totalMb = m_Megabytes + totalKb / 1024;
|
||||
m_Megabytes = totalMb % 1024;
|
||||
m_Gigabytes += totalMb / 1024;
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
MemorySize g_TotalAlloc = {};
|
||||
|
||||
template <>
|
||||
struct fmt::formatter<MemorySize>
|
||||
{
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
constexpr auto
|
||||
parse(format_parse_context &ctx)
|
||||
{
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename Context>
|
||||
// ReSharper disable once CppInconsistentNaming
|
||||
constexpr auto
|
||||
format(MemorySize const &mem, Context &ctx) const
|
||||
{
|
||||
// return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
|
||||
if (mem.m_Gigabytes > 0)
|
||||
{
|
||||
return v10::format_to(ctx.out(), "{}.{} GB", mem.m_Gigabytes,
|
||||
Cast<u16>(mem.m_Megabytes / 1024.0));
|
||||
}
|
||||
if (mem.m_Megabytes > 0)
|
||||
{
|
||||
return v10::format_to(ctx.out(), "{}.{} MB", mem.m_Megabytes, Cast<u16>(mem.m_Kilobytes / 1024.0));
|
||||
}
|
||||
if (mem.m_Kilobytes > 0)
|
||||
{
|
||||
return v10::format_to(ctx.out(), "{}.{} KB", mem.m_Kilobytes, Cast<u16>(mem.m_Bytes / 1024.0));
|
||||
}
|
||||
|
||||
return v10::format_to(ctx.out(), "{} Bytes", mem.m_Bytes);
|
||||
}
|
||||
};
|
||||
|
||||
void *
|
||||
operator new[](size_t size, const char * /*pName*/, int flags, unsigned /*debugFlags*/, const char * /*file*/,
|
||||
operator new[](size_t size, const char * /*pName*/, int /*flags*/, unsigned /*debugFlags*/, const char * /*file*/,
|
||||
int /*line*/)
|
||||
{
|
||||
g_TotalAlloc += size;
|
||||
|
||||
VERBOSE("Total: {} - Allocated {} bytes. ({})", g_TotalAlloc, size, (flags & eastl::MEM_TEMP) ? "temp" : "perm");
|
||||
return new u8[size];
|
||||
}
|
||||
|
||||
void *
|
||||
operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, const char * /*pName*/, int flags,
|
||||
operator new[](size_t size, size_t /*alignment*/, size_t /*alignmentOffset*/, const char * /*pName*/, int /*flags*/,
|
||||
unsigned /*debugFlags*/, const char * /*file*/, int /*line*/)
|
||||
{
|
||||
g_TotalAlloc += size;
|
||||
|
||||
VERBOSE("Total: {} - Allocated {} bytes. ({})", g_TotalAlloc, size, (flags & eastl::MEM_TEMP) ? "temp" : "perm");
|
||||
return new u8[size];
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
#include "physical_device.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "surface.h"
|
||||
#include "window.h"
|
||||
|
||||
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
||||
|
|
@ -155,11 +154,12 @@ EnumeratePhysicalDevices(const vk::Instance instance)
|
|||
return physicalDevices;
|
||||
}
|
||||
|
||||
PhysicalDevices::PhysicalDevices(const Surface *surface, const Context *context)
|
||||
PhysicalDevices::PhysicalDevices(const Window *window, const Context *context)
|
||||
{
|
||||
auto surface = window->m_Surface;
|
||||
auto physicalDevices = EnumeratePhysicalDevices(context->m_Instance);
|
||||
for (auto physicalDevice : physicalDevices)
|
||||
{
|
||||
this->emplace_back(surface->m_Surface, physicalDevice);
|
||||
this->emplace_back(surface, physicalDevice);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
#include "surface.h"
|
||||
|
||||
#include <EASTL/fixed_vector.h>
|
||||
|
||||
struct Window;
|
||||
|
|
@ -54,5 +52,5 @@ struct PhysicalDevice final
|
|||
class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
|
||||
{
|
||||
public:
|
||||
PhysicalDevices(const Surface *surface, const Context *context);
|
||||
PhysicalDevices(const Window *window, const Context *context);
|
||||
};
|
||||
20
aster/size.h
20
aster/size.h
|
|
@ -1,20 +0,0 @@
|
|||
// =============================================
|
||||
// Aster: size.h
|
||||
// Copyright (c) 2020-2024 Anish Bhobe
|
||||
// =============================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
struct Size2D
|
||||
{
|
||||
u32 m_Width;
|
||||
u32 m_Height;
|
||||
|
||||
explicit
|
||||
operator vk::Extent2D() const
|
||||
{
|
||||
return {m_Width, m_Height};
|
||||
}
|
||||
};
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
// =============================================
|
||||
// Aster: surface.cpp
|
||||
// Copyright (c) 2020-2024 Anish Bhobe
|
||||
// =============================================
|
||||
|
||||
#include "surface.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "window.h"
|
||||
|
||||
Surface::Surface(Context *context, const Window *window, cstr name)
|
||||
: m_Context(context)
|
||||
{
|
||||
VkSurfaceKHR surface;
|
||||
auto result = Cast<vk::Result>(
|
||||
glfwCreateWindowSurface(Cast<VkInstance>(m_Context->m_Instance), window->m_Window, nullptr, &surface));
|
||||
ERROR_IF(Failed(result), "Failed to create Surface with {}", result)
|
||||
THEN_ABORT(result)
|
||||
ELSE_DEBUG("Surface {} Created", m_Name);
|
||||
m_Surface = vk::SurfaceKHR(surface);
|
||||
}
|
||||
|
||||
Surface::~Surface()
|
||||
{
|
||||
if (m_Context && m_Surface)
|
||||
{
|
||||
m_Context->m_Instance.destroy(m_Surface, nullptr);
|
||||
DEBUG("Surface Destroyed");
|
||||
|
||||
m_Surface = nullptr;
|
||||
m_Context = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Surface::Surface(Surface &&other) noexcept
|
||||
: m_Context(Take(other.m_Context))
|
||||
, m_Surface(Take(other.m_Surface))
|
||||
, m_Name(std::move(other.m_Name))
|
||||
{
|
||||
}
|
||||
|
||||
Surface &
|
||||
Surface::operator=(Surface &&other) noexcept
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
m_Context = Take(other.m_Context);
|
||||
m_Surface = Take(other.m_Surface);
|
||||
m_Name = std::move(other.m_Name);
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// =============================================
|
||||
// Aster: surface.h
|
||||
// Copyright (c) 2020-2024 Anish Bhobe
|
||||
// =============================================
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
struct Context;
|
||||
struct Window;
|
||||
|
||||
struct Surface
|
||||
{
|
||||
Context *m_Context;
|
||||
vk::SurfaceKHR m_Surface;
|
||||
NameString m_Name;
|
||||
|
||||
// Ctor Dtor
|
||||
Surface(Context *context, const Window *window, cstr name);
|
||||
~Surface();
|
||||
|
||||
// Move
|
||||
Surface(Surface &&other) noexcept;
|
||||
Surface &operator=(Surface &&other) noexcept;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Surface);
|
||||
};
|
||||
|
|
@ -7,17 +7,16 @@
|
|||
|
||||
#include "device.h"
|
||||
#include "physical_device.h"
|
||||
#include "surface.h"
|
||||
#include "window.h"
|
||||
|
||||
[[nodiscard]] vk::Extent2D GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities);
|
||||
[[nodiscard]] vk::Extent2D GetExtent(const Window *window, vk::SurfaceCapabilitiesKHR *surfaceCapabilities);
|
||||
|
||||
Swapchain::Swapchain(const Surface *surface, const Device *device, Size2D size, NameString &&name)
|
||||
Swapchain::Swapchain(const Window *window, const Device *device, NameString &&name)
|
||||
: m_Device(device)
|
||||
, m_Name(std::move(name))
|
||||
, m_Format(vk::Format::eUndefined)
|
||||
{
|
||||
this->Create(surface, size);
|
||||
this->Create(window);
|
||||
}
|
||||
|
||||
Swapchain::~Swapchain()
|
||||
|
|
@ -52,20 +51,20 @@ Swapchain::operator=(Swapchain &&other) noexcept
|
|||
}
|
||||
|
||||
void
|
||||
Swapchain::Create(const Surface *surface, Size2D size)
|
||||
Swapchain::Create(const Window *window)
|
||||
{
|
||||
auto surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, surface->m_Surface);
|
||||
m_Extent = GetExtent(size, &surfaceCapabilities);
|
||||
auto surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, window->m_Surface);
|
||||
m_Extent = GetExtent(window, &surfaceCapabilities);
|
||||
|
||||
while (m_Extent.width == 0 || m_Extent.height == 0)
|
||||
{
|
||||
glfwWaitEvents();
|
||||
surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, surface->m_Surface);
|
||||
m_Extent = GetExtent(size, &surfaceCapabilities);
|
||||
surfaceCapabilities = GetSurfaceCapabilities(m_Device->m_PhysicalDevice, window->m_Surface);
|
||||
m_Extent = GetExtent(window, &surfaceCapabilities);
|
||||
}
|
||||
|
||||
auto surfaceFormats = GetSurfaceFormats(m_Device->m_PhysicalDevice, surface->m_Surface);
|
||||
auto presentModes = GetSurfacePresentModes(m_Device->m_PhysicalDevice, surface->m_Surface);
|
||||
auto surfaceFormats = GetSurfaceFormats(m_Device->m_PhysicalDevice, window->m_Surface);
|
||||
auto presentModes = GetSurfacePresentModes(m_Device->m_PhysicalDevice, window->m_Surface);
|
||||
|
||||
m_Format = vk::Format::eUndefined;
|
||||
vk::ColorSpaceKHR swapchainColorSpace = vk::ColorSpaceKHR::eSrgbNonlinear;
|
||||
|
|
@ -105,7 +104,7 @@ Swapchain::Create(const Surface *surface, Size2D size)
|
|||
// TODO: Note that different queues might need the images to be shared.
|
||||
|
||||
const vk::SwapchainCreateInfoKHR swapchainCreateInfo = {
|
||||
.surface = surface->m_Surface,
|
||||
.surface = window->m_Surface,
|
||||
.minImageCount = swapchainImageCount,
|
||||
.imageFormat = m_Format,
|
||||
.imageColorSpace = swapchainColorSpace,
|
||||
|
|
@ -207,14 +206,14 @@ Swapchain::Cleanup()
|
|||
}
|
||||
|
||||
vk::Extent2D
|
||||
GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities)
|
||||
GetExtent(const Window *window, vk::SurfaceCapabilitiesKHR *surfaceCapabilities)
|
||||
{
|
||||
if (surfaceCapabilities->currentExtent.width != MaxValue<u32>)
|
||||
{
|
||||
return surfaceCapabilities->currentExtent;
|
||||
}
|
||||
|
||||
auto [width, height] = size;
|
||||
auto [width, height] = window->GetSize();
|
||||
auto [minWidth, minHeight] = surfaceCapabilities->minImageExtent;
|
||||
auto [maxWidth, maxHeight] = surfaceCapabilities->maxImageExtent;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,10 @@
|
|||
|
||||
#include "global.h"
|
||||
|
||||
#include "size.h"
|
||||
|
||||
#include <EASTL/fixed_vector.h>
|
||||
|
||||
struct PhysicalDevice;
|
||||
struct Surface;
|
||||
struct Window;
|
||||
struct Device;
|
||||
|
||||
struct Swapchain final
|
||||
|
|
@ -29,11 +27,11 @@ struct Swapchain final
|
|||
|
||||
eastl::vector<FnResizeCallback> m_ResizeCallbacks;
|
||||
|
||||
void Create(const Surface *window, Size2D size);
|
||||
void Create(const Window *window);
|
||||
void RegisterResizeCallback(FnResizeCallback &&callback);
|
||||
|
||||
// Ctor/Dtor
|
||||
Swapchain(const Surface *window, const Device *device, Size2D size, NameString &&name);
|
||||
Swapchain(const Window *window, const Device *device, NameString &&name);
|
||||
~Swapchain();
|
||||
|
||||
// Move
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@
|
|||
#include "context.h"
|
||||
#include "logger.h"
|
||||
|
||||
std::atomic_uint64_t Window::m_WindowCount = 0;
|
||||
std::atomic_bool Window::m_IsGlfwInit = false;
|
||||
|
||||
void
|
||||
Window::RequestExit() const noexcept
|
||||
{
|
||||
|
|
@ -29,7 +26,7 @@ Window::SetWindowSize(const u32 width, const u32 height) const noexcept
|
|||
glfwSetWindowSize(m_Window, Cast<i32>(width), Cast<i32>(height));
|
||||
}
|
||||
|
||||
Size2D
|
||||
vk::Extent2D
|
||||
Window::GetSize() const
|
||||
{
|
||||
int width;
|
||||
|
|
@ -38,23 +35,11 @@ Window::GetSize() const
|
|||
return {Cast<u32>(width), Cast<u32>(height)};
|
||||
}
|
||||
|
||||
Window::Window(const cstr title, Size2D extent, const b8 isFullScreen)
|
||||
Window::Window(const cstr title, Context *context, vk::Extent2D extent, const b8 isFullScreen)
|
||||
{
|
||||
m_Context = context;
|
||||
m_Name = title;
|
||||
|
||||
if (!m_IsGlfwInit)
|
||||
{
|
||||
if (!glfwInit())
|
||||
{
|
||||
const char *error = nullptr;
|
||||
const auto code = glfwGetError(&error);
|
||||
ERROR("GLFW Init failed. Cause: ({}) {}", code, error)
|
||||
THEN_ABORT(code);
|
||||
}
|
||||
m_WindowCount = 0;
|
||||
m_IsGlfwInit = true;
|
||||
}
|
||||
|
||||
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
|
||||
ERROR_IF(!monitor, "No monitor found");
|
||||
|
||||
|
|
@ -64,10 +49,10 @@ Window::Window(const cstr title, Size2D extent, const b8 isFullScreen)
|
|||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE);
|
||||
|
||||
m_Window = glfwCreateWindow(Cast<i32>(extent.m_Width), Cast<i32>(extent.m_Height), m_Name.c_str(),
|
||||
m_Window = glfwCreateWindow(Cast<i32>(extent.width), Cast<i32>(extent.height), m_Name.c_str(),
|
||||
isFullScreen ? monitor : nullptr, nullptr);
|
||||
ERROR_IF(m_Window == nullptr, "Window creation failed")
|
||||
ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.m_Width, extent.m_Height);
|
||||
ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.width, extent.height);
|
||||
if (m_Window == nullptr)
|
||||
{
|
||||
const char *error = nullptr;
|
||||
|
|
@ -78,35 +63,41 @@ Window::Window(const cstr title, Size2D extent, const b8 isFullScreen)
|
|||
|
||||
if (isFullScreen == false)
|
||||
{
|
||||
glfwSetWindowPos(m_Window, Cast<i32>(windowWidth - extent.m_Width) / 2,
|
||||
Cast<i32>(windowHeight - extent.m_Height) / 2);
|
||||
glfwSetWindowPos(m_Window, Cast<i32>(windowWidth - extent.width) / 2,
|
||||
Cast<i32>(windowHeight - extent.height) / 2);
|
||||
}
|
||||
glfwSetInputMode(m_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
|
||||
++m_WindowCount;
|
||||
VkSurfaceKHR surface;
|
||||
auto result =
|
||||
Cast<vk::Result>(glfwCreateWindowSurface(Cast<VkInstance>(m_Context->m_Instance), m_Window, nullptr, &surface));
|
||||
ERROR_IF(Failed(result), "Failed to create Surface with {}", result)
|
||||
THEN_ABORT(result)
|
||||
ELSE_DEBUG("Surface {} Created", m_Name);
|
||||
m_Surface = vk::SurfaceKHR(surface);
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
if (m_Context && m_Surface)
|
||||
{
|
||||
m_Context->m_Instance.destroy(m_Surface, nullptr);
|
||||
DEBUG("Surface Destroyed");
|
||||
}
|
||||
|
||||
if (m_Window)
|
||||
{
|
||||
glfwDestroyWindow(m_Window);
|
||||
m_Window = nullptr;
|
||||
|
||||
--m_WindowCount;
|
||||
}
|
||||
|
||||
if (m_WindowCount== 0 && m_IsGlfwInit)
|
||||
{
|
||||
glfwTerminate();
|
||||
m_IsGlfwInit = false;
|
||||
}
|
||||
|
||||
DEBUG("Window '{}' Destroyed", m_Name);
|
||||
}
|
||||
|
||||
Window::Window(Window &&other) noexcept
|
||||
: m_Window(Take(other.m_Window))
|
||||
: m_Context(other.m_Context)
|
||||
, m_Window(Take(other.m_Window))
|
||||
, m_Surface(Take(other.m_Surface))
|
||||
, m_Name(Take(other.m_Name))
|
||||
{
|
||||
}
|
||||
|
|
@ -116,7 +107,9 @@ Window::operator=(Window &&other) noexcept
|
|||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
m_Context = other.m_Context;
|
||||
m_Window = Take(other.m_Window);
|
||||
m_Surface = Take(other.m_Surface);
|
||||
m_Name = Take(other.m_Name);
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,18 @@
|
|||
#pragma once
|
||||
|
||||
#include "global.h"
|
||||
|
||||
#include "size.h"
|
||||
|
||||
#include <EASTL/fixed_string.h>
|
||||
|
||||
struct Context;
|
||||
|
||||
struct Window final
|
||||
{
|
||||
// fields
|
||||
GLFWwindow *m_Window = nullptr;
|
||||
NameString m_Name;
|
||||
Context *m_Context{};
|
||||
|
||||
static std::atomic_uint64_t m_WindowCount;
|
||||
static std::atomic_bool m_IsGlfwInit;
|
||||
GLFWwindow *m_Window = nullptr;
|
||||
vk::SurfaceKHR m_Surface;
|
||||
eastl::fixed_string<char, 32> m_Name;
|
||||
|
||||
// Methods
|
||||
[[nodiscard]] bool
|
||||
|
|
@ -32,10 +31,10 @@ struct Window final
|
|||
void SetWindowSize(const vk::Extent2D &extent) const noexcept;
|
||||
void SetWindowSize(u32 width, u32 height) const noexcept;
|
||||
/// Actual size of the framebuffer being used for the window render.
|
||||
[[nodiscard]] Size2D GetSize() const;
|
||||
[[nodiscard]] vk::Extent2D GetSize() const;
|
||||
|
||||
// Ctor/Dtor
|
||||
Window(cstr title, Size2D extent, b8 isFullScreen = false);
|
||||
Window(cstr title, Context *context, vk::Extent2D extent, b8 isFullScreen = false);
|
||||
~Window();
|
||||
|
||||
// Move
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ Frame::Frame(const Device *device, const u32 queueFamilyIndex, const u32 frameCo
|
|||
}
|
||||
|
||||
void
|
||||
Frame::Present(const vk::Queue commandQueue, Swapchain *swapchain, const Surface *surface, Size2D size)
|
||||
Frame::Present(const vk::Queue commandQueue, Swapchain *swapchain, const Window *window)
|
||||
{
|
||||
|
||||
vk::PresentInfoKHR presentInfo = {
|
||||
|
|
@ -70,7 +70,7 @@ Frame::Present(const vk::Queue commandQueue, Swapchain *swapchain, const Surface
|
|||
case vk::Result::eErrorOutOfDateKHR:
|
||||
case vk::Result::eSuboptimalKHR:
|
||||
DEBUG("Recreating Swapchain. Cause: {}", result);
|
||||
swapchain->Create(surface, size);
|
||||
swapchain->Create(window);
|
||||
break; // Present failed. We do nothing. Frame is skipped.
|
||||
default:
|
||||
AbortIfFailedM(result, "Swapchain Present failed.");
|
||||
|
|
@ -128,7 +128,7 @@ FrameManager::FrameManager(const Device *device, u32 queueFamilyIndex, u32 frame
|
|||
}
|
||||
|
||||
Frame *
|
||||
FrameManager::GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D size)
|
||||
FrameManager::GetNextFrame(Swapchain *swapchain, const Window *window)
|
||||
{
|
||||
|
||||
Frame *currentFrame = &m_Frames[m_CurrentFrameIdx];
|
||||
|
|
@ -153,7 +153,7 @@ FrameManager::GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D
|
|||
break; // Image acquired. Break out of loop.
|
||||
case vk::Result::eErrorOutOfDateKHR:
|
||||
DEBUG("Recreating Swapchain. Cause: {}", result);
|
||||
swapchain->Create(surface, size);
|
||||
swapchain->Create(window);
|
||||
break; // Image acquire has failed. We move to the next frame.
|
||||
default:
|
||||
AbortIfFailedMV(result, "Waiting for swapchain image {} failed.", frameIndex);
|
||||
|
|
|
|||
|
|
@ -8,14 +8,11 @@
|
|||
#include "global.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include "size.h"
|
||||
|
||||
#include <EASTL/fixed_vector.h>
|
||||
|
||||
struct Device;
|
||||
struct Window;
|
||||
struct Swapchain;
|
||||
struct Surface;
|
||||
|
||||
struct Frame
|
||||
{
|
||||
|
|
@ -31,7 +28,7 @@ struct Frame
|
|||
// Transient
|
||||
u32 m_ImageIdx;
|
||||
|
||||
void Present(const vk::Queue commandQueue, Swapchain* swapchain, const Surface* surface, Size2D size);
|
||||
void Present(vk::Queue commandQueue, Swapchain *swapchain, const Window *window);
|
||||
|
||||
Frame(const Device *device, u32 queueFamilyIndex, u32 frameCount);
|
||||
~Frame();
|
||||
|
|
@ -51,5 +48,5 @@ struct FrameManager
|
|||
|
||||
FrameManager(const Device *device, u32 queueFamilyIndex, u32 framesInFlight);
|
||||
|
||||
Frame *GetNextFrame(Swapchain *swapchain, const Surface *surface, Size2D size);
|
||||
Frame *GetNextFrame(Swapchain *swapchain, const Window *window);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -75,10 +75,9 @@ main(int, char **)
|
|||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
Context context = {"Triangle", VERSION};
|
||||
Window window = {"Triangle (Aster)", {640, 480}};
|
||||
Surface surface = {&context, &window, "Primary"};
|
||||
Window window = {"Triangle (Aster)", &context, {640, 480}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&surface, &context};
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
||||
INFO("Using {} as the primary device.", deviceToUse.m_DeviceProperties.deviceName.data());
|
||||
|
|
@ -87,7 +86,7 @@ main(int, char **)
|
|||
QueueAllocation queueAllocation = FindAppropriateQueueAllocation(&deviceToUse);
|
||||
Device device = {&context, &deviceToUse, &enabledDeviceFeatures, {queueAllocation}, "Primary Device"};
|
||||
vk::Queue commandQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||
Pipeline pipeline = CreatePipeline(&device, &swapchain);
|
||||
|
||||
vk::CommandPool copyPool;
|
||||
|
|
@ -218,7 +217,7 @@ main(int, char **)
|
|||
case vk::Result::eErrorOutOfDateKHR:
|
||||
case vk::Result::eSuboptimalKHR:
|
||||
INFO("Recreating Swapchain. Cause: {}", result);
|
||||
swapchain.Create(&surface, window.GetSize());
|
||||
swapchain.Create(&window);
|
||||
viewport.y = Cast<f32>(swapchain.m_Extent.height);
|
||||
viewport.width = Cast<f32>(swapchain.m_Extent.width);
|
||||
viewport.height = -Cast<f32>(swapchain.m_Extent.height);
|
||||
|
|
@ -318,7 +317,7 @@ main(int, char **)
|
|||
case vk::Result::eErrorOutOfDateKHR:
|
||||
case vk::Result::eSuboptimalKHR:
|
||||
INFO("Recreating Swapchain. Cause: {}", result);
|
||||
swapchain.Create(&surface, window.GetSize());
|
||||
swapchain.Create(&window);
|
||||
viewport.y = Cast<f32>(swapchain.m_Extent.height);
|
||||
viewport.width = Cast<f32>(swapchain.m_Extent.width);
|
||||
viewport.height = -Cast<f32>(swapchain.m_Extent.height);
|
||||
|
|
|
|||
|
|
@ -116,10 +116,9 @@ main(int, char **)
|
|||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
Context context = {"Box", VERSION};
|
||||
Window window = {"Box (Aster)", {640, 480}};
|
||||
Surface surface = {&context, &window, "Primary"};
|
||||
Window window = {"Box (Aster)", &context, {640, 480}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&surface, &context};
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
||||
INFO("Using {} as the primary device.", deviceToUse.m_DeviceProperties.deviceName.data());
|
||||
|
|
@ -131,7 +130,7 @@ main(int, char **)
|
|||
QueueAllocation queueAllocation = FindAppropriateQueueAllocation(&deviceToUse);
|
||||
Device device = {&context, &deviceToUse, &enabledDeviceFeatures, {queueAllocation}, "Primary Device"};
|
||||
vk::Queue commandQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||
Pipeline pipeline = CreatePipeline(&device, &swapchain);
|
||||
|
||||
Camera camera = {
|
||||
|
|
@ -454,7 +453,7 @@ main(int, char **)
|
|||
camera.m_Model *= rotate(mat4{1.0f}, Cast<f32>(45.0_deg * Time::m_Delta), vec3(0.0f, 1.0f, 0.0f));
|
||||
ubo.Write(&device, 0, sizeof camera, &camera);
|
||||
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &surface, window.GetSize());
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &window);
|
||||
|
||||
u32 imageIndex = currentFrame->m_ImageIdx;
|
||||
vk::ImageView currentImageView = swapchain.m_ImageViews[imageIndex];
|
||||
|
|
@ -529,7 +528,7 @@ main(int, char **)
|
|||
};
|
||||
AbortIfFailed(commandQueue.submit(1, &submitInfo, currentFrame->m_FrameAvailableFence));
|
||||
|
||||
currentFrame->Present(commandQueue, &swapchain, &surface, window.GetSize());
|
||||
currentFrame->Present(commandQueue, &swapchain, &window);
|
||||
}
|
||||
|
||||
device.WaitIdle();
|
||||
|
|
|
|||
|
|
@ -134,10 +134,9 @@ main(int, char **)
|
|||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
Context context = {"ModelRender", VERSION};
|
||||
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
||||
Surface surface = {&context, &window, "Primary Surface"};
|
||||
Window window = {"ModelRender (Aster)", &context, {INIT_WIDTH, INIT_HEIGHT}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&surface, &context};
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
||||
usize physicalDeviceOffsetAlignment = deviceToUse.m_DeviceProperties.limits.minUniformBufferOffsetAlignment;
|
||||
|
|
@ -174,7 +173,7 @@ main(int, char **)
|
|||
Device device = {&context, &deviceToUse, &enabledDeviceFeatures,
|
||||
{queueAllocation}, pipelineCacheData, "Primary Device"};
|
||||
vk::Queue graphicsQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||
GpuResourceManager resourceManager = {&device, 1000};
|
||||
|
||||
AssetLoader assetLoader = {&resourceManager, graphicsQueue, queueAllocation.m_Family, queueAllocation.m_Family};
|
||||
|
|
@ -514,7 +513,7 @@ main(int, char **)
|
|||
cameraController.m_Camera.CalculateInverses();
|
||||
ubo.Write(&device, 0, sizeof cameraController.m_Camera, &cameraController.m_Camera);
|
||||
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &surface, window.GetSize());
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &window);
|
||||
|
||||
u32 imageIndex = currentFrame->m_ImageIdx;
|
||||
vk::Image currentSwapchainImage = swapchain.m_Images[imageIndex];
|
||||
|
|
@ -687,7 +686,7 @@ main(int, char **)
|
|||
};
|
||||
AbortIfFailed(graphicsQueue.submit(1, &submitInfo, currentFrame->m_FrameAvailableFence));
|
||||
|
||||
currentFrame->Present(graphicsQueue, &swapchain, &surface, window.GetSize());
|
||||
currentFrame->Present(graphicsQueue, &swapchain, &window);
|
||||
}
|
||||
|
||||
device.WaitIdle();
|
||||
|
|
|
|||
|
|
@ -239,11 +239,12 @@ LightManager::Update()
|
|||
const u16 requiredBufferCapacity = eastl::min(Cast<u16>(m_Lights.capacity()), MAX_LIGHTS);
|
||||
if ((m_GpuBufferCapacity_ & CAPACITY_MASK) < requiredBufferCapacity)
|
||||
{
|
||||
StorageBuffer newBuffer;
|
||||
newBuffer.Init(m_ResourceManager->m_Device, requiredBufferCapacity * sizeof m_Lights[0], true, "Light Buffer");
|
||||
m_GpuBufferCapacity_ = requiredBufferCapacity | UPDATE_REQUIRED_BIT;
|
||||
|
||||
m_ResourceManager->Release(m_MetaInfo.m_LightBuffer);
|
||||
m_MetaInfo.m_LightBuffer =
|
||||
m_ResourceManager->CreateStorageBuffer(requiredBufferCapacity * sizeof m_Lights[0], "Light Buffer");
|
||||
m_MetaInfo.m_LightBuffer = m_ResourceManager->Commit(&newBuffer);
|
||||
}
|
||||
if (m_GpuBufferCapacity_ & UPDATE_REQUIRED_BIT)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,11 +37,10 @@ main(int, char *[])
|
|||
{
|
||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
Window window = {"Scene Render [WIP] (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
||||
Context context = {"Scene Render [WIP]", VERSION};
|
||||
Surface surface = {&context, &window, "Primary Surface"};
|
||||
Window window = {"Scene Render [WIP] (Aster)", &context, {INIT_WIDTH, INIT_HEIGHT}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&surface, &context};
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
||||
vk::Extent2D internalResolution = {1920, 1080};
|
||||
|
|
@ -92,7 +91,7 @@ main(int, char *[])
|
|||
Device device = {&context, &deviceToUse, &enabledDeviceFeatures,
|
||||
{queueAllocation}, pipelineCacheData, "Primary Device"};
|
||||
vk::Queue graphicsQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||
Swapchain swapchain = {&surface, &device, window.GetSize(),"Primary Chain"};
|
||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||
|
||||
RenderResourceManager resourceManager = {&device, 1024};
|
||||
EcsRegistry registry;
|
||||
|
|
@ -356,7 +355,7 @@ main(int, char *[])
|
|||
// glm::rotate(dynTrans.m_Rotation, Cast<f32>(30_deg * (++index) * Time::m_Delta), vec3{0.0f, 1.0f, 0.0f});
|
||||
//}
|
||||
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &surface, window.GetSize());
|
||||
Frame *currentFrame = frameManager.GetNextFrame(&swapchain, &window);
|
||||
|
||||
u32 imageIndex = currentFrame->m_ImageIdx;
|
||||
vk::Image currentSwapchainImage = swapchain.m_Images[imageIndex];
|
||||
|
|
@ -553,7 +552,7 @@ main(int, char *[])
|
|||
};
|
||||
AbortIfFailed(graphicsQueue.submit(1, &submitInfo, currentFrame->m_FrameAvailableFence));
|
||||
|
||||
currentFrame->Present(graphicsQueue, &swapchain, &surface, window.GetSize());
|
||||
currentFrame->Present(graphicsQueue, &swapchain, &window);
|
||||
}
|
||||
|
||||
device.WaitIdle();
|
||||
|
|
|
|||
|
|
@ -96,39 +96,20 @@ void
|
|||
BufferManager::Init(const u32 maxCapacity)
|
||||
{
|
||||
m_MaxCapacity = maxCapacity;
|
||||
m_FreeHead = 0;
|
||||
m_Buffers = new Buffer[maxCapacity];
|
||||
|
||||
// Chaining Freeheads
|
||||
Buffer *pIter = m_Buffers;
|
||||
for (u32 i = 1; i < m_MaxCapacity; ++i)
|
||||
{
|
||||
*Recast<u32 *>(pIter) = i;
|
||||
++pIter;
|
||||
}
|
||||
*Recast<u32 *>(pIter) = GpuResourceHandle::INVALID_HANDLE;
|
||||
m_FreeHead = GpuResourceHandle::INVALID_HANDLE;
|
||||
}
|
||||
|
||||
BufferHandle
|
||||
BufferManager::Allocate(const Device *device, const u32 bufferSize, const cstr name)
|
||||
{
|
||||
StorageBuffer sb;
|
||||
sb.Init(device, bufferSize, true, true, name);
|
||||
return Commit_(&sb);
|
||||
}
|
||||
|
||||
BufferHandle
|
||||
BufferManager::Commit_(StorageBuffer *buffer)
|
||||
BufferManager::Commit(StorageBuffer *buffer)
|
||||
{
|
||||
ERROR_IF(!buffer || !buffer->IsValid() || !buffer->IsOwned(), "Buffer must be valid and owned for commital")
|
||||
THEN_ABORT(-1);
|
||||
|
||||
ERROR_IF(m_FreeHead == GpuResourceHandle::INVALID_HANDLE, "Out of buffers")
|
||||
THEN_ABORT(-1);
|
||||
|
||||
if (m_FreeHead != GpuResourceHandle::INVALID_HANDLE)
|
||||
{
|
||||
const u32 index = m_FreeHead;
|
||||
|
||||
Buffer *allocatedBuffer = &m_Buffers[index];
|
||||
StorageBuffer *allocatedBuffer = &m_Buffers[index];
|
||||
|
||||
assert(!allocatedBuffer->IsValid());
|
||||
m_FreeHead = *Recast<u32 *>(allocatedBuffer);
|
||||
|
|
@ -143,12 +124,29 @@ BufferManager::Commit_(StorageBuffer *buffer)
|
|||
return {index};
|
||||
}
|
||||
|
||||
const u32 index = Cast<u32>(m_Buffers.size());
|
||||
if (index < m_MaxCapacity)
|
||||
{
|
||||
StorageBuffer *allocatedBuffer = &m_Buffers.push_back();
|
||||
|
||||
// Ensure it is copyable.
|
||||
static_assert(std::is_trivially_copyable_v<StorageBuffer>);
|
||||
*allocatedBuffer = *buffer;
|
||||
|
||||
buffer->m_Size_ &= ~StorageBuffer::OWNED_BIT;
|
||||
|
||||
return {index};
|
||||
}
|
||||
|
||||
ERROR("Out of Buffers") THEN_ABORT(-1);
|
||||
}
|
||||
|
||||
StorageBuffer *
|
||||
BufferManager::Fetch(const BufferHandle handle)
|
||||
{
|
||||
assert(!handle.IsInvalid());
|
||||
|
||||
return Recast<StorageBuffer *>(&m_Buffers[handle.m_Index]);
|
||||
return &m_Buffers[handle.m_Index];
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -156,7 +154,7 @@ BufferManager::Release(const Device *device, const BufferHandle handle)
|
|||
{
|
||||
assert(!handle.IsInvalid());
|
||||
|
||||
Buffer *allocatedBuffer = &m_Buffers[handle.m_Index];
|
||||
StorageBuffer *allocatedBuffer = &m_Buffers[handle.m_Index];
|
||||
allocatedBuffer->Destroy(device);
|
||||
|
||||
assert(!allocatedBuffer->IsValid());
|
||||
|
|
@ -168,19 +166,10 @@ BufferManager::Release(const Device *device, const BufferHandle handle)
|
|||
void
|
||||
BufferManager::Destroy(const Device *device)
|
||||
{
|
||||
if (!m_Buffers)
|
||||
for (auto &buffer : m_Buffers)
|
||||
{
|
||||
WARN("Double Deletion");
|
||||
return;
|
||||
buffer.Destroy(device);
|
||||
}
|
||||
|
||||
Buffer *pBegin = m_Buffers;
|
||||
const Buffer *pEnd = m_Buffers + m_MaxCapacity;
|
||||
while (pBegin != pEnd)
|
||||
{
|
||||
(pBegin++)->Destroy(device);
|
||||
}
|
||||
delete[] Take(m_Buffers);
|
||||
}
|
||||
|
||||
StorageTextureHandle
|
||||
|
|
@ -416,39 +405,9 @@ RenderResourceManager::WriteInfo::WriteInfo(vk::BufferView info)
|
|||
}
|
||||
|
||||
BufferHandle
|
||||
RenderResourceManager::Commit_(StorageBuffer *storageBuffer)
|
||||
RenderResourceManager::Commit(StorageBuffer *storageBuffer)
|
||||
{
|
||||
const BufferHandle handle = m_BufferManager.Commit_(storageBuffer);
|
||||
|
||||
m_WriteInfos.emplace_back(vk::DescriptorBufferInfo{
|
||||
.buffer = storageBuffer->m_Buffer,
|
||||
.offset = 0,
|
||||
.range = storageBuffer->GetSize(),
|
||||
});
|
||||
|
||||
m_Writes.push_back({
|
||||
.dstSet = m_DescriptorSet,
|
||||
.dstBinding = BUFFER_BINDING_INDEX,
|
||||
.dstArrayElement = handle.m_Index,
|
||||
.descriptorCount = 1,
|
||||
.descriptorType = vk::DescriptorType::eStorageBuffer,
|
||||
.pBufferInfo = &m_WriteInfos.back().uBufferInfo,
|
||||
});
|
||||
|
||||
m_WriteOwner.emplace_back(HandleType::eBuffer, handle.m_Index);
|
||||
|
||||
#if !defined(ASTER_NDEBUG)
|
||||
++m_CommitedBufferCount;
|
||||
#endif
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
BufferHandle
|
||||
RenderResourceManager::CreateStorageBuffer(const u32 bufferSize, const cstr name)
|
||||
{
|
||||
auto handle = m_BufferManager.Allocate(m_Device, bufferSize, name);
|
||||
const auto storageBuffer = m_BufferManager.Fetch(handle);
|
||||
const BufferHandle handle = m_BufferManager.Commit(storageBuffer);
|
||||
|
||||
m_WriteInfos.emplace_back(vk::DescriptorBufferInfo{
|
||||
.buffer = storageBuffer->m_Buffer,
|
||||
|
|
@ -789,7 +748,7 @@ RenderResourceManager::RenderResourceManager(Device *device, u16 maxSize, bool u
|
|||
m_Device->SetName(m_DescriptorSet, "Bindless Set");
|
||||
|
||||
// NOTE: This needs to be synced with the destructor manually.
|
||||
assert(Commit_(m_Geometry.m_BackingBuffer.get()).m_Index == UNIFIED_GEOMETRY_DATA_HANDLE_INDEX); // Making an assumption to avoid extra bindings.
|
||||
assert(Commit(m_Geometry.m_BackingBuffer.get()).m_Index == UNIFIED_GEOMETRY_DATA_HANDLE_INDEX); // Making an assumption to avoid extra bindings.
|
||||
}
|
||||
|
||||
RenderResourceManager::~RenderResourceManager()
|
||||
|
|
|
|||
|
|
@ -75,13 +75,12 @@ struct TextureManager
|
|||
|
||||
struct BufferManager
|
||||
{
|
||||
Buffer* m_Buffers;
|
||||
eastl::vector<StorageBuffer> m_Buffers;
|
||||
u32 m_MaxCapacity;
|
||||
u32 m_FreeHead;
|
||||
|
||||
void Init(u32 maxCapacity);
|
||||
BufferHandle Allocate(const Device *device, u32 bufferSize, cstr name);
|
||||
BufferHandle Commit_(StorageBuffer *buffer);
|
||||
BufferHandle Commit(StorageBuffer *buffer);
|
||||
StorageBuffer *Fetch(BufferHandle handle);
|
||||
void Release(const Device *device, BufferHandle handle);
|
||||
void Destroy(const Device *device);
|
||||
|
|
@ -179,7 +178,6 @@ struct RenderResourceManager
|
|||
SamplerManager m_SamplerManager;
|
||||
|
||||
void EraseWrites(u32 handleIndex, HandleType handleType);
|
||||
BufferHandle Commit_(StorageBuffer *storageBuffer); // Commit to GPU and take Ownership
|
||||
|
||||
public:
|
||||
Device *m_Device;
|
||||
|
|
@ -200,7 +198,7 @@ struct RenderResourceManager
|
|||
|
||||
bool m_UseBufferAddr;
|
||||
|
||||
BufferHandle CreateStorageBuffer(u32 bufferSize, cstr name); // Allocate a new buffer and commit to GPU.
|
||||
BufferHandle Commit(StorageBuffer *storageBuffer); // Commit to GPU and take Ownership
|
||||
void Write(BufferHandle handle, usize offset, usize size, const void *data); // Write to buffer
|
||||
void Release(BufferHandle handle); // Release and Destroy
|
||||
void Release(StorageBuffer *storageBuffer, BufferHandle handle); // Release and Return
|
||||
|
|
|
|||
Loading…
Reference in New Issue