Compare commits
No commits in common. "a790c26f1c69a6931521bc8b6e1112f902ca411f" and "703624eb8681b118877b9e1bdd2ed0e915f47ec5" have entirely different histories.
a790c26f1c
...
703624eb86
|
|
@ -7,7 +7,7 @@ INTERFACE
|
||||||
"global.h"
|
"global.h"
|
||||||
"constants.h"
|
"constants.h"
|
||||||
"config.h"
|
"config.h"
|
||||||
"instance.h"
|
"context.h"
|
||||||
"physical_device.h"
|
"physical_device.h"
|
||||||
"device.h"
|
"device.h"
|
||||||
"swapchain.h"
|
"swapchain.h"
|
||||||
|
|
|
||||||
|
|
@ -8,25 +8,25 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class Instance
|
* @class Context
|
||||||
*
|
*
|
||||||
* @brief Vulkan context to handle device initialization logic.
|
* @brief Vulkan context to handle device initialization logic.
|
||||||
*
|
*
|
||||||
* Handles the required hardware interactions.
|
* Handles the required hardware interactions.
|
||||||
*/
|
*/
|
||||||
struct Instance final
|
struct Context final
|
||||||
{
|
{
|
||||||
// Members
|
// Members
|
||||||
vk::Instance m_Instance = nullptr;
|
vk::Instance m_Instance = nullptr;
|
||||||
vk::DebugUtilsMessengerEXT m_DebugMessenger = nullptr;
|
vk::DebugUtilsMessengerEXT m_DebugMessenger = nullptr;
|
||||||
|
|
||||||
// Ctor/Dtor
|
// Ctor/Dtor
|
||||||
Instance(cstr appName, Version version, bool enableValidation = ENABLE_LAYER_MESSAGES_DEFAULT_VALUE);
|
Context(cstr appName, Version version, bool enableValidation = ENABLE_LAYER_MESSAGES_DEFAULT_VALUE);
|
||||||
~Instance();
|
~Context();
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
Instance(Instance &&other) noexcept;
|
Context(Context &&other) noexcept;
|
||||||
Instance &operator=(Instance &&other) noexcept;
|
Context &operator=(Context &&other) noexcept;
|
||||||
|
|
||||||
#if !defined(ASTER_NDEBUG)
|
#if !defined(ASTER_NDEBUG)
|
||||||
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = true;
|
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = true;
|
||||||
|
|
@ -34,5 +34,5 @@ struct Instance final
|
||||||
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = false;
|
constexpr static bool ENABLE_LAYER_MESSAGES_DEFAULT_VALUE = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Instance);
|
DISALLOW_COPY_AND_ASSIGN(Context);
|
||||||
};
|
};
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <EASTL/vector.h>
|
#include <EASTL/vector.h>
|
||||||
|
|
||||||
struct QueueAllocation;
|
struct QueueAllocation;
|
||||||
struct Instance;
|
struct Context;
|
||||||
struct PhysicalDevice;
|
struct PhysicalDevice;
|
||||||
|
|
||||||
struct Features
|
struct Features
|
||||||
|
|
@ -40,9 +40,9 @@ struct Device final
|
||||||
void WaitIdle() const;
|
void WaitIdle() const;
|
||||||
|
|
||||||
// Ctor/Dtor
|
// Ctor/Dtor
|
||||||
Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
||||||
Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
||||||
NameString &&name);
|
NameString &&name);
|
||||||
~Device();
|
~Device();
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
struct Instance;
|
struct Context;
|
||||||
|
|
||||||
enum class QueueSupportFlagBits
|
enum class QueueSupportFlagBits
|
||||||
{
|
{
|
||||||
|
|
@ -54,5 +54,5 @@ struct PhysicalDevice final
|
||||||
class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
|
class PhysicalDevices : public eastl::fixed_vector<PhysicalDevice, 4>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PhysicalDevices(const Surface *surface, const Instance *context);
|
PhysicalDevices(const Surface *surface, const Context *context);
|
||||||
};
|
};
|
||||||
|
|
@ -7,17 +7,17 @@
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
struct Instance;
|
struct Context;
|
||||||
struct Window;
|
struct Window;
|
||||||
|
|
||||||
struct Surface
|
struct Surface
|
||||||
{
|
{
|
||||||
Instance *m_Context;
|
Context *m_Context;
|
||||||
vk::SurfaceKHR m_Surface;
|
vk::SurfaceKHR m_Surface;
|
||||||
NameString m_Name;
|
NameString m_Name;
|
||||||
|
|
||||||
// Ctor Dtor
|
// Ctor Dtor
|
||||||
Surface(Instance *context, const Window *window, cstr name);
|
Surface(Context *context, const Window *window, cstr name);
|
||||||
~Surface();
|
~Surface();
|
||||||
|
|
||||||
// Move
|
// Move
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,5 @@ class BufferManager final
|
||||||
[[nodiscard]] Ref<StorageBuffer> CreateStorageBuffer(usize size, cstr name = nullptr) const;
|
[[nodiscard]] Ref<StorageBuffer> CreateStorageBuffer(usize size, cstr name = nullptr) const;
|
||||||
[[nodiscard]] Ref<UniformBuffer> CreateUniformBuffer(usize size, cstr name = nullptr) const;
|
[[nodiscard]] Ref<UniformBuffer> CreateUniformBuffer(usize size, cstr name = nullptr) const;
|
||||||
[[nodiscard]] Ref<StagingBuffer> CreateStagingBuffer(usize size, cstr name = nullptr) const;
|
[[nodiscard]] Ref<StagingBuffer> CreateStagingBuffer(usize size, cstr name = nullptr) const;
|
||||||
[[nodiscard]] Ref<VertexBuffer> CreateVertexBuffer(usize size, cstr name = nullptr) const;
|
|
||||||
};
|
};
|
||||||
} // namespace systems
|
} // namespace systems
|
||||||
|
|
@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.13)
|
||||||
target_sources(aster_core
|
target_sources(aster_core
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"global.cpp"
|
"global.cpp"
|
||||||
"instance.cpp"
|
"context.cpp"
|
||||||
"physical_device.cpp"
|
"physical_device.cpp"
|
||||||
"device.cpp"
|
"device.cpp"
|
||||||
"swapchain.cpp"
|
"swapchain.cpp"
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
// Copyright (c) 2020-2025 Anish Bhobe
|
// Copyright (c) 2020-2025 Anish Bhobe
|
||||||
// =============================================
|
// =============================================
|
||||||
|
|
||||||
#include "core/instance.h"
|
#include "core/context.h"
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
#include <EASTL/fixed_vector.h>
|
#include <EASTL/fixed_vector.h>
|
||||||
|
|
@ -35,7 +35,7 @@ DebugCallback(const VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::Instance(const cstr appName, const Version version, bool enableValidation)
|
Context::Context(const cstr appName, const Version version, bool enableValidation)
|
||||||
{
|
{
|
||||||
INFO_IF(enableValidation, "Validation Layers enabled");
|
INFO_IF(enableValidation, "Validation Layers enabled");
|
||||||
|
|
||||||
|
|
@ -97,7 +97,7 @@ Instance::Instance(const cstr appName, const Version version, bool enableValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::~Instance()
|
Context::~Context()
|
||||||
{
|
{
|
||||||
if (m_DebugMessenger)
|
if (m_DebugMessenger)
|
||||||
{
|
{
|
||||||
|
|
@ -108,14 +108,14 @@ Instance::~Instance()
|
||||||
DEBUG("Instance destroyed");
|
DEBUG("Instance destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance::Instance(Instance &&other) noexcept
|
Context::Context(Context &&other) noexcept
|
||||||
: m_Instance(Take(other.m_Instance))
|
: m_Instance(Take(other.m_Instance))
|
||||||
, m_DebugMessenger(Take(other.m_DebugMessenger))
|
, m_DebugMessenger(Take(other.m_DebugMessenger))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Instance &
|
Context &
|
||||||
Instance::operator=(Instance &&other) noexcept
|
Context::operator=(Context &&other) noexcept
|
||||||
{
|
{
|
||||||
if (this == &other)
|
if (this == &other)
|
||||||
return *this;
|
return *this;
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
#include "core/instance.h"
|
#include "core/context.h"
|
||||||
#include "core/physical_device.h"
|
#include "core/physical_device.h"
|
||||||
#include "core/queue_allocation.h"
|
#include "core/queue_allocation.h"
|
||||||
|
|
||||||
|
|
@ -17,13 +17,13 @@ constexpr eastl::array DEVICE_EXTENSIONS = {
|
||||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
Device::Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device::Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name)
|
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name)
|
||||||
: Device(context, physicalDevice, enabledFeatures, queueAllocations, {}, std::move(name))
|
: Device(context, physicalDevice, enabledFeatures, queueAllocations, {}, std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Device::Device(const Instance *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
Device::Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||||
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
const eastl::vector<QueueAllocation> &queueAllocations, eastl::span<u8> &&pipelineCacheData,
|
||||||
NameString &&name)
|
NameString &&name)
|
||||||
: m_Name(std::move(name))
|
: m_Name(std::move(name))
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/physical_device.h"
|
#include "core/physical_device.h"
|
||||||
|
|
||||||
#include "core/instance.h"
|
#include "core/context.h"
|
||||||
#include "core/surface.h"
|
#include "core/surface.h"
|
||||||
|
|
||||||
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
[[nodiscard]] vk::SurfaceCapabilitiesKHR
|
||||||
|
|
@ -154,7 +154,7 @@ EnumeratePhysicalDevices(const vk::Instance instance)
|
||||||
return physicalDevices;
|
return physicalDevices;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalDevices::PhysicalDevices(const Surface *surface, const Instance *context)
|
PhysicalDevices::PhysicalDevices(const Surface *surface, const Context *context)
|
||||||
{
|
{
|
||||||
auto physicalDevices = EnumeratePhysicalDevices(context->m_Instance);
|
auto physicalDevices = EnumeratePhysicalDevices(context->m_Instance);
|
||||||
for (auto physicalDevice : physicalDevices)
|
for (auto physicalDevice : physicalDevices)
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
#include "core/surface.h"
|
#include "core/surface.h"
|
||||||
|
|
||||||
#include "core/instance.h"
|
#include "core/context.h"
|
||||||
#include "core/window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
Surface::Surface(Instance *context, const Window *window, cstr name)
|
Surface::Surface(Context *context, const Window *window, cstr name)
|
||||||
: m_Context(context)
|
: m_Context(context)
|
||||||
, m_Name(name)
|
, m_Name(name)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "core/window.h"
|
#include "core/window.h"
|
||||||
|
|
||||||
#include "core/instance.h"
|
#include "core/context.h"
|
||||||
#include "util/logger.h"
|
#include "util/logger.h"
|
||||||
|
|
||||||
std::atomic_uint64_t Window::m_WindowCount = 0;
|
std::atomic_uint64_t Window::m_WindowCount = 0;
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,6 @@ BufferManager::CreateStagingBuffer(const usize size, const cstr name) const
|
||||||
return std::make_shared<StagingBuffer>(Buffer{m_Device, size, usage, createFlags, memoryUsage, name});
|
return std::make_shared<StagingBuffer>(Buffer{m_Device, size, usage, createFlags, memoryUsage, name});
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<VertexBuffer>
|
|
||||||
BufferManager::CreateVertexBuffer(const usize size, const cstr name) const
|
|
||||||
{
|
|
||||||
constexpr vk::BufferUsageFlags usage = vk::BufferUsageFlagBits::eVertexBuffer;
|
|
||||||
constexpr VmaAllocationCreateFlags createFlags =
|
|
||||||
VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT;
|
|
||||||
constexpr VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_AUTO;
|
|
||||||
return std::make_shared<VertexBuffer>(Buffer{m_Device, size, usage, createFlags, memoryUsage, name});
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// void
|
// void
|
||||||
// UniformBuffer::Init(const Device *device, const usize size, const cstr name)
|
// UniformBuffer::Init(const Device *device, const usize size, const cstr name)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
|
|
||||||
#include "aster/core/instance.h"
|
#include "aster/core/context.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/window.h"
|
#include "aster/core/window.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
@ -26,7 +26,7 @@ VulkanAssert(VkResult result)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
Init(const Context *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
||||||
const u32 imageCount, const u32 queueFamily, const vk::Queue queue)
|
const u32 imageCount, const u32 queueFamily, const vk::Queue queue)
|
||||||
{
|
{
|
||||||
g_AttachmentFormat = attachmentFormat;
|
g_AttachmentFormat = attachmentFormat;
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
struct Device;
|
struct Device;
|
||||||
struct Instance;
|
struct Context;
|
||||||
struct Window;
|
struct Window;
|
||||||
struct Swapchain;
|
struct Swapchain;
|
||||||
|
|
||||||
// ReSharper disable once CppInconsistentNaming
|
// ReSharper disable once CppInconsistentNaming
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
void Init(const Instance *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
void Init(const Context *context, const Device *device, const Window *window, vk::Format attachmentFormat,
|
||||||
u32 imageCount, u32 queueFamily, vk::Queue queue);
|
u32 imageCount, u32 queueFamily, vk::Queue queue);
|
||||||
void Destroy(const Device *device);
|
void Destroy(const Device *device);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/instance.h"
|
#include "aster/core/context.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
#include "aster/core/pipeline.h"
|
#include "aster/core/pipeline.h"
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
#include "aster/core/window.h"
|
#include "aster/core/window.h"
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "aster/systems/resource_manager.h"
|
|
||||||
|
|
||||||
#include <EASTL/array.h>
|
#include <EASTL/array.h>
|
||||||
|
|
||||||
|
|
@ -76,7 +75,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"Triangle (Aster)", {640, 480}};
|
Window window = {"Triangle (Aster)", {640, 480}};
|
||||||
Instance context = {"Triangle", VERSION};
|
Context context = {"Triangle", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
@ -93,7 +92,6 @@ main(int, char **)
|
||||||
vk::Queue commandQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
vk::Queue commandQueue = device.GetQueue(queueAllocation.m_Family, 0);
|
||||||
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
Swapchain swapchain = {&surface, &device, window.GetSize(), "Primary Chain"};
|
||||||
Pipeline pipeline = CreatePipeline(&device, &swapchain);
|
Pipeline pipeline = CreatePipeline(&device, &swapchain);
|
||||||
systems::ResourceManager resourceManager{&device};
|
|
||||||
|
|
||||||
vk::CommandPool copyPool;
|
vk::CommandPool copyPool;
|
||||||
vk::CommandBuffer copyBuffer;
|
vk::CommandBuffer copyBuffer;
|
||||||
|
|
@ -119,8 +117,45 @@ main(int, char **)
|
||||||
Vertex{.m_Position = {0.5f, -0.5f, 0.0f}, .m_Color = {0.0f, 1.0f, 0.0f}},
|
Vertex{.m_Position = {0.5f, -0.5f, 0.0f}, .m_Color = {0.0f, 1.0f, 0.0f}},
|
||||||
Vertex{.m_Position = {0.0f, 0.5f, 0.0f}, .m_Color = {0.0f, 0.0f, 1.0f}},
|
Vertex{.m_Position = {0.0f, 0.5f, 0.0f}, .m_Color = {0.0f, 0.0f, 1.0f}},
|
||||||
};
|
};
|
||||||
auto vbo = resourceManager.Buffers().CreateVertexBuffer(vertices.size() * sizeof vertices[0], "VBO");
|
VertexBuffer vbo;
|
||||||
vbo->Write(0, vertices.size() * sizeof vertices[0], vertices.data());
|
vbo.Init(&device, vertices.size() * sizeof vertices[0], "VBO");
|
||||||
|
{
|
||||||
|
StagingBuffer staging;
|
||||||
|
staging.Init(&device, vertices.size() * sizeof vertices[0], "Staging");
|
||||||
|
staging.Write(0, vertices.size() * sizeof vertices[0], vertices.data());
|
||||||
|
|
||||||
|
vk::Fence fence;
|
||||||
|
vk::FenceCreateInfo fenceCreateInfo = {};
|
||||||
|
auto result = device.m_Device.createFence(&fenceCreateInfo, nullptr, &fence);
|
||||||
|
ERROR_IF(Failed(result), "Fence creation failed. Cause: {}", result) THEN_ABORT(result);
|
||||||
|
|
||||||
|
vk::CommandBufferBeginInfo beginInfo = {.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit};
|
||||||
|
result = copyBuffer.begin(&beginInfo);
|
||||||
|
ERROR_IF(Failed(result), "Copy begin failed. Cause: {}", result) THEN_ABORT(result);
|
||||||
|
|
||||||
|
vk::BufferCopy bufferCopy = {.srcOffset = 0, .dstOffset = 0, .size = staging.m_Size};
|
||||||
|
copyBuffer.copyBuffer(staging.m_Buffer, vbo.m_Buffer, 1, &bufferCopy);
|
||||||
|
|
||||||
|
result = copyBuffer.end();
|
||||||
|
ERROR_IF(Failed(result), "Copy end failed. Cause: {}", result) THEN_ABORT(result);
|
||||||
|
|
||||||
|
vk::SubmitInfo submitInfo = {
|
||||||
|
.commandBufferCount = 1,
|
||||||
|
.pCommandBuffers = ©Buffer,
|
||||||
|
};
|
||||||
|
|
||||||
|
result = commandQueue.submit(1, &submitInfo, fence);
|
||||||
|
ERROR_IF(Failed(result), "Submit failed. Cause: {}", result) THEN_ABORT(result) ELSE_INFO("Submit copy");
|
||||||
|
|
||||||
|
result = device.m_Device.waitForFences(1, &fence, true, MaxValue<u64>);
|
||||||
|
ERROR_IF(Failed(result), "Fence wait failed. Cause: {}", result) THEN_ABORT(result) ELSE_INFO("Fence wait");
|
||||||
|
|
||||||
|
result = device.m_Device.resetCommandPool(copyPool, {});
|
||||||
|
ERROR_IF(Failed(result), "Couldn't reset command pool. Cause: {}", result) THEN_ABORT(result);
|
||||||
|
|
||||||
|
device.m_Device.destroy(fence, nullptr);
|
||||||
|
staging.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
// Persistent variables
|
// Persistent variables
|
||||||
vk::Viewport viewport = {
|
vk::Viewport viewport = {
|
||||||
|
|
@ -259,7 +294,7 @@ main(int, char **)
|
||||||
cmd.setScissor(0, 1, &scissor);
|
cmd.setScissor(0, 1, &scissor);
|
||||||
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline.m_Pipeline);
|
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline.m_Pipeline);
|
||||||
usize offsets = 0;
|
usize offsets = 0;
|
||||||
cmd.bindVertexBuffers(0, 1, &vbo->m_Buffer, &offsets);
|
cmd.bindVertexBuffers(0, 1, &vbo.m_Buffer, &offsets);
|
||||||
cmd.draw(3, 1, 0, 0);
|
cmd.draw(3, 1, 0, 0);
|
||||||
|
|
||||||
cmd.endRendering();
|
cmd.endRendering();
|
||||||
|
|
@ -317,6 +352,7 @@ main(int, char **)
|
||||||
device.WaitIdle();
|
device.WaitIdle();
|
||||||
|
|
||||||
device.m_Device.destroy(copyPool, nullptr);
|
device.m_Device.destroy(copyPool, nullptr);
|
||||||
|
vbo.Destroy();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/instance.h"
|
#include "aster/core/context.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/image.h"
|
#include "aster/core/image.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
|
|
@ -99,7 +99,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"Box (Aster)", {640, 480}};
|
Window window = {"Box (Aster)", {640, 480}};
|
||||||
Instance context = {"Box", VERSION};
|
Context context = {"Box", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary"};
|
Surface surface = {&context, &window, "Primary"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -367,21 +367,14 @@ GenerateMipMaps(vk::CommandBuffer commandBuffer, const Ref<Texture> &texture, vk
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<systems::ResId<TextureView>, Ref<StagingBuffer>>
|
std::tuple<systems::ResId<TextureView>, Ref<Buffer>>
|
||||||
AssetLoader::LoadImageToGpu(tinygltf::Image *image, bool isSrgb, cstr name) const
|
AssetLoader::LoadImageToGpu(tinygltf::Image *image, bool isSrgb) const
|
||||||
{
|
{
|
||||||
// TODO(Something not loading properly).
|
// TODO(Something not loading properly).
|
||||||
|
|
||||||
assert(image->component == 4);
|
assert(image->component == 4);
|
||||||
assert(image->height > 0 && image->width > 0);
|
assert(image->height > 0 && image->width > 0);
|
||||||
|
|
||||||
#if !defined(ASTER_NDEBUG)
|
|
||||||
auto assignedName = name ? name : image->name.empty() ? image->uri.c_str() : image->name.c_str();
|
|
||||||
#else
|
|
||||||
auto assignedName = nullptr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
u32 height = Cast<u32>(image->height);
|
u32 height = Cast<u32>(image->height);
|
||||||
u32 width = Cast<u32>(image->width);
|
u32 width = Cast<u32>(image->width);
|
||||||
|
|
||||||
|
|
@ -391,7 +384,7 @@ AssetLoader::LoadImageToGpu(tinygltf::Image *image, bool isSrgb, cstr name) cons
|
||||||
auto texture = m_ResourceManager->Images().CreateTexture2D<Texture>({
|
auto texture = m_ResourceManager->Images().CreateTexture2D<Texture>({
|
||||||
.m_Format = imageFormat,
|
.m_Format = imageFormat,
|
||||||
.m_Extent = {width, height},
|
.m_Extent = {width, height},
|
||||||
.m_Name = assignedName,
|
.m_Name = image->name.c_str(),
|
||||||
.m_IsSampled = true,
|
.m_IsSampled = true,
|
||||||
.m_IsMipMapped = true,
|
.m_IsMipMapped = true,
|
||||||
.m_IsStorage = false,
|
.m_IsStorage = false,
|
||||||
|
|
@ -402,7 +395,7 @@ AssetLoader::LoadImageToGpu(tinygltf::Image *image, bool isSrgb, cstr name) cons
|
||||||
|
|
||||||
#if !defined(ASTER_NDEBUG)
|
#if !defined(ASTER_NDEBUG)
|
||||||
StackString<128> loadActionName = "Load: ";
|
StackString<128> loadActionName = "Load: ";
|
||||||
loadActionName += assignedName;
|
loadActionName += image->name.empty() ? "<texture>" : image->name.c_str();
|
||||||
vk::DebugUtilsLabelEXT debugLabel = {
|
vk::DebugUtilsLabelEXT debugLabel = {
|
||||||
.pLabelName = loadActionName.c_str(),
|
.pLabelName = loadActionName.c_str(),
|
||||||
.color = std::array{1.0f, 1.0f, 1.0f, 1.0f},
|
.color = std::array{1.0f, 1.0f, 1.0f, 1.0f},
|
||||||
|
|
@ -548,7 +541,7 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
m_CommandBuffer.beginDebugUtilsLabelEXT(&debugLabel);
|
m_CommandBuffer.beginDebugUtilsLabelEXT(&debugLabel);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
eastl::vector<Ref<StagingBuffer>> stagingBuffers;
|
eastl::vector<Ref<Buffer>> stagingBuffers;
|
||||||
|
|
||||||
eastl::hash_map<i32, systems::ResId<TextureView>> textureHandleMap;
|
eastl::hash_map<i32, systems::ResId<TextureView>> textureHandleMap;
|
||||||
|
|
||||||
|
|
@ -569,9 +562,8 @@ AssetLoader::LoadModelToGpu(cstr path, cstr name)
|
||||||
return iter->second;
|
return iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &texture = model.textures[index];
|
auto *image = &model.images[index];
|
||||||
auto *image = &model.images[texture.source];
|
auto [handle, staging] = LoadImageToGpu(image, isSrgb);
|
||||||
auto [handle, staging] = LoadImageToGpu(image, isSrgb, texture.name.empty() ? nullptr : texture.name.c_str());
|
|
||||||
textureHandleMap.emplace(index, handle);
|
textureHandleMap.emplace(index, handle);
|
||||||
stagingBuffers.emplace_back(std::move(staging));
|
stagingBuffers.emplace_back(std::move(staging));
|
||||||
return handle;
|
return handle;
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,7 @@ struct AssetLoader
|
||||||
u32 m_GraphicsQueueIndex;
|
u32 m_GraphicsQueueIndex;
|
||||||
|
|
||||||
Ref<TextureView> LoadHdrImage(cstr path, cstr name = nullptr) const;
|
Ref<TextureView> LoadHdrImage(cstr path, cstr name = nullptr) const;
|
||||||
|
std::tuple<systems::ResId<TextureView>, Ref<Buffer>> LoadImageToGpu(tinygltf::Image *image, bool isSrgb) const;
|
||||||
Model LoadModelToGpu(cstr path, cstr name = nullptr);
|
Model LoadModelToGpu(cstr path, cstr name = nullptr);
|
||||||
|
|
||||||
constexpr static auto ANormal = "NORMAL";
|
constexpr static auto ANormal = "NORMAL";
|
||||||
|
|
@ -131,10 +132,6 @@ struct AssetLoader
|
||||||
AssetLoader &operator=(AssetLoader &&other) noexcept;
|
AssetLoader &operator=(AssetLoader &&other) noexcept;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AssetLoader);
|
DISALLOW_COPY_AND_ASSIGN(AssetLoader);
|
||||||
|
|
||||||
private:
|
|
||||||
std::tuple<systems::ResId<TextureView>, Ref<StagingBuffer>>
|
|
||||||
LoadImageToGpu(tinygltf::Image *image, bool isSrgb, cstr name = nullptr) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
BIN
samples/03_model_render/model/Sponza/10381718147657362067.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/10381718147657362067.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/10388182081421875623.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/10388182081421875623.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/11474523244911310074.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/11474523244911310074.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/11490520546946913238.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/11490520546946913238.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/11872827283454512094.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/11872827283454512094.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/11968150294050148237.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/11968150294050148237.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/1219024358953944284.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/1219024358953944284.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/12501374198249454378.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/12501374198249454378.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/13196865903111448057.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/13196865903111448057.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/13824894030729245199.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/13824894030729245199.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/13982482287905699490.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/13982482287905699490.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/14118779221266351425.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/14118779221266351425.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/14170708867020035030.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/14170708867020035030.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/14267839433702832875.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/14267839433702832875.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/14650633544276105767.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/14650633544276105767.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/15295713303328085182.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/15295713303328085182.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/15722799267630235092.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/15722799267630235092.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/16275776544635328252.png (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/16275776544635328252.png (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/16299174074766089871.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/16299174074766089871.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/16885566240357350108.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/16885566240357350108.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/17556969131407844942.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/17556969131407844942.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/17876391417123941155.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/17876391417123941155.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2051777328469649772.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2051777328469649772.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2185409758123873465.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2185409758123873465.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2299742237651021498.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2299742237651021498.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2374361008830720677.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2374361008830720677.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2411100444841994089.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2411100444841994089.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2775690330959970771.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2775690330959970771.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/2969916736137545357.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/2969916736137545357.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/332936164838540657.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/332936164838540657.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/3371964815757888145.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/3371964815757888145.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/3455394979645218238.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/3455394979645218238.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/3628158980083700836.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/3628158980083700836.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/3827035219084910048.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/3827035219084910048.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4477655471536070370.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4477655471536070370.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4601176305987539675.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4601176305987539675.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/466164707995436622.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/466164707995436622.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4675343432951571524.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4675343432951571524.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4871783166746854860.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4871783166746854860.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4910669866631290573.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4910669866631290573.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/4975155472559461469.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/4975155472559461469.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/5061699253647017043.png (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/5061699253647017043.png (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/5792855332885324923.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/5792855332885324923.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/5823059166183034438.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/5823059166183034438.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/6047387724914829168.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/6047387724914829168.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/6151467286084645207.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/6151467286084645207.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/6593109234861095314.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/6593109234861095314.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/6667038893015345571.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/6667038893015345571.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/6772804448157695701.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/6772804448157695701.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/7056944414013900257.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/7056944414013900257.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/715093869573992647.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/715093869573992647.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/7268504077753552595.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/7268504077753552595.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/7441062115984513793.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/7441062115984513793.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/755318871556304029.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/755318871556304029.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/759203620573749278.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/759203620573749278.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/7645212358685992005.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/7645212358685992005.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/7815564343179553343.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/7815564343179553343.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8006627369776289000.png (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8006627369776289000.png (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8051790464816141987.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8051790464816141987.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8114461559286000061.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8114461559286000061.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8481240838833932244.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8481240838833932244.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8503262930880235456.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8503262930880235456.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8747919177698443163.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8747919177698443163.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8750083169368950601.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8750083169368950601.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8773302468495022225.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8773302468495022225.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/8783994986360286082.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/8783994986360286082.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/9288698199695299068.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/9288698199695299068.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/9916269861720640319.jpg (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/9916269861720640319.jpg (Stored with Git LFS)
Binary file not shown.
BIN
samples/03_model_render/model/Sponza/Sponza.bin (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/Sponza.bin (Stored with Git LFS)
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
samples/03_model_render/model/Sponza/white.png (Stored with Git LFS)
BIN
samples/03_model_render/model/Sponza/white.png (Stored with Git LFS)
Binary file not shown.
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "aster/core/buffer.h"
|
#include "aster/core/buffer.h"
|
||||||
#include "aster/core/constants.h"
|
#include "aster/core/constants.h"
|
||||||
#include "aster/core/instance.h"
|
#include "aster/core/context.h"
|
||||||
#include "aster/core/device.h"
|
#include "aster/core/device.h"
|
||||||
#include "aster/core/image.h"
|
#include "aster/core/image.h"
|
||||||
#include "aster/core/physical_device.h"
|
#include "aster/core/physical_device.h"
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
constexpr u32 MAX_FRAMES_IN_FLIGHT = 3;
|
constexpr u32 MAX_FRAMES_IN_FLIGHT = 3;
|
||||||
constexpr auto PIPELINE_CACHE_FILE = "PipelineCacheData.bin";
|
constexpr auto PIPELINE_CACHE_FILE = "PipelineCacheData.bin";
|
||||||
constexpr auto MODEL_FILE = "model/Sponza/Sponza.gltf";
|
constexpr auto MODEL_FILE = "model/DamagedHelmet.glb";
|
||||||
constexpr auto BACKDROP_FILE = "image/photo_studio_loft_hall_4k.hdr";
|
constexpr auto BACKDROP_FILE = "image/photo_studio_loft_hall_4k.hdr";
|
||||||
constexpr u32 INIT_WIDTH = 1280;
|
constexpr u32 INIT_WIDTH = 1280;
|
||||||
constexpr u32 INIT_HEIGHT = 720;
|
constexpr u32 INIT_HEIGHT = 720;
|
||||||
|
|
@ -136,7 +136,7 @@ main(int, char **)
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
Window window = {"ModelRender (Aster)", {INIT_WIDTH, INIT_HEIGHT}};
|
||||||
Instance context = {"ModelRender", VERSION};
|
Context context = {"ModelRender", VERSION};
|
||||||
Surface surface = {&context, &window, "Primary Surface"};
|
Surface surface = {&context, &window, "Primary Surface"};
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&surface, &context};
|
PhysicalDevices physicalDevices = {&surface, &context};
|
||||||
|
|
|
||||||
|
|
@ -15,38 +15,38 @@ struct FS_Output
|
||||||
|
|
||||||
float4 GetAlbedo(float2 UV, float4 InColor)
|
float4 GetAlbedo(float2 UV, float4 InColor)
|
||||||
{
|
{
|
||||||
float4 AlbedoFactor = (float4) MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].AlbedoFactor;
|
float4 AlbedoFactor = (float4) MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].AlbedoFactor;
|
||||||
uint AlbedoTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].AlbedoTex;
|
uint AlbedoTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].AlbedoTex;
|
||||||
|
|
||||||
return AlbedoFactor * InColor * (AlbedoTexId != INVALID_HANDLE ? Textures[NonUniformResourceIndex(AlbedoTexId)].Sample(ImmutableSamplers[NonUniformResourceIndex(AlbedoTexId)], UV) : 1.0f.xxxx);
|
return AlbedoFactor * InColor * (AlbedoTexId != INVALID_HANDLE ? Textures[AlbedoTexId].Sample(ImmutableSamplers[AlbedoTexId], UV) : 1.0f.xxxx);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetOcclusion(float2 UV)
|
float GetOcclusion(float2 UV)
|
||||||
{
|
{
|
||||||
uint OcclusionTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].OcclusionTex;
|
uint OcclusionTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].OcclusionTex;
|
||||||
|
|
||||||
return OcclusionTexId != INVALID_HANDLE ? Textures[NonUniformResourceIndex(OcclusionTexId)].Sample(ImmutableSamplers[NonUniformResourceIndex(OcclusionTexId)], UV).r : 1.0f;
|
return OcclusionTexId != INVALID_HANDLE ? Textures[OcclusionTexId].Sample(ImmutableSamplers[OcclusionTexId], UV).r : 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 GetEmissive(float2 UV)
|
float3 GetEmissive(float2 UV)
|
||||||
{
|
{
|
||||||
float3 EmissionFactor = (float3) MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].EmissionFactor;
|
float3 EmissionFactor = (float3) MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].EmissionFactor;
|
||||||
uint EmissionTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].EmissionTex;
|
uint EmissionTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].EmissionTex;
|
||||||
|
|
||||||
return EmissionFactor * (EmissionTexId != INVALID_HANDLE ? Textures[NonUniformResourceIndex(EmissionTexId)].Sample(ImmutableSamplers[NonUniformResourceIndex(EmissionTexId)], UV).rgb : 1.0f.xxx);
|
return EmissionFactor * (EmissionTexId != INVALID_HANDLE ? Textures[EmissionTexId].Sample(ImmutableSamplers[EmissionTexId], UV).rgb : 1.0f.xxx);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 GetNormal(float3 Position, float3 Normal, float2 UV)
|
float3 GetNormal(float3 Position, float3 Normal, float2 UV)
|
||||||
{
|
{
|
||||||
float3 N = normalize(Normal);
|
float3 N = normalize(Normal);
|
||||||
|
|
||||||
uint NormalTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].NormalTex;
|
uint NormalTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].NormalTex;
|
||||||
if (NormalTexId == INVALID_HANDLE)
|
if (NormalTexId == INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
return N;
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 TangentSpaceNormal = Textures[NonUniformResourceIndex(NormalTexId)].Sample(ImmutableSamplers[NonUniformResourceIndex(NormalTexId)], UV).xyz * 2.0f - 1.0f;
|
float3 TangentSpaceNormal = Textures[NormalTexId].Sample(ImmutableSamplers[NormalTexId], UV).xyz * 2.0f - 1.0f;
|
||||||
|
|
||||||
float3 q1 = ddx(Position);
|
float3 q1 = ddx(Position);
|
||||||
float3 q2 = ddy(Position);
|
float3 q2 = ddy(Position);
|
||||||
|
|
@ -62,10 +62,10 @@ float3 GetNormal(float3 Position, float3 Normal, float2 UV)
|
||||||
|
|
||||||
float2 GetMetalRough(float2 UV)
|
float2 GetMetalRough(float2 UV)
|
||||||
{
|
{
|
||||||
float2 MetalRoughFactors = float2(MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].MetalFactor, MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].RoughFactor);
|
float2 MetalRoughFactors = float2(MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].MetalFactor, MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].RoughFactor);
|
||||||
uint MetalRoughTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][NonUniformResourceIndex(PushConstant.MaterialIdx)].MetalRoughTex;
|
uint MetalRoughTexId = MaterialsBuffer[PushConstant.MaterialBufferHandle][PushConstant.MaterialIdx].MetalRoughTex;
|
||||||
|
|
||||||
return MetalRoughFactors * (MetalRoughTexId != INVALID_HANDLE ? Textures[NonUniformResourceIndex(MetalRoughTexId)].Sample(ImmutableSamplers[NonUniformResourceIndex(MetalRoughTexId)], UV).bg : 1.0f.xx); // Metal is B, Rough is G.
|
return MetalRoughFactors * (MetalRoughTexId != INVALID_HANDLE ? Textures[MetalRoughTexId].Sample(ImmutableSamplers[MetalRoughTexId], UV).bg : 1.0f.xx); // Metal is B, Rough is G.
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 SampleIrradiance(float3 Direction)
|
float3 SampleIrradiance(float3 Direction)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
add_subdirectory("00_util")
|
add_subdirectory("00_util")
|
||||||
add_subdirectory("01_triangle")
|
# add_subdirectory("01_triangle")
|
||||||
add_subdirectory("02_box")
|
add_subdirectory("02_box")
|
||||||
add_subdirectory("03_model_render")
|
add_subdirectory("03_model_render")
|
||||||
# add_subdirectory("04_scenes")
|
# add_subdirectory("04_scenes")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue