Fixed buffers, and restructured samples.
This commit is contained in:
parent
e64096ce3c
commit
c6987a9d5d
|
|
@ -21,6 +21,7 @@ void
|
|||
Buffer::Allocate(const Device *device, usize size, vk::BufferUsageFlags bufferUsage,
|
||||
VmaAllocationCreateFlags allocationFlags, VmaMemoryUsage memoryUsage, cstr name)
|
||||
{
|
||||
assert(!IsValid());
|
||||
assert(size <= SIZE_MASK);
|
||||
|
||||
vk::BufferCreateInfo bufferCreateInfo = {
|
||||
|
|
@ -104,7 +105,7 @@ StorageBuffer::Init(const Device *device, usize size, bool hostVisible, cstr nam
|
|||
else
|
||||
{
|
||||
Allocate(device, size, vk::BufferUsageFlagBits::eStorageBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
||||
VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, VMA_MEMORY_USAGE_AUTO, name);
|
||||
0, VMA_MEMORY_USAGE_AUTO, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -112,14 +113,14 @@ void
|
|||
VertexBuffer::Init(const Device *device, usize size, cstr name)
|
||||
{
|
||||
Allocate(device, size, vk::BufferUsageFlagBits::eVertexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
||||
VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, VMA_MEMORY_USAGE_AUTO, name);
|
||||
0, VMA_MEMORY_USAGE_AUTO, name);
|
||||
}
|
||||
|
||||
void
|
||||
IndexBuffer::Init(const Device *device, usize size, cstr name)
|
||||
{
|
||||
Allocate(device, size, vk::BufferUsageFlagBits::eIndexBuffer | vk::BufferUsageFlagBits::eTransferDst,
|
||||
VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT, VMA_MEMORY_USAGE_AUTO, name);
|
||||
0, VMA_MEMORY_USAGE_AUTO, name);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#define GLM_FORCE_RADIANS
|
||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
#define GLM_FORCE_QUATERNIONS_XYZW
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
|
||||
#define GLFW_INCLUDE_VULKAN
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstdio>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
using c8 = char;
|
||||
using u8 = uint8_t;
|
||||
|
|
@ -57,22 +58,26 @@ Recast(TFrom &&in)
|
|||
return reinterpret_cast<TType>(std::forward<TFrom>(in));
|
||||
}
|
||||
|
||||
constexpr f32 operator""_deg(long double degrees)
|
||||
constexpr f32
|
||||
operator""_deg(long double degrees)
|
||||
{
|
||||
return glm::radians<f32>(Cast<f32>(degrees));
|
||||
}
|
||||
|
||||
constexpr f32 operator""_deg(unsigned long long int degrees)
|
||||
constexpr f32
|
||||
operator""_deg(unsigned long long int degrees)
|
||||
{
|
||||
return glm::radians<f32>(Cast<f32>(degrees));
|
||||
}
|
||||
|
||||
constexpr f32 operator""_rad(long double rads)
|
||||
constexpr f32
|
||||
operator""_rad(long double rads)
|
||||
{
|
||||
return Cast<f32>(rads);
|
||||
}
|
||||
|
||||
constexpr f32 operator""_rad(unsigned long long int rads)
|
||||
constexpr f32
|
||||
operator""_rad(unsigned long long int rads)
|
||||
{
|
||||
return Cast<f32>(rads);
|
||||
}
|
||||
|
|
@ -110,6 +115,36 @@ constexpr Version VERSION = {
|
|||
.m_Patch = 0,
|
||||
};
|
||||
|
||||
constexpr u32
|
||||
Kilobyte(const u32 in)
|
||||
{
|
||||
return in * 1024;
|
||||
}
|
||||
|
||||
constexpr usize
|
||||
Kilobyte(const usize in)
|
||||
{
|
||||
return in * 1024;
|
||||
}
|
||||
|
||||
constexpr u32
|
||||
Megabyte(const u32 in)
|
||||
{
|
||||
return in * 1024 * 1024;
|
||||
}
|
||||
|
||||
constexpr usize
|
||||
Megabyte(const usize in)
|
||||
{
|
||||
return in * 1024 * 1024;
|
||||
}
|
||||
|
||||
constexpr usize
|
||||
Gigabyte(const usize in)
|
||||
{
|
||||
return in * 1024 * 1024 * 1024;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr T MaxValue = std::numeric_limits<T>::max();
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,14 @@ Device::DumpPipelineCache() const
|
|||
return pipelineCacheData;
|
||||
}
|
||||
|
||||
void
|
||||
Device::WaitIdle() const
|
||||
{
|
||||
auto deviceIdleResult = m_Device.waitIdle();
|
||||
ERROR_IF(Failed(deviceIdleResult), "Device Idling Failed. Cause: {}", deviceIdleResult)
|
||||
THEN_ABORT(deviceIdleResult);
|
||||
}
|
||||
|
||||
Device::Device(Device &&other) noexcept
|
||||
: m_Name(std::move(other.m_Name))
|
||||
, m_PhysicalDevice(Take(other.m_PhysicalDevice))
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ struct Device final
|
|||
|
||||
[[nodiscard]] eastl::vector<u8> DumpPipelineCache() const;
|
||||
|
||||
void WaitIdle() const;
|
||||
|
||||
// Ctor/Dtor
|
||||
Device(const Context *context, PhysicalDevice *physicalDevice, Features *enabledFeatures,
|
||||
const eastl::vector<QueueAllocation> &queueAllocations, NameString &&name);
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ add_library(util_helper STATIC
|
|||
helpers.cpp
|
||||
frame.cpp
|
||||
frame.h
|
||||
gpu_resource_manager.cpp
|
||||
gpu_resource_manager.h
|
||||
gui.cpp
|
||||
gui.h)
|
||||
|
||||
|
|
|
|||
|
|
@ -331,8 +331,7 @@ main(int, char **)
|
|||
frameIndex = (frameIndex + 1) % MAX_FRAMES_IN_FLIGHT;
|
||||
}
|
||||
|
||||
auto result = device.m_Device.waitIdle();
|
||||
ERROR_IF(Failed(result), "Wait idle failed. Cause: {}", result);
|
||||
device.WaitIdle();
|
||||
|
||||
device.m_Device.destroy(copyPool, nullptr);
|
||||
vbo.Destroy(&device);
|
||||
|
|
|
|||
|
|
@ -531,7 +531,7 @@ main(int, char **)
|
|||
currentFrame->Present(commandQueue, &swapchain, &window);
|
||||
}
|
||||
|
||||
AbortIfFailed(device.m_Device.waitIdle());
|
||||
device.WaitIdle();
|
||||
|
||||
for (auto &depthImage : depthImages)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ add_executable(model_render model_render.cpp
|
|||
asset_loader.h
|
||||
light_manager.cpp
|
||||
light_manager.h
|
||||
gpu_resource_manager.cpp
|
||||
gpu_resource_manager.h
|
||||
nodes.cpp
|
||||
nodes.h
|
||||
ibl_helpers.cpp
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ main(int, char **)
|
|||
{
|
||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
Context context = {"ModelRender [WIP]", VERSION};
|
||||
Window window = {"ModelRender [WIP] (Aster)", &context, {INIT_WIDTH, INIT_HEIGHT}};
|
||||
Context context = {"ModelRender", VERSION};
|
||||
Window window = {"ModelRender (Aster)", &context, {INIT_WIDTH, INIT_HEIGHT}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
|
@ -689,7 +689,7 @@ main(int, char **)
|
|||
currentFrame->Present(graphicsQueue, &swapchain, &window);
|
||||
}
|
||||
|
||||
AbortIfFailed(device.m_Device.waitIdle());
|
||||
device.WaitIdle();
|
||||
|
||||
environment.Destroy(&resourceManager);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue