Compare commits
3 Commits
12ab256a30
...
cba6c580cf
| Author | SHA1 | Date |
|---|---|---|
|
|
cba6c580cf | |
|
|
7d906e08f8 | |
|
|
ad6ee9a0e5 |
|
|
@ -10,42 +10,15 @@ find_package(fmt CONFIG REQUIRED)
|
||||||
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
||||||
find_package(EASTL CONFIG REQUIRED)
|
find_package(EASTL CONFIG REQUIRED)
|
||||||
|
|
||||||
set(HEADER_FILES
|
add_library(aster_core STATIC)
|
||||||
"constants.h"
|
|
||||||
"config.h"
|
|
||||||
"logger.h"
|
|
||||||
"global.h"
|
|
||||||
"context.h"
|
|
||||||
"window.h"
|
|
||||||
"physical_device.h"
|
|
||||||
"device.h"
|
|
||||||
"swapchain.h"
|
|
||||||
"pipeline.h"
|
|
||||||
"queue_allocation.h"
|
|
||||||
"buffer.h"
|
|
||||||
"image.h"
|
|
||||||
"surface.h"
|
|
||||||
"size.h")
|
|
||||||
|
|
||||||
set(SOURCE_FILES
|
add_subdirectory("include")
|
||||||
"logger.cpp"
|
add_subdirectory("src")
|
||||||
"global.cpp"
|
|
||||||
"context.cpp"
|
|
||||||
"window.cpp"
|
|
||||||
"physical_device.cpp"
|
|
||||||
"device.cpp"
|
|
||||||
"swapchain.cpp"
|
|
||||||
"pipeline.cpp"
|
|
||||||
"buffer.cpp"
|
|
||||||
"image.cpp"
|
|
||||||
"surface.cpp")
|
|
||||||
|
|
||||||
add_library(aster_core STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
|
||||||
set_property(TARGET aster_core PROPERTY CXX_STANDARD 20)
|
set_property(TARGET aster_core PROPERTY CXX_STANDARD 20)
|
||||||
|
|
||||||
target_precompile_headers(aster_core PUBLIC global.h)
|
target_include_directories(aster_core PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include/aster")
|
||||||
|
target_include_directories(aster_core PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
target_include_directories(aster_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
|
|
||||||
target_link_libraries(aster_core PUBLIC glm::glm-header-only)
|
target_link_libraries(aster_core PUBLIC glm::glm-header-only)
|
||||||
target_link_libraries(aster_core PRIVATE glfw)
|
target_link_libraries(aster_core PRIVATE glfw)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_subdirectory("aster")
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_subdirectory("core")
|
||||||
|
add_subdirectory("util")
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
PUBLIC "aster.h")
|
||||||
|
|
||||||
|
target_precompile_headers(aster_core PUBLIC "aster.h")
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: aster.h
|
||||||
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "core/global.h"
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Core Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
INTERFACE
|
||||||
|
"global.h"
|
||||||
|
"constants.h"
|
||||||
|
"config.h"
|
||||||
|
"context.h"
|
||||||
|
"physical_device.h"
|
||||||
|
"device.h"
|
||||||
|
"swapchain.h"
|
||||||
|
"pipeline.h"
|
||||||
|
"queue_allocation.h"
|
||||||
|
"buffer.h"
|
||||||
|
"image.h"
|
||||||
|
"surface.h"
|
||||||
|
"size.h"
|
||||||
|
"window.h")
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
#include <GLFW/glfw3.h>
|
#include <GLFW/glfw3.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
@ -40,6 +40,12 @@ constexpr u32 ASTER_API_VERSION = VK_API_VERSION_1_3;
|
||||||
CLASS_NAME(const CLASS_NAME &other) = delete; \
|
CLASS_NAME(const CLASS_NAME &other) = delete; \
|
||||||
CLASS_NAME &operator=(const CLASS_NAME &other) = delete
|
CLASS_NAME &operator=(const CLASS_NAME &other) = delete
|
||||||
|
|
||||||
|
#define PIN_MEMORY(CLASS_NAME) \
|
||||||
|
CLASS_NAME(const CLASS_NAME &other) = delete; \
|
||||||
|
CLASS_NAME(CLASS_NAME &&other) noexcept = delete; \
|
||||||
|
CLASS_NAME &operator=(const CLASS_NAME &other) = delete; \
|
||||||
|
CLASS_NAME &operator=(CLASS_NAME &&other) noexcept = delete
|
||||||
|
|
||||||
#define Take(ELEMENT) eastl::exchange(ELEMENT, {})
|
#define Take(ELEMENT) eastl::exchange(ELEMENT, {})
|
||||||
|
|
||||||
#define TODO(MSG) assert(false && ("Unimplemented: " MSG))
|
#define TODO(MSG) assert(false && ("Unimplemented: " MSG))
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
INTERFACE
|
||||||
|
"manager.h"
|
||||||
|
"buffer_manager.h")
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: manager.h
|
||||||
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "aster/aster.h"
|
||||||
|
#include "aster/core/buffer.h"
|
||||||
|
#include "manager.h"
|
||||||
|
|
||||||
|
namespace systems
|
||||||
|
{
|
||||||
|
class BufferManager final : public Manager<Buffer>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BufferManager(const Device *device, const u32 maxCount);
|
||||||
|
|
||||||
|
Ref CreateStorageBuffer(usize size, cstr name = nullptr);
|
||||||
|
};
|
||||||
|
} // namespace systems
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: manager.h
|
||||||
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "aster/aster.h"
|
||||||
|
|
||||||
|
#include <EASTL/intrusive_ptr.h>
|
||||||
|
|
||||||
|
struct Device;
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
requires std::is_default_constructible_v<T>
|
||||||
|
class Manager
|
||||||
|
{
|
||||||
|
using InternalType = T;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct Type : InternalType
|
||||||
|
{
|
||||||
|
void
|
||||||
|
AddRef()
|
||||||
|
{
|
||||||
|
m_Instance->AddRef(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Release()
|
||||||
|
{
|
||||||
|
m_Instance->Release(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32
|
||||||
|
GetIndex()
|
||||||
|
{
|
||||||
|
return m_Instance->GetIndex(this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static_assert(sizeof(Type) == sizeof(InternalType));
|
||||||
|
|
||||||
|
using Ref = eastl::intrusive_ptr<Type>;
|
||||||
|
|
||||||
|
static Manager *Instance();
|
||||||
|
|
||||||
|
explicit Manager(const Device *device, const u32 maxCount)
|
||||||
|
: m_MaxCount{maxCount}
|
||||||
|
, m_FreeHead{0}
|
||||||
|
, m_Device{device}
|
||||||
|
{
|
||||||
|
m_Data = new Type[m_MaxCount];
|
||||||
|
m_RefCount = new u32[m_MaxCount];
|
||||||
|
|
||||||
|
for (u32 i = 0; i < m_MaxCount; ++i)
|
||||||
|
{
|
||||||
|
m_RefCount[i] = (i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~Manager()
|
||||||
|
{
|
||||||
|
if (!m_Data)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (u32 i = 0; i < m_MaxCount; ++i)
|
||||||
|
{
|
||||||
|
m_Data[i].Destroy(m_Device);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] m_Data;
|
||||||
|
delete[] m_RefCount;
|
||||||
|
m_Data = nullptr;
|
||||||
|
m_RefCount = nullptr;
|
||||||
|
m_MaxCount = 0;
|
||||||
|
m_FreeHead = 0;
|
||||||
|
m_Device = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
PIN_MEMORY(Manager);
|
||||||
|
|
||||||
|
void
|
||||||
|
AddRef(Type *p)
|
||||||
|
{
|
||||||
|
auto index = GetIndex(p);
|
||||||
|
|
||||||
|
++m_RefCount[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Release(Type *p)
|
||||||
|
{
|
||||||
|
assert(p->IsValid());
|
||||||
|
|
||||||
|
auto index = GetIndex(p);
|
||||||
|
|
||||||
|
auto rc = --m_RefCount[index];
|
||||||
|
|
||||||
|
// Overflow case.
|
||||||
|
assert(rc != MaxValue<u32>);
|
||||||
|
if (rc == 0)
|
||||||
|
{
|
||||||
|
p->Destroy(m_Device);
|
||||||
|
|
||||||
|
m_RefCount[index] = m_FreeHead;
|
||||||
|
m_FreeHead = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u32
|
||||||
|
GetIndex(Type *p)
|
||||||
|
{
|
||||||
|
auto index = p - m_Data;
|
||||||
|
assert(index >= 0 && index < m_MaxCount);
|
||||||
|
|
||||||
|
return Cast<u32>(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Type *m_Data = nullptr;
|
||||||
|
u32 *m_RefCount = nullptr;
|
||||||
|
u32 m_MaxCount = 0;
|
||||||
|
u32 m_FreeHead = 0;
|
||||||
|
|
||||||
|
static Manager *m_Instance;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const Device *m_Device;
|
||||||
|
|
||||||
|
void
|
||||||
|
SetInstance(Manager *instance)
|
||||||
|
{
|
||||||
|
assert(!m_Instance);
|
||||||
|
m_Instance = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref
|
||||||
|
Alloc()
|
||||||
|
{
|
||||||
|
ERROR_IF(m_FreeHead >= m_MaxCount, "Max buffers allocated.") THEN_ABORT(-1);
|
||||||
|
|
||||||
|
const auto index = m_FreeHead;
|
||||||
|
m_FreeHead = m_RefCount[index];
|
||||||
|
m_RefCount[index] = 0;
|
||||||
|
return Ref{&m_Data[index]};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
INTERFACE "logger.h")
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include <debugbreak.h>
|
#include <debugbreak.h>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_subdirectory("aster")
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_subdirectory("core")
|
||||||
|
add_subdirectory("systems")
|
||||||
|
add_subdirectory("util")
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
PRIVATE
|
||||||
|
"global.cpp"
|
||||||
|
"context.cpp"
|
||||||
|
"physical_device.cpp"
|
||||||
|
"device.cpp"
|
||||||
|
"swapchain.cpp"
|
||||||
|
"pipeline.cpp"
|
||||||
|
"buffer.cpp"
|
||||||
|
"image.cpp"
|
||||||
|
"surface.cpp"
|
||||||
|
"window.cpp")
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "core/buffer.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
Buffer::Destroy(const Device *device)
|
Buffer::Destroy(const Device *device)
|
||||||
|
|
@ -44,7 +44,8 @@ Buffer::Allocate(const Device *device, usize size, vk::BufferUsageFlags bufferUs
|
||||||
vk::MemoryPropertyFlags memoryPropertyFlags;
|
vk::MemoryPropertyFlags memoryPropertyFlags;
|
||||||
vmaGetAllocationMemoryProperties(device->m_Allocator, allocation,
|
vmaGetAllocationMemoryProperties(device->m_Allocator, allocation,
|
||||||
Recast<VkMemoryPropertyFlags *>(&memoryPropertyFlags));
|
Recast<VkMemoryPropertyFlags *>(&memoryPropertyFlags));
|
||||||
bool hostAccessible = Cast<bool>(memoryPropertyFlags & vk::MemoryPropertyFlagBits::eHostVisible);
|
// TODO: Actually track Host Access
|
||||||
|
// bool hostAccessible = Cast<bool>(memoryPropertyFlags & vk::MemoryPropertyFlagBits::eHostVisible);
|
||||||
|
|
||||||
m_Buffer = buffer;
|
m_Buffer = buffer;
|
||||||
m_Size_ = size | VALID_BUFFER_BIT | OWNED_BIT;
|
m_Size_ = size | VALID_BUFFER_BIT | OWNED_BIT;
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "context.h"
|
#include "core/context.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "core/context.h"
|
||||||
#include "physical_device.h"
|
#include "core/physical_device.h"
|
||||||
#include "queue_allocation.h"
|
#include "core/queue_allocation.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "global.h"
|
#include "core/global.h"
|
||||||
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
@ -30,7 +30,7 @@ struct MemorySize
|
||||||
m_Kilobytes = totalKb % 1024;
|
m_Kilobytes = totalKb % 1024;
|
||||||
const usize totalMb = m_Megabytes + totalKb / 1024;
|
const usize totalMb = m_Megabytes + totalKb / 1024;
|
||||||
m_Megabytes = totalMb % 1024;
|
m_Megabytes = totalMb % 1024;
|
||||||
m_Gigabytes += totalMb / 1024;
|
m_Gigabytes += Cast<u16>(totalMb / 1024);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
@ -56,8 +56,7 @@ struct fmt::formatter<MemorySize>
|
||||||
// return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
|
// return format_to(ctx.out(), "({}, {})", foo.a, foo.b); // --== KEY LINE ==--
|
||||||
if (mem.m_Gigabytes > 0)
|
if (mem.m_Gigabytes > 0)
|
||||||
{
|
{
|
||||||
return v10::format_to(ctx.out(), "{}.{} GB", mem.m_Gigabytes,
|
return v10::format_to(ctx.out(), "{}.{} GB", mem.m_Gigabytes, Cast<u16>(mem.m_Megabytes / 1024.0));
|
||||||
Cast<u16>(mem.m_Megabytes / 1024.0));
|
|
||||||
}
|
}
|
||||||
if (mem.m_Megabytes > 0)
|
if (mem.m_Megabytes > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "image.h"
|
#include "core/image.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
Image::Destroy(const Device *device)
|
Image::Destroy(const Device *device)
|
||||||
|
|
@ -3,11 +3,10 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "physical_device.h"
|
#include "core/physical_device.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "core/context.h"
|
||||||
#include "surface.h"
|
#include "core/surface.h"
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
||||||
GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface)
|
GetSurfaceCapabilities(const vk::PhysicalDevice physicalDevice, const vk::SurfaceKHR surface)
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "pipeline.h"
|
#include "core/pipeline.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
Pipeline::Pipeline(const Device *device, vk::PipelineLayout layout, vk::Pipeline pipeline,
|
Pipeline::Pipeline(const Device *device, vk::PipelineLayout layout, vk::Pipeline pipeline,
|
||||||
eastl::vector<vk::DescriptorSetLayout> &&setLayouts)
|
eastl::vector<vk::DescriptorSetLayout> &&setLayouts)
|
||||||
|
|
@ -3,13 +3,14 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "surface.h"
|
#include "core/surface.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "core/context.h"
|
||||||
#include "window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
Surface::Surface(Context *context, const Window *window, cstr name)
|
Surface::Surface(Context *context, const Window *window, cstr name)
|
||||||
: m_Context(context)
|
: m_Context(context)
|
||||||
|
, m_Name(name)
|
||||||
{
|
{
|
||||||
VkSurfaceKHR surface;
|
VkSurfaceKHR surface;
|
||||||
auto result = Cast<vk::Result>(
|
auto result = Cast<vk::Result>(
|
||||||
|
|
@ -3,12 +3,11 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
#include "swapchain.h"
|
#include "core/swapchain.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "core/device.h"
|
||||||
#include "physical_device.h"
|
#include "core/physical_device.h"
|
||||||
#include "surface.h"
|
#include "core/surface.h"
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
[[nodiscard]] vk::Extent2D GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities);
|
[[nodiscard]] vk::Extent2D GetExtent(Size2D size, vk::SurfaceCapabilitiesKHR *surfaceCapabilities);
|
||||||
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "core/context.h"
|
||||||
#include "logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
std::atomic_uint64_t Window::m_WindowCount = 0;
|
std::atomic_uint64_t Window::m_WindowCount = 0;
|
||||||
std::atomic_bool Window::m_IsGlfwInit = false;
|
std::atomic_bool Window::m_IsGlfwInit = false;
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core
|
||||||
|
PRIVATE
|
||||||
|
"manager.cpp"
|
||||||
|
"buffer_manager.cpp")
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: buffer_manager.cpp
|
||||||
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#include "systems/buffer_manager.h"
|
||||||
|
|
||||||
|
Manager<Buffer> *Manager<Buffer>::m_Instance;
|
||||||
|
|
||||||
|
systems::BufferManager::Ref
|
||||||
|
systems::BufferManager::CreateStorageBuffer(const usize size, const cstr name)
|
||||||
|
{
|
||||||
|
Ref object = Alloc();
|
||||||
|
|
||||||
|
// TODO: Storage and Index buffer are set.
|
||||||
|
// This is hacky and should be improved.
|
||||||
|
constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eIndexBuffer |
|
||||||
|
vk::BufferUsageFlagBits::eShaderDeviceAddress;
|
||||||
|
constexpr VmaAllocationCreateFlags createFlags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT |
|
||||||
|
VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT |
|
||||||
|
VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
||||||
|
constexpr VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_AUTO;
|
||||||
|
object->Allocate(m_Device, size, usage, createFlags, memoryUsage, name);
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
|
systems::BufferManager::BufferManager(const Device *device, const u32 maxCount)
|
||||||
|
: Manager{device, maxCount}
|
||||||
|
{
|
||||||
|
SetInstance(this);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: manager.cpp
|
||||||
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
|
#include "systems/manager.h"
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# CMakeList.txt ; CMake project for Aster Util Headers
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
target_sources(aster_core PRIVATE "logger.cpp")
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
Logger g_Logger = Logger();
|
Logger g_Logger = Logger();
|
||||||
// ReSharper disable once CppInconsistentNaming
|
// ReSharper disable once CppInconsistentNaming
|
||||||
|
|
@ -5,12 +5,12 @@ cmake_minimum_required(VERSION 3.13)
|
||||||
find_package(imgui CONFIG REQUIRED)
|
find_package(imgui CONFIG REQUIRED)
|
||||||
|
|
||||||
add_library(util_helper STATIC
|
add_library(util_helper STATIC
|
||||||
helpers.h
|
"helpers.h"
|
||||||
helpers.cpp
|
"helpers.cpp"
|
||||||
frame.cpp
|
"frame.cpp"
|
||||||
frame.h
|
"frame.h"
|
||||||
gui.cpp
|
"gui.cpp"
|
||||||
gui.h)
|
"gui.h")
|
||||||
|
|
||||||
target_link_libraries(util_helper PRIVATE aster_core)
|
target_link_libraries(util_helper PRIVATE aster_core)
|
||||||
target_link_libraries(util_helper PRIVATE imgui::imgui)
|
target_link_libraries(util_helper PRIVATE imgui::imgui)
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@
|
||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/swapchain.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "swapchain.h"
|
|
||||||
|
|
||||||
Frame::Frame(const Device *device, const u32 queueFamilyIndex, const u32 frameCount)
|
Frame::Frame(const Device *device, const u32 queueFamilyIndex, const u32 frameCount)
|
||||||
: m_FrameIdx(frameCount)
|
: m_FrameIdx(frameCount)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#include "size.h"
|
#include "aster/core/size.h"
|
||||||
|
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "aster/core/context.h"
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/window.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
#include <imgui_impl_glfw.h>
|
#include <imgui_impl_glfw.h>
|
||||||
#include <imgui_impl_vulkan.h>
|
#include <imgui_impl_vulkan.h>
|
||||||
|
|
@ -108,11 +108,11 @@ StartBuild()
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
NewFrame();
|
NewFrame();
|
||||||
|
|
||||||
// static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
|
static ImGuiDockNodeFlags dockspaceFlags = ImGuiDockNodeFlags_None | ImGuiDockNodeFlags_PassthruCentralNode;
|
||||||
|
|
||||||
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
|
||||||
// because it would be confusing to have two docking targets within each others.
|
// because it would be confusing to have two docking targets within each others.
|
||||||
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None; // ImGuiWindowFlags_NoDocking;
|
ImGuiWindowFlags windowFlags = ImGuiWindowFlags_None | ImGuiWindowFlags_NoDocking;
|
||||||
|
|
||||||
const ImGuiViewport *viewport = GetMainViewport();
|
const ImGuiViewport *viewport = GetMainViewport();
|
||||||
SetNextWindowPos(viewport->WorkPos);
|
SetNextWindowPos(viewport->WorkPos);
|
||||||
|
|
@ -130,18 +130,18 @@ StartBuild()
|
||||||
// all active windows docked into it will lose their parent and become undocked.
|
// all active windows docked into it will lose their parent and become undocked.
|
||||||
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
|
// We cannot preserve the docking relationship between an active window and an inactive docking, otherwise
|
||||||
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
// any change of dockspace/settings would lead to windows being stuck in limbo and never being visible.
|
||||||
// PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
// Begin("DockSpace Demo", nullptr, windowFlags);
|
Begin("DockSpace Demo", nullptr, windowFlags);
|
||||||
// PopStyleVar();
|
PopStyleVar();
|
||||||
|
|
||||||
// PopStyleVar(2);
|
PopStyleVar(2);
|
||||||
|
|
||||||
// DockSpace
|
// DockSpace
|
||||||
// if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
if (GetIO().ConfigFlags & ImGuiConfigFlags_DockingEnable)
|
||||||
// {
|
{
|
||||||
// const ImGuiID dockspaceId = GetID("MyDockSpace");
|
const ImGuiID dockspaceId = GetID("MyDockSpace");
|
||||||
// DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
DockSpace(dockspaceId, ImVec2(0.0f, 0.0f), dockspaceFlags);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
#include "physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include "queue_allocation.h"
|
#include "aster/core/queue_allocation.h"
|
||||||
|
|
||||||
#include "EASTL/span.h"
|
#include "EASTL/span.h"
|
||||||
#include <EASTL/vector.h>
|
#include <EASTL/vector.h>
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,16 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/aster.h"
|
||||||
#include "constants.h"
|
|
||||||
#include "context.h"
|
|
||||||
#include "device.h"
|
|
||||||
#include "physical_device.h"
|
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "pipeline.h"
|
#include "aster/core/constants.h"
|
||||||
#include "swapchain.h"
|
#include "aster/core/context.h"
|
||||||
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/physical_device.h"
|
||||||
|
#include "aster/core/window.h"
|
||||||
|
#include "aster/core/pipeline.h"
|
||||||
|
#include "aster/core/swapchain.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
|
@ -74,8 +74,8 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Context context = {"Triangle", VERSION};
|
|
||||||
Window window = {"Triangle (Aster)", {640, 480}};
|
Window window = {"Triangle (Aster)", {640, 480}};
|
||||||
|
Context context = {"Triangle", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,22 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/aster.h"
|
||||||
#include "constants.h"
|
|
||||||
#include "context.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "device.h"
|
#include "aster/core/constants.h"
|
||||||
#include "global.h"
|
#include "aster/core/context.h"
|
||||||
#include "physical_device.h"
|
#include "aster/core/device.h"
|
||||||
#include "pipeline.h"
|
#include "aster/core/physical_device.h"
|
||||||
#include "swapchain.h"
|
#include "aster/core/pipeline.h"
|
||||||
#include "window.h"
|
#include "aster/core/swapchain.h"
|
||||||
|
#include "aster/core/window.h"
|
||||||
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "image.h"
|
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
@ -115,8 +116,8 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Context context = {"Box", VERSION};
|
|
||||||
Window window = {"Box (Aster)", {640, 480}};
|
Window window = {"Box (Aster)", {640, 480}};
|
||||||
|
Context context = {"Box", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -10,15 +10,15 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||||
|
|
||||||
#include "asset_loader.h"
|
#include "aster/core/buffer.h"
|
||||||
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "EASTL/fixed_vector.h"
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "device.h"
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
#include "asset_loader.h"
|
||||||
|
|
||||||
|
#include <EASTL/fixed_vector.h>
|
||||||
#include <EASTL/hash_map.h>
|
#include <EASTL/hash_map.h>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/aster.h"
|
||||||
#include "global.h"
|
|
||||||
|
#include "aster/core/buffer.h"
|
||||||
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
#include "nodes.h"
|
#include "nodes.h"
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,11 @@
|
||||||
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
|
||||||
#include "device.h"
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
|
||||||
|
#include "aster/core/buffer.h"
|
||||||
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include <EASTL/deque.h>
|
#include <EASTL/deque.h>
|
||||||
#include <EASTL/vector_map.h>
|
#include <EASTL/vector_map.h>
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,17 @@
|
||||||
|
|
||||||
#include "ibl_helpers.h"
|
#include "ibl_helpers.h"
|
||||||
|
|
||||||
#include "EASTL/fixed_vector.h"
|
#include "aster/core/device.h"
|
||||||
#include "EASTL/tuple.h"
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "asset_loader.h"
|
#include "asset_loader.h"
|
||||||
#include "device.h"
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
|
#include <EASTL/fixed_vector.h>
|
||||||
|
#include <EASTL/tuple.h>
|
||||||
|
|
||||||
constexpr cstr EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
constexpr cstr EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
||||||
constexpr cstr DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
constexpr cstr DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
||||||
constexpr cstr PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
constexpr cstr PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
||||||
|
|
@ -195,8 +197,8 @@ CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, const u32
|
||||||
vk::PushConstantRange pcr = {
|
vk::PushConstantRange pcr = {
|
||||||
.stageFlags = vk::ShaderStageFlagBits::eCompute,
|
.stageFlags = vk::ShaderStageFlagBits::eCompute,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
.size = eastl::max(eastl::max(sizeof(SkyboxPushConstants), sizeof(BrdfLutPushConstants)),
|
.size = Cast<u32>(eastl::max(eastl::max(sizeof(SkyboxPushConstants), sizeof(BrdfLutPushConstants)),
|
||||||
eastl::max(sizeof(DiffuseIrradiancePushConstants), sizeof(PrefilterPushConstants))),
|
eastl::max(sizeof(DiffuseIrradiancePushConstants), sizeof(PrefilterPushConstants)))),
|
||||||
};
|
};
|
||||||
|
|
||||||
vk::PipelineLayout pipelineLayout;
|
vk::PipelineLayout pipelineLayout;
|
||||||
|
|
@ -252,7 +254,7 @@ CreateCubeFromHdrEnv(AssetLoader *assetLoader, vk::Queue computeQueue, const u32
|
||||||
};
|
};
|
||||||
|
|
||||||
eastl::array<vk::Pipeline, computePipelineCreateInfo.size()> pipelines;
|
eastl::array<vk::Pipeline, computePipelineCreateInfo.size()> pipelines;
|
||||||
AbortIfFailed(pDevice->m_Device.createComputePipelines(pDevice->m_PipelineCache, computePipelineCreateInfo.size(),
|
AbortIfFailed(pDevice->m_Device.createComputePipelines(pDevice->m_PipelineCache, Cast<u32>(computePipelineCreateInfo.size()),
|
||||||
computePipelineCreateInfo.data(), nullptr,
|
computePipelineCreateInfo.data(), nullptr,
|
||||||
pipelines.data()));
|
pipelines.data()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
|
|
||||||
#include <EASTL/tuple.h>
|
|
||||||
|
|
||||||
struct Pipeline;
|
struct Pipeline;
|
||||||
struct Texture;
|
struct Texture;
|
||||||
struct TextureCube;
|
struct TextureCube;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "light_manager.h"
|
#include "light_manager.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "glm/ext/matrix_transform.hpp"
|
#include "glm/ext/matrix_transform.hpp"
|
||||||
|
|
||||||
struct Light
|
struct Light
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
// TODO: Separate files so you only import handles.
|
// TODO: Separate files so you only import handles.
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
|
|
@ -66,7 +66,7 @@ struct LightManager
|
||||||
// Using lower bit. Capacity can be directly a multiple of 2
|
// Using lower bit. Capacity can be directly a multiple of 2
|
||||||
// Thus, range is up to MaxValue<u16>
|
// Thus, range is up to MaxValue<u16>
|
||||||
constexpr static u16 UPDATE_REQUIRED_BIT = 1;
|
constexpr static u16 UPDATE_REQUIRED_BIT = 1;
|
||||||
constexpr static u16 CAPACITY_MASK = ~(UPDATE_REQUIRED_BIT);
|
constexpr static u16 CAPACITY_MASK = Cast<u16>(~UPDATE_REQUIRED_BIT);
|
||||||
|
|
||||||
LightHandle AddDirectional(const vec3 &direction, const vec3 &color, f32 intensity);
|
LightHandle AddDirectional(const vec3 &direction, const vec3 &color, f32 intensity);
|
||||||
LightHandle AddPoint(const vec3 &position, const vec3 &color, f32 radius, f32 intensity);
|
LightHandle AddPoint(const vec3 &position, const vec3 &color, f32 radius, f32 intensity);
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,17 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/aster.h"
|
||||||
#include "constants.h"
|
|
||||||
#include "context.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "device.h"
|
#include "aster/core/constants.h"
|
||||||
#include "global.h"
|
#include "aster/core/context.h"
|
||||||
#include "image.h"
|
#include "aster/core/device.h"
|
||||||
#include "physical_device.h"
|
#include "aster/core/image.h"
|
||||||
#include "pipeline.h"
|
#include "aster/core/physical_device.h"
|
||||||
#include "swapchain.h"
|
#include "aster/core/pipeline.h"
|
||||||
#include "window.h"
|
#include "aster/core/swapchain.h"
|
||||||
|
#include "aster/core/window.h"
|
||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
@ -133,8 +134,8 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Context context = {"ModelRender", VERSION};
|
|
||||||
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
||||||
|
Context context = {"ModelRender", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary Surface"};
|
Surface surface = {&context, &window, "Primary Surface"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include "EASTL/vector.h"
|
#include <EASTL/vector.h>
|
||||||
|
|
||||||
struct Nodes
|
struct Nodes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@
|
||||||
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/pipeline.h"
|
||||||
|
|
||||||
#include "gpu_resource_manager.h"
|
#include "gpu_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
#include "pipeline.h"
|
|
||||||
|
|
||||||
struct GpuResourceManager;
|
struct GpuResourceManager;
|
||||||
struct Swapchain;
|
struct Swapchain;
|
||||||
struct Device;
|
struct Device;
|
||||||
|
struct Pipeline;
|
||||||
|
|
||||||
constexpr auto VERTEX_SHADER_FILE = "shader/model.vs.hlsl.spv";
|
constexpr auto VERTEX_SHADER_FILE = "shader/model.vs.hlsl.spv";
|
||||||
constexpr auto FRAGMENT_SHADER_FILE = "shader/model.ps.hlsl.spv";
|
constexpr auto FRAGMENT_SHADER_FILE = "shader/model.ps.hlsl.spv";
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
|
|
||||||
#include "asset_loader.h"
|
#include "asset_loader.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
#include "image.h"
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "core_components.h"
|
#include "core_components.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
@ -870,7 +870,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
}
|
}
|
||||||
else if (material->alphaMode == "MASK")
|
else if (material->alphaMode == "MASK")
|
||||||
{
|
{
|
||||||
alphaBlendValue = material->alphaCutoff;
|
alphaBlendValue = Cast<f32>(material->alphaCutoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
materials.push_back({
|
materials.push_back({
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
|
|
||||||
#include "ecs_adapter.h"
|
#include "ecs_adapter.h"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
struct Camera
|
struct Camera
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
template <typename TComponent>
|
template <typename TComponent>
|
||||||
struct CDirty
|
struct CDirty
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,17 @@
|
||||||
|
|
||||||
#include "ibl_helpers.h"
|
#include "ibl_helpers.h"
|
||||||
|
|
||||||
#include "EASTL/fixed_vector.h"
|
#include "aster/core/device.h"
|
||||||
#include "EASTL/tuple.h"
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "asset_loader.h"
|
#include "asset_loader.h"
|
||||||
#include "device.h"
|
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
|
#include <EASTL/fixed_vector.h>
|
||||||
|
#include <EASTL/tuple.h>
|
||||||
|
|
||||||
constexpr cstr EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
constexpr cstr EQUIRECT_TO_CUBE_SHADER_FILE = "shader/eqrect_to_cube.cs.hlsl.spv";
|
||||||
constexpr cstr DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
constexpr cstr DIFFUSE_IRRADIANCE_SHADER_FILE = "shader/diffuse_irradiance.cs.hlsl.spv";
|
||||||
constexpr cstr PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
constexpr cstr PREFILTER_SHADER_FILE = "shader/prefilter.cs.hlsl.spv";
|
||||||
|
|
@ -195,8 +197,8 @@ CreateEnvironment(AssetLoader *assetLoader, vk::Queue computeQueue, const u32 cu
|
||||||
vk::PushConstantRange pcr = {
|
vk::PushConstantRange pcr = {
|
||||||
.stageFlags = vk::ShaderStageFlagBits::eCompute,
|
.stageFlags = vk::ShaderStageFlagBits::eCompute,
|
||||||
.offset = 0,
|
.offset = 0,
|
||||||
.size = eastl::max(eastl::max(sizeof(SkyboxPushConstants), sizeof(BrdfLutPushConstants)),
|
.size = Cast<u32>(eastl::max(eastl::max(sizeof(SkyboxPushConstants), sizeof(BrdfLutPushConstants)),
|
||||||
eastl::max(sizeof(DiffuseIrradiancePushConstants), sizeof(PrefilterPushConstants))),
|
eastl::max(sizeof(DiffuseIrradiancePushConstants), sizeof(PrefilterPushConstants)))),
|
||||||
};
|
};
|
||||||
|
|
||||||
vk::PipelineLayout pipelineLayout;
|
vk::PipelineLayout pipelineLayout;
|
||||||
|
|
@ -252,7 +254,7 @@ CreateEnvironment(AssetLoader *assetLoader, vk::Queue computeQueue, const u32 cu
|
||||||
};
|
};
|
||||||
|
|
||||||
eastl::array<vk::Pipeline, computePipelineCreateInfo.size()> pipelines;
|
eastl::array<vk::Pipeline, computePipelineCreateInfo.size()> pipelines;
|
||||||
AbortIfFailed(pDevice->m_Device.createComputePipelines(pDevice->m_PipelineCache, computePipelineCreateInfo.size(),
|
AbortIfFailed(pDevice->m_Device.createComputePipelines(pDevice->m_PipelineCache, Cast<u32>(computePipelineCreateInfo.size()),
|
||||||
computePipelineCreateInfo.data(), nullptr,
|
computePipelineCreateInfo.data(), nullptr,
|
||||||
pipelines.data()));
|
pipelines.data()));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
|
|
||||||
struct Pipeline;
|
struct Pipeline;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "light_manager.h"
|
#include "light_manager.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "ibl_helpers.h"
|
#include "ibl_helpers.h"
|
||||||
#include "glm/ext/matrix_transform.hpp"
|
#include "glm/ext/matrix_transform.hpp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
// TODO: Separate files so you only import handles.
|
// TODO: Separate files so you only import handles.
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
|
|
@ -73,7 +73,7 @@ struct LightManager
|
||||||
// Using lower bit. Capacity can be directly a multiple of 2
|
// Using lower bit. Capacity can be directly a multiple of 2
|
||||||
// Thus, range is up to MaxValue<u16>
|
// Thus, range is up to MaxValue<u16>
|
||||||
constexpr static u16 UPDATE_REQUIRED_BIT = 1;
|
constexpr static u16 UPDATE_REQUIRED_BIT = 1;
|
||||||
constexpr static u16 CAPACITY_MASK = ~(UPDATE_REQUIRED_BIT);
|
constexpr static u16 CAPACITY_MASK = Cast<u16>(~UPDATE_REQUIRED_BIT);
|
||||||
|
|
||||||
LightHandle AddDirectional(const vec3 &direction, const vec3 &color, f32 intensity);
|
LightHandle AddDirectional(const vec3 &direction, const vec3 &color, f32 intensity);
|
||||||
LightHandle AddPoint(const vec3 &position, const vec3 &color, f32 radius, f32 intensity);
|
LightHandle AddPoint(const vec3 &position, const vec3 &color, f32 radius, f32 intensity);
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,16 @@
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "context.h"
|
#include "aster/core/context.h"
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/image.h"
|
||||||
|
#include "aster/core/physical_device.h"
|
||||||
|
#include "aster/core/pipeline.h"
|
||||||
|
#include "aster/core/swapchain.h"
|
||||||
|
#include "aster/core/window.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "physical_device.h"
|
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
#include "swapchain.h"
|
|
||||||
#include "window.h"
|
|
||||||
|
|
||||||
#include "asset_loader.h"
|
#include "asset_loader.h"
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
|
|
@ -19,8 +22,6 @@
|
||||||
#include "ecs_adapter.h"
|
#include "ecs_adapter.h"
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
#include "ibl_helpers.h"
|
#include "ibl_helpers.h"
|
||||||
#include "image.h"
|
|
||||||
#include "pipeline.h"
|
|
||||||
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
|
|
@ -92,7 +93,7 @@ main(int, char *[])
|
||||||
Device device = {&context, &deviceToUse, &enabledDeviceFeatures,
|
Device device = {&context, &deviceToUse, &enabledDeviceFeatures,
|
||||||
{queueAllocation}, pipelineCacheData, "Primary Device"};
|
{queueAllocation}, pipelineCacheData, "Primary Device"};
|
||||||
vk::Queue graphicsQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
vk::Queue graphicsQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||||
Swapchain swapchain = {&surface, &device, window.GetSize(),"Primary Chain"};
|
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||||
|
|
||||||
RenderResourceManager resourceManager = {&device, 1024};
|
RenderResourceManager resourceManager = {&device, 1024};
|
||||||
EcsRegistry registry;
|
EcsRegistry registry;
|
||||||
|
|
@ -113,7 +114,7 @@ main(int, char *[])
|
||||||
|
|
||||||
eastl::vector<Model> models;
|
eastl::vector<Model> models;
|
||||||
models.emplace_back(assetLoader.LoadModelToGpu(MODEL_FILE, "Main Model"));
|
models.emplace_back(assetLoader.LoadModelToGpu(MODEL_FILE, "Main Model"));
|
||||||
//registry.get<CDynamicTransform>(model.m_RootEntity).m_Position = vec3(2 * i, 0, 2 * j);
|
// registry.get<CDynamicTransform>(model.m_RootEntity).m_Position = vec3(2 * i, 0, 2 * j);
|
||||||
|
|
||||||
UniformBuffer ubo;
|
UniformBuffer ubo;
|
||||||
constexpr usize uboLightManagerOffset = sizeof cameraController.m_Camera;
|
constexpr usize uboLightManagerOffset = sizeof cameraController.m_Camera;
|
||||||
|
|
@ -349,12 +350,13 @@ main(int, char *[])
|
||||||
{
|
{
|
||||||
Time::Update();
|
Time::Update();
|
||||||
|
|
||||||
//u32 index = 0;
|
// u32 index = 0;
|
||||||
//for (auto [entity, dynTrans] : rootModel.each())
|
// for (auto [entity, dynTrans] : rootModel.each())
|
||||||
//{
|
//{
|
||||||
// dynTrans.m_Rotation =
|
// dynTrans.m_Rotation =
|
||||||
// glm::rotate(dynTrans.m_Rotation, Cast<f32>(30_deg * (++index) * Time::m_Delta), vec3{0.0f, 1.0f, 0.0f});
|
// 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, &surface, window.GetSize());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@
|
||||||
|
|
||||||
#include "pipeline_utils.h"
|
#include "pipeline_utils.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
#include "pipeline.h"
|
#include "aster/core/pipeline.h"
|
||||||
|
|
||||||
struct RenderResourceManager;
|
struct RenderResourceManager;
|
||||||
struct Swapchain;
|
struct Swapchain;
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,11 @@
|
||||||
|
|
||||||
#include "render_resource_manager.h"
|
#include "render_resource_manager.h"
|
||||||
|
|
||||||
#include "buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "device.h"
|
#include "aster/core/device.h"
|
||||||
|
#include "aster/core/image.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "image.h"
|
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
|
@ -314,7 +315,7 @@ VirtualizedBufferPool::InitIndex(const Device *device, usize bufferMaxSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VirtualizedBufferPool::UpdateToGpu(const Device *device)
|
VirtualizedBufferPool::UpdateToGpu(const Device *)
|
||||||
{
|
{
|
||||||
// Unrequired until adding the non-ReBAR support.
|
// Unrequired until adding the non-ReBAR support.
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "global.h"
|
#include "aster/aster.h"
|
||||||
|
|
||||||
#include <EASTL/deque.h>
|
#include <EASTL/deque.h>
|
||||||
#include <EASTL/vector_map.h>
|
#include <EASTL/vector_map.h>
|
||||||
|
|
|
||||||
2
vcpkg
2
vcpkg
|
|
@ -1 +1 @@
|
||||||
Subproject commit b27651341123a59f7187b42ef2bc476284afb310
|
Subproject commit 0ca64b4e1c70fa6d9f53b369b8f3f0843797c20c
|
||||||
Loading…
Reference in New Issue