Compare commits
10 Commits
fd5cdbf692
...
f3807f1557
| Author | SHA1 | Date | |
|---|---|---|---|
|
f3807f1557
|
|||
|
21cf49a1f9
|
|||
|
ba30cc49d5
|
|||
|
829a00bab8
|
|||
|
e7f2103fff
|
|||
|
db7d50c371
|
|||
|
04eec1b703
|
|||
|
d89f8de08f
|
|||
|
ccd5306636
|
|||
|
b25e5936e2
|
@@ -1,12 +1,12 @@
|
|||||||
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
# Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
|
||||||
|
|
||||||
project(nova)
|
project(nova)
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <nova/platform/window_driver.h>
|
#include <nova/platform/window_driver.h>
|
||||||
#include <nova/render/render_device.h>
|
#include <nova/render/render_device.h>
|
||||||
#include <nova/render/render_driver.h>
|
#include <nova/render/render_driver.h>
|
||||||
#include <nova/render/render_params.h>
|
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|||||||
@@ -23,11 +23,10 @@ set(ENGINE_SRC
|
|||||||
core/debug.cpp
|
core/debug.cpp
|
||||||
drivers/dx12/render_driver.cpp
|
drivers/dx12/render_driver.cpp
|
||||||
drivers/vulkan/render_driver.cpp
|
drivers/vulkan/render_driver.cpp
|
||||||
drivers/wayland/window_driver.cpp
|
platform/linux/wayland/window_driver.cpp
|
||||||
drivers/win32/window_driver.cpp
|
platform/linux/x11/window_driver.cpp
|
||||||
drivers/x11/window_driver.cpp
|
platform/windows/window_driver.cpp
|
||||||
platform/window_driver.cpp
|
platform/window_driver.cpp
|
||||||
render/renderer.cpp
|
|
||||||
render/render_device.cpp
|
render/render_device.cpp
|
||||||
render/render_driver.cpp
|
render/render_driver.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace Nova {
|
|||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|
||||||
#define NOVA_LOG(...) ::Nova::Debug::get_logger()->info(__VA_ARGS__)
|
#define NOVA_INFO(...) ::Nova::Debug::get_logger()->info(__VA_ARGS__)
|
||||||
#define NOVA_WARN(...) ::Nova::Debug::get_logger()->warn(__VA_ARGS__)
|
#define NOVA_WARN(...) ::Nova::Debug::get_logger()->warn(__VA_ARGS__)
|
||||||
#define NOVA_ERROR(...) ::Nova::Debug::get_logger()->error(__VA_ARGS__)
|
#define NOVA_ERROR(...) ::Nova::Debug::get_logger()->error(__VA_ARGS__)
|
||||||
#define NOVA_CRITICAL(...) ::Nova::Debug::get_logger()->critical(__VA_ARGS__)
|
#define NOVA_CRITICAL(...) ::Nova::Debug::get_logger()->critical(__VA_ARGS__)
|
||||||
|
|||||||
@@ -7,10 +7,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
enum class WindowAPI { WAYLAND, WINDOWS, X11 };
|
|
||||||
|
|
||||||
class WindowDriver;
|
|
||||||
|
|
||||||
struct Window;
|
struct Window;
|
||||||
using WindowID = Window*;
|
using WindowID = Window*;
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
@@ -7,33 +7,37 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nova/api.h>
|
#include <nova/api.h>
|
||||||
#include <nova/platform/window_fwd.h>
|
#include <nova/platform/platform_structs.h>
|
||||||
#include <nova/render/render_fwd.h>
|
#include <nova/render/render_structs.h>
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <string_view>
|
#include <string>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
|
class RenderDriver;
|
||||||
|
|
||||||
|
enum class WindowAPI { WAYLAND, WINDOWS, X11 };
|
||||||
|
|
||||||
class NOVA_API WindowDriver {
|
class NOVA_API WindowDriver {
|
||||||
public:
|
public:
|
||||||
static WindowDriver* create();
|
static WindowDriver* create();
|
||||||
virtual ~WindowDriver() = default;
|
virtual ~WindowDriver() = default;
|
||||||
|
|
||||||
[[nodiscard]] virtual WindowAPI get_api() const = 0;
|
virtual WindowAPI get_api() const = 0;
|
||||||
[[nodiscard]] virtual std::string get_api_name() const = 0;
|
virtual std::string get_api_name() const = 0;
|
||||||
|
|
||||||
virtual void poll_events() = 0;
|
virtual void poll_events() = 0;
|
||||||
virtual void beep() = 0;
|
virtual void beep() = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual u32 get_window_count() const = 0;
|
virtual u32 get_window_count() const = 0;
|
||||||
[[nodiscard]] virtual WindowID create_window(std::string_view title, u32 width, u32 height) = 0;
|
[[nodiscard]] virtual WindowID create_window(const std::string& title, u32 width, u32 height) = 0;
|
||||||
virtual void destroy_window(WindowID window) = 0;
|
virtual void destroy_window(WindowID window) = 0;
|
||||||
|
|
||||||
virtual void set_window_title(WindowID window, std::string_view title) = 0;
|
virtual void set_window_title(WindowID window, const std::string& title) = 0;
|
||||||
virtual void set_window_size(WindowID window, u32 width, u32 height) = 0;
|
virtual void set_window_size(WindowID window, u32 width, u32 height) = 0;
|
||||||
virtual void set_window_position(WindowID window, i32 x, i32 y) = 0;
|
virtual void set_window_position(WindowID window, i32 x, i32 y) = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual const char* get_surface_extension() const = 0;
|
virtual const char* get_surface_extension() const = 0;
|
||||||
[[nodiscard]] virtual SurfaceID create_surface(WindowID window, RenderDriver* driver) = 0;
|
[[nodiscard]] virtual SurfaceID create_surface(WindowID window, RenderDriver* driver) = 0;
|
||||||
};
|
};
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
|
|||||||
@@ -7,15 +7,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
enum class CullMode { NONE, FRONT, BACK };
|
|
||||||
enum class FrontFace { CLOCKWISE, COUNTER_CLOCKWISE };
|
|
||||||
enum class InputRate { VERTEX, INSTANCE };
|
|
||||||
enum class PipelineType { GRAPHICS, COMPUTE };
|
|
||||||
enum class PrimitiveTopology { POINT_LIST, LINE_LIST, LINE_STRIP, TRIANGLE_LIST, TRIANGLE_STRIP };
|
|
||||||
enum class QueueType { UNDEFINED, GRAPHICS, COMPUTE, TRANSFER };
|
|
||||||
enum class RenderAPI { DX12, VULKAN };
|
|
||||||
enum class ShaderStage { VERTEX, FRAGMENT, GEOMETRY, TESS_CONTROL, TESS_EVAL, COMPUTE, MESH, TASK };
|
|
||||||
|
|
||||||
enum class DataFormat {
|
enum class DataFormat {
|
||||||
UNDEFINED,
|
UNDEFINED,
|
||||||
R4G4_UNORM_PACK8,
|
R4G4_UNORM_PACK8,
|
||||||
@@ -237,31 +228,4 @@ namespace Nova {
|
|||||||
G16_B16R16_2PLANE_422_UNORM,
|
G16_B16R16_2PLANE_422_UNORM,
|
||||||
G16_B16_R16_3PLANE_444_UNORM,
|
G16_B16_R16_3PLANE_444_UNORM,
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderDriver;
|
|
||||||
struct RenderDevice;
|
|
||||||
|
|
||||||
struct VertexAttribute;
|
|
||||||
struct VertexBinding;
|
|
||||||
struct RenderPassParams;
|
|
||||||
struct GraphicsPipelineParams;
|
|
||||||
struct ComputePipelineParams;
|
|
||||||
|
|
||||||
struct CommandBuffer;
|
|
||||||
struct CommandPool;
|
|
||||||
struct Pipeline;
|
|
||||||
struct Queue;
|
|
||||||
struct RenderPass;
|
|
||||||
struct Shader;
|
|
||||||
struct Surface;
|
|
||||||
struct Swapchain;
|
|
||||||
|
|
||||||
using CommandBufferID = CommandBuffer*;
|
|
||||||
using CommandPoolID = CommandPool*;
|
|
||||||
using PipelineID = Pipeline*;
|
|
||||||
using QueueID = Queue*;
|
|
||||||
using RenderPassID = RenderPass*;
|
|
||||||
using ShaderID = Shader*;
|
|
||||||
using SurfaceID = Surface*;
|
|
||||||
using SwapchainID = Swapchain*;
|
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
13
engine/include/nova/render/params/compute_pipeline.h
Normal file
13
engine/include/nova/render/params/compute_pipeline.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct ComputePipelineParams {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
@@ -6,12 +6,18 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nova/render/render_fwd.h>
|
#include <nova/render/data_format.h>
|
||||||
|
#include <nova/render/render_structs.h>
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
|
enum class CullMode { NONE, FRONT, BACK };
|
||||||
|
enum class FrontFace { CLOCKWISE, COUNTER_CLOCKWISE };
|
||||||
|
enum class InputRate { VERTEX, INSTANCE };
|
||||||
|
enum class PrimitiveTopology { POINT_LIST, LINE_LIST, LINE_STRIP, TRIANGLE_LIST, TRIANGLE_STRIP };
|
||||||
|
|
||||||
struct VertexAttribute {
|
struct VertexAttribute {
|
||||||
u32 binding = 0;
|
u32 binding = 0;
|
||||||
u32 location = 0;
|
u32 location = 0;
|
||||||
@@ -25,8 +31,6 @@ namespace Nova {
|
|||||||
InputRate rate = InputRate::VERTEX;
|
InputRate rate = InputRate::VERTEX;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderPassParams {};
|
|
||||||
|
|
||||||
struct GraphicsPipelineParams {
|
struct GraphicsPipelineParams {
|
||||||
std::vector<ShaderID> shaders;
|
std::vector<ShaderID> shaders;
|
||||||
std::vector<VertexBinding> bindings;
|
std::vector<VertexBinding> bindings;
|
||||||
@@ -54,6 +58,4 @@ namespace Nova {
|
|||||||
RenderPassID render_pass = nullptr;
|
RenderPassID render_pass = nullptr;
|
||||||
u32 subpass = 0;
|
u32 subpass = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ComputePipelineParams {};
|
|
||||||
} // namespace Nova
|
} // namespace Nova
|
||||||
13
engine/include/nova/render/params/render_pass.h
Normal file
13
engine/include/nova/render/params/render_pass.h
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct RenderPassParams {
|
||||||
|
// TODO
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nova/api.h>
|
#include <nova/api.h>
|
||||||
#include <nova/render/render_fwd.h>
|
#include <nova/render/render_structs.h>
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
@@ -15,13 +15,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
struct NOVA_API RenderDevice {
|
class RenderDriver;
|
||||||
enum class Vendor { UNKNOWN = 0, INTEL = 0x8086, AMD = 0x1002, NVIDIA = 0x10de };
|
|
||||||
enum class Type { OTHER = 0, INTEGRATED = 1, DISCRETE = 2, VIRTUAL = 3, CPU = 4 };
|
|
||||||
|
|
||||||
|
enum class DeviceVendor { UNKNOWN = 0, INTEL = 0x8086, AMD = 0x1002, NVIDIA = 0x10de };
|
||||||
|
enum class DeviceType { OTHER = 0, INTEGRATED = 1, DISCRETE = 2, VIRTUAL = 3, CPU = 4 };
|
||||||
|
|
||||||
|
struct NOVA_API RenderDevice {
|
||||||
std::string name;
|
std::string name;
|
||||||
Vendor vendor;
|
DeviceVendor vendor;
|
||||||
Type type;
|
DeviceType type;
|
||||||
u32 deviceID;
|
u32 deviceID;
|
||||||
void* handle;
|
void* handle;
|
||||||
|
|
||||||
|
|||||||
@@ -7,30 +7,42 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nova/api.h>
|
#include <nova/api.h>
|
||||||
#include <nova/platform/window_fwd.h>
|
#include <nova/platform/platform_structs.h>
|
||||||
#include <nova/render/render_fwd.h>
|
#include <nova/render/params/compute_pipeline.h>
|
||||||
|
#include <nova/render/params/graphics_pipeline.h>
|
||||||
|
#include <nova/render/params/render_pass.h>
|
||||||
|
#include <nova/render/render_device.h>
|
||||||
|
#include <nova/render/render_structs.h>
|
||||||
#include <nova/types.h>
|
#include <nova/types.h>
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
|
class WindowDriver;
|
||||||
|
|
||||||
|
enum class PipelineType { GRAPHICS, COMPUTE };
|
||||||
|
enum class QueueType { UNDEFINED, GRAPHICS, COMPUTE, TRANSFER };
|
||||||
|
enum class RenderAPI { DX12, VULKAN };
|
||||||
|
enum class ShaderStage { VERTEX, FRAGMENT, GEOMETRY, TESS_CONTROL, TESS_EVAL, COMPUTE, MESH, TASK };
|
||||||
|
|
||||||
class NOVA_API RenderDriver {
|
class NOVA_API RenderDriver {
|
||||||
public:
|
public:
|
||||||
static RenderDriver* create(RenderAPI api, WindowDriver* window_driver = nullptr);
|
static RenderDriver* create(RenderAPI api, WindowDriver* window_driver = nullptr);
|
||||||
virtual ~RenderDriver() = default;
|
virtual ~RenderDriver() = default;
|
||||||
|
|
||||||
[[nodiscard]] virtual RenderAPI get_api() const = 0;
|
virtual RenderAPI get_api() const = 0;
|
||||||
[[nodiscard]] virtual u32 get_api_version() const = 0;
|
virtual u32 get_api_version() const = 0;
|
||||||
[[nodiscard]] virtual std::string get_api_name() const = 0;
|
virtual std::string get_api_name() const = 0;
|
||||||
[[nodiscard]] virtual std::string get_api_version_string() const = 0;
|
virtual std::string get_api_version_string() const = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual u32 get_device_count() const = 0;
|
virtual u32 get_device_count() const = 0;
|
||||||
[[nodiscard]] virtual const RenderDevice& get_device(u32 index) const = 0;
|
virtual const RenderDevice& get_device(u32 index) const = 0;
|
||||||
[[nodiscard]] virtual bool get_device_supports_surface(u32 index, SurfaceID surface) const = 0;
|
virtual bool get_device_supports_surface(u32 index, SurfaceID surface) const = 0;
|
||||||
virtual void select_device(u32 index) = 0;
|
virtual void select_device(u32 index) = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual u32 choose_queue_family(QueueType type, SurfaceID surface) = 0;
|
virtual u32 choose_queue_family(QueueType type, SurfaceID surface) = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual QueueID get_queue(u32 queue_family) = 0;
|
[[nodiscard]] virtual QueueID get_queue(u32 queue_family) = 0;
|
||||||
virtual void free_queue(QueueID queue) = 0;
|
virtual void free_queue(QueueID queue) = 0;
|
||||||
|
|
||||||
@@ -39,7 +51,7 @@ namespace Nova {
|
|||||||
|
|
||||||
[[nodiscard]] virtual SwapchainID create_swapchain(SurfaceID surface) = 0;
|
[[nodiscard]] virtual SwapchainID create_swapchain(SurfaceID surface) = 0;
|
||||||
virtual void resize_swapchain(SwapchainID swapchain) = 0;
|
virtual void resize_swapchain(SwapchainID swapchain) = 0;
|
||||||
[[nodiscard]] virtual RenderPassID get_swapchain_render_pass(SwapchainID swapchain) const = 0;
|
virtual RenderPassID get_swapchain_render_pass(SwapchainID swapchain) const = 0;
|
||||||
virtual void destroy_swapchain(SwapchainID swapchain) = 0;
|
virtual void destroy_swapchain(SwapchainID swapchain) = 0;
|
||||||
|
|
||||||
[[nodiscard]] virtual ShaderID create_shader(const std::span<u8> bytes, ShaderStage stage) = 0;
|
[[nodiscard]] virtual ShaderID create_shader(const std::span<u8> bytes, ShaderStage stage) = 0;
|
||||||
|
|||||||
27
engine/include/nova/render/render_structs.h
Normal file
27
engine/include/nova/render/render_structs.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct CommandBuffer;
|
||||||
|
struct CommandPool;
|
||||||
|
struct Pipeline;
|
||||||
|
struct Queue;
|
||||||
|
struct RenderPass;
|
||||||
|
struct Shader;
|
||||||
|
struct Surface;
|
||||||
|
struct Swapchain;
|
||||||
|
|
||||||
|
using CommandBufferID = CommandBuffer*;
|
||||||
|
using CommandPoolID = CommandPool*;
|
||||||
|
using PipelineID = Pipeline*;
|
||||||
|
using QueueID = Queue*;
|
||||||
|
using RenderPassID = RenderPass*;
|
||||||
|
using ShaderID = Shader*;
|
||||||
|
using SurfaceID = Surface*;
|
||||||
|
using SwapchainID = Swapchain*;
|
||||||
|
} // namespace Nova
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <nova/api.h>
|
|
||||||
#include <nova/render/render_fwd.h>
|
|
||||||
|
|
||||||
namespace Nova {
|
|
||||||
class NOVA_API Renderer {
|
|
||||||
public:
|
|
||||||
static void init(RenderAPI api);
|
|
||||||
static void shutdown();
|
|
||||||
static RenderDriver* get_driver();
|
|
||||||
};
|
|
||||||
} // namespace Nova
|
|
||||||
@@ -8,10 +8,11 @@
|
|||||||
|
|
||||||
#include "drivers/vulkan/render_driver.h"
|
#include "drivers/vulkan/render_driver.h"
|
||||||
|
|
||||||
|
#include "drivers/vulkan/render_structs.h"
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
#include <nova/platform/window_driver.h>
|
#include <nova/platform/window_driver.h>
|
||||||
#include <nova/render/render_device.h>
|
#include <nova/render/render_device.h>
|
||||||
#include <nova/render/render_params.h>
|
|
||||||
#include <nova/version.h>
|
#include <nova/version.h>
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
@@ -19,280 +20,279 @@
|
|||||||
#include <bit>
|
#include <bit>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
#define VALIDATION_LAYER "VK_LAYER_KHRONOS_validation"
|
namespace {
|
||||||
#define MAX_QUEUES_PER_FAMILY 2U
|
static constexpr u32 MAX_QUEUES_PER_FAMILY = 2;
|
||||||
|
static constexpr std::string_view VALIDATION_LAYER = "VK_LAYER_KHRONOS_validation";
|
||||||
|
|
||||||
|
static constexpr VkShaderStageFlagBits VK_SHADER_STAGE_MAP[] = {
|
||||||
|
VK_SHADER_STAGE_VERTEX_BIT,
|
||||||
|
VK_SHADER_STAGE_FRAGMENT_BIT,
|
||||||
|
VK_SHADER_STAGE_GEOMETRY_BIT,
|
||||||
|
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
|
||||||
|
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
||||||
|
VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
VK_SHADER_STAGE_MESH_BIT_EXT,
|
||||||
|
VK_SHADER_STAGE_TASK_BIT_EXT
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkPrimitiveTopology VK_PRIMITIVE_TOPOLOGY_MAP[] = {
|
||||||
|
VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
|
||||||
|
VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
|
||||||
|
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP,
|
||||||
|
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
||||||
|
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkCullModeFlags VK_CULL_MODE_MAP[] = {
|
||||||
|
VK_CULL_MODE_NONE,
|
||||||
|
VK_CULL_MODE_FRONT_BIT,
|
||||||
|
VK_CULL_MODE_BACK_BIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkFrontFace VK_FRONT_FACE_MAP[] = {
|
||||||
|
VK_FRONT_FACE_COUNTER_CLOCKWISE,
|
||||||
|
VK_FRONT_FACE_CLOCKWISE,
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkVertexInputRate VK_VERTEX_INPUT_RATE_MAP[] = {
|
||||||
|
VK_VERTEX_INPUT_RATE_VERTEX,
|
||||||
|
VK_VERTEX_INPUT_RATE_INSTANCE,
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkQueueFlagBits VK_QUEUE_FLAGS_MAP[] = {
|
||||||
|
static_cast<VkQueueFlagBits>(0),
|
||||||
|
VK_QUEUE_GRAPHICS_BIT,
|
||||||
|
VK_QUEUE_COMPUTE_BIT,
|
||||||
|
VK_QUEUE_TRANSFER_BIT,
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr VkFormat VK_FORMAT_MAP[] = {
|
||||||
|
VK_FORMAT_UNDEFINED,
|
||||||
|
VK_FORMAT_R4G4_UNORM_PACK8,
|
||||||
|
VK_FORMAT_R4G4B4A4_UNORM_PACK16,
|
||||||
|
VK_FORMAT_B4G4R4A4_UNORM_PACK16,
|
||||||
|
VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||||
|
VK_FORMAT_B5G6R5_UNORM_PACK16,
|
||||||
|
VK_FORMAT_R5G5B5A1_UNORM_PACK16,
|
||||||
|
VK_FORMAT_B5G5R5A1_UNORM_PACK16,
|
||||||
|
VK_FORMAT_A1R5G5B5_UNORM_PACK16,
|
||||||
|
VK_FORMAT_R8_UNORM,
|
||||||
|
VK_FORMAT_R8_SNORM,
|
||||||
|
VK_FORMAT_R8_USCALED,
|
||||||
|
VK_FORMAT_R8_SSCALED,
|
||||||
|
VK_FORMAT_R8_UINT,
|
||||||
|
VK_FORMAT_R8_SINT,
|
||||||
|
VK_FORMAT_R8_SRGB,
|
||||||
|
VK_FORMAT_R8G8_UNORM,
|
||||||
|
VK_FORMAT_R8G8_SNORM,
|
||||||
|
VK_FORMAT_R8G8_USCALED,
|
||||||
|
VK_FORMAT_R8G8_SSCALED,
|
||||||
|
VK_FORMAT_R8G8_UINT,
|
||||||
|
VK_FORMAT_R8G8_SINT,
|
||||||
|
VK_FORMAT_R8G8_SRGB,
|
||||||
|
VK_FORMAT_R8G8B8_UNORM,
|
||||||
|
VK_FORMAT_R8G8B8_SNORM,
|
||||||
|
VK_FORMAT_R8G8B8_USCALED,
|
||||||
|
VK_FORMAT_R8G8B8_SSCALED,
|
||||||
|
VK_FORMAT_R8G8B8_UINT,
|
||||||
|
VK_FORMAT_R8G8B8_SINT,
|
||||||
|
VK_FORMAT_R8G8B8_SRGB,
|
||||||
|
VK_FORMAT_B8G8R8_UNORM,
|
||||||
|
VK_FORMAT_B8G8R8_SNORM,
|
||||||
|
VK_FORMAT_B8G8R8_USCALED,
|
||||||
|
VK_FORMAT_B8G8R8_SSCALED,
|
||||||
|
VK_FORMAT_B8G8R8_UINT,
|
||||||
|
VK_FORMAT_B8G8R8_SINT,
|
||||||
|
VK_FORMAT_B8G8R8_SRGB,
|
||||||
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
VK_FORMAT_R8G8B8A8_SNORM,
|
||||||
|
VK_FORMAT_R8G8B8A8_USCALED,
|
||||||
|
VK_FORMAT_R8G8B8A8_SSCALED,
|
||||||
|
VK_FORMAT_R8G8B8A8_UINT,
|
||||||
|
VK_FORMAT_R8G8B8A8_SINT,
|
||||||
|
VK_FORMAT_R8G8B8A8_SRGB,
|
||||||
|
VK_FORMAT_B8G8R8A8_UNORM,
|
||||||
|
VK_FORMAT_B8G8R8A8_SNORM,
|
||||||
|
VK_FORMAT_B8G8R8A8_USCALED,
|
||||||
|
VK_FORMAT_B8G8R8A8_SSCALED,
|
||||||
|
VK_FORMAT_B8G8R8A8_UINT,
|
||||||
|
VK_FORMAT_B8G8R8A8_SINT,
|
||||||
|
VK_FORMAT_B8G8R8A8_SRGB,
|
||||||
|
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_USCALED_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_UINT_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_SINT_PACK32,
|
||||||
|
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_UNORM_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_SNORM_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_USCALED_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_UINT_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_SINT_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_SNORM_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_USCALED_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||||
|
VK_FORMAT_A2B10G10R10_SINT_PACK32,
|
||||||
|
VK_FORMAT_R16_UNORM,
|
||||||
|
VK_FORMAT_R16_SNORM,
|
||||||
|
VK_FORMAT_R16_USCALED,
|
||||||
|
VK_FORMAT_R16_SSCALED,
|
||||||
|
VK_FORMAT_R16_UINT,
|
||||||
|
VK_FORMAT_R16_SINT,
|
||||||
|
VK_FORMAT_R16_SFLOAT,
|
||||||
|
VK_FORMAT_R16G16_UNORM,
|
||||||
|
VK_FORMAT_R16G16_SNORM,
|
||||||
|
VK_FORMAT_R16G16_USCALED,
|
||||||
|
VK_FORMAT_R16G16_SSCALED,
|
||||||
|
VK_FORMAT_R16G16_UINT,
|
||||||
|
VK_FORMAT_R16G16_SINT,
|
||||||
|
VK_FORMAT_R16G16_SFLOAT,
|
||||||
|
VK_FORMAT_R16G16B16_UNORM,
|
||||||
|
VK_FORMAT_R16G16B16_SNORM,
|
||||||
|
VK_FORMAT_R16G16B16_USCALED,
|
||||||
|
VK_FORMAT_R16G16B16_SSCALED,
|
||||||
|
VK_FORMAT_R16G16B16_UINT,
|
||||||
|
VK_FORMAT_R16G16B16_SINT,
|
||||||
|
VK_FORMAT_R16G16B16_SFLOAT,
|
||||||
|
VK_FORMAT_R16G16B16A16_UNORM,
|
||||||
|
VK_FORMAT_R16G16B16A16_SNORM,
|
||||||
|
VK_FORMAT_R16G16B16A16_USCALED,
|
||||||
|
VK_FORMAT_R16G16B16A16_SSCALED,
|
||||||
|
VK_FORMAT_R16G16B16A16_UINT,
|
||||||
|
VK_FORMAT_R16G16B16A16_SINT,
|
||||||
|
VK_FORMAT_R16G16B16A16_SFLOAT,
|
||||||
|
VK_FORMAT_R32_UINT,
|
||||||
|
VK_FORMAT_R32_SINT,
|
||||||
|
VK_FORMAT_R32_SFLOAT,
|
||||||
|
VK_FORMAT_R32G32_UINT,
|
||||||
|
VK_FORMAT_R32G32_SINT,
|
||||||
|
VK_FORMAT_R32G32_SFLOAT,
|
||||||
|
VK_FORMAT_R32G32B32_UINT,
|
||||||
|
VK_FORMAT_R32G32B32_SINT,
|
||||||
|
VK_FORMAT_R32G32B32_SFLOAT,
|
||||||
|
VK_FORMAT_R32G32B32A32_UINT,
|
||||||
|
VK_FORMAT_R32G32B32A32_SINT,
|
||||||
|
VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
|
VK_FORMAT_R64_UINT,
|
||||||
|
VK_FORMAT_R64_SINT,
|
||||||
|
VK_FORMAT_R64_SFLOAT,
|
||||||
|
VK_FORMAT_R64G64_UINT,
|
||||||
|
VK_FORMAT_R64G64_SINT,
|
||||||
|
VK_FORMAT_R64G64_SFLOAT,
|
||||||
|
VK_FORMAT_R64G64B64_UINT,
|
||||||
|
VK_FORMAT_R64G64B64_SINT,
|
||||||
|
VK_FORMAT_R64G64B64_SFLOAT,
|
||||||
|
VK_FORMAT_R64G64B64A64_UINT,
|
||||||
|
VK_FORMAT_R64G64B64A64_SINT,
|
||||||
|
VK_FORMAT_R64G64B64A64_SFLOAT,
|
||||||
|
VK_FORMAT_B10G11R11_UFLOAT_PACK32,
|
||||||
|
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
|
||||||
|
VK_FORMAT_D16_UNORM,
|
||||||
|
VK_FORMAT_X8_D24_UNORM_PACK32,
|
||||||
|
VK_FORMAT_D32_SFLOAT,
|
||||||
|
VK_FORMAT_S8_UINT,
|
||||||
|
VK_FORMAT_D16_UNORM_S8_UINT,
|
||||||
|
VK_FORMAT_D24_UNORM_S8_UINT,
|
||||||
|
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
||||||
|
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC1_RGB_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_BC2_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC2_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC3_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_BC4_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC4_SNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC5_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC5_SNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC6H_UFLOAT_BLOCK,
|
||||||
|
VK_FORMAT_BC6H_SFLOAT_BLOCK,
|
||||||
|
VK_FORMAT_BC7_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_BC7_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_EAC_R11_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_EAC_R11_SNORM_BLOCK,
|
||||||
|
VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
|
||||||
|
VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
|
||||||
|
VK_FORMAT_G8B8G8R8_422_UNORM,
|
||||||
|
VK_FORMAT_B8G8R8G8_422_UNORM,
|
||||||
|
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
|
||||||
|
VK_FORMAT_G8_B8R8_2PLANE_420_UNORM,
|
||||||
|
VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM,
|
||||||
|
VK_FORMAT_G8_B8R8_2PLANE_422_UNORM,
|
||||||
|
VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM,
|
||||||
|
VK_FORMAT_R10X6_UNORM_PACK16,
|
||||||
|
VK_FORMAT_R10X6G10X6_UNORM_2PACK16,
|
||||||
|
VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_R12X4_UNORM_PACK16,
|
||||||
|
VK_FORMAT_R12X4G12X4_UNORM_2PACK16,
|
||||||
|
VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,
|
||||||
|
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16,
|
||||||
|
VK_FORMAT_G16B16G16R16_422_UNORM,
|
||||||
|
VK_FORMAT_B16G16R16G16_422_UNORM,
|
||||||
|
VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM,
|
||||||
|
VK_FORMAT_G16_B16R16_2PLANE_420_UNORM,
|
||||||
|
VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM,
|
||||||
|
VK_FORMAT_G16_B16R16_2PLANE_422_UNORM,
|
||||||
|
VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM
|
||||||
|
};
|
||||||
|
} // namespace
|
||||||
|
|
||||||
using namespace Nova;
|
using namespace Nova;
|
||||||
|
|
||||||
static constexpr VkShaderStageFlagBits VK_SHADER_STAGE_MAP[] = {
|
|
||||||
VK_SHADER_STAGE_VERTEX_BIT,
|
|
||||||
VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
||||||
VK_SHADER_STAGE_GEOMETRY_BIT,
|
|
||||||
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT,
|
|
||||||
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT,
|
|
||||||
VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
VK_SHADER_STAGE_MESH_BIT_EXT,
|
|
||||||
VK_SHADER_STAGE_TASK_BIT_EXT
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr VkPrimitiveTopology VK_PRIMITIVE_TOPOLOGY_MAP[] = {
|
|
||||||
VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
|
|
||||||
VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
|
|
||||||
VK_PRIMITIVE_TOPOLOGY_LINE_STRIP,
|
|
||||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
|
|
||||||
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
|
|
||||||
};
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
|
|
||||||
static constexpr VkCullModeFlags VK_CULL_MODE_MAP[] = {
|
|
||||||
VK_CULL_MODE_NONE,
|
|
||||||
VK_CULL_MODE_FRONT_BIT,
|
|
||||||
VK_CULL_MODE_BACK_BIT
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr VkFrontFace VK_FRONT_FACE_MAP[] = {
|
|
||||||
VK_FRONT_FACE_COUNTER_CLOCKWISE,
|
|
||||||
VK_FRONT_FACE_CLOCKWISE
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr VkVertexInputRate VK_VERTEX_INPUT_RATE_MAP[] = {
|
|
||||||
VK_VERTEX_INPUT_RATE_VERTEX,
|
|
||||||
VK_VERTEX_INPUT_RATE_INSTANCE
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr VkQueueFlagBits VK_QUEUE_FLAGS_MAP[] = {
|
|
||||||
static_cast<VkQueueFlagBits>(0),
|
|
||||||
VK_QUEUE_GRAPHICS_BIT,
|
|
||||||
VK_QUEUE_COMPUTE_BIT,
|
|
||||||
VK_QUEUE_TRANSFER_BIT
|
|
||||||
};
|
|
||||||
|
|
||||||
// clang-format on
|
|
||||||
|
|
||||||
static constexpr VkFormat VK_FORMAT_MAP[] = {
|
|
||||||
VK_FORMAT_UNDEFINED,
|
|
||||||
VK_FORMAT_R4G4_UNORM_PACK8,
|
|
||||||
VK_FORMAT_R4G4B4A4_UNORM_PACK16,
|
|
||||||
VK_FORMAT_B4G4R4A4_UNORM_PACK16,
|
|
||||||
VK_FORMAT_R5G6B5_UNORM_PACK16,
|
|
||||||
VK_FORMAT_B5G6R5_UNORM_PACK16,
|
|
||||||
VK_FORMAT_R5G5B5A1_UNORM_PACK16,
|
|
||||||
VK_FORMAT_B5G5R5A1_UNORM_PACK16,
|
|
||||||
VK_FORMAT_A1R5G5B5_UNORM_PACK16,
|
|
||||||
VK_FORMAT_R8_UNORM,
|
|
||||||
VK_FORMAT_R8_SNORM,
|
|
||||||
VK_FORMAT_R8_USCALED,
|
|
||||||
VK_FORMAT_R8_SSCALED,
|
|
||||||
VK_FORMAT_R8_UINT,
|
|
||||||
VK_FORMAT_R8_SINT,
|
|
||||||
VK_FORMAT_R8_SRGB,
|
|
||||||
VK_FORMAT_R8G8_UNORM,
|
|
||||||
VK_FORMAT_R8G8_SNORM,
|
|
||||||
VK_FORMAT_R8G8_USCALED,
|
|
||||||
VK_FORMAT_R8G8_SSCALED,
|
|
||||||
VK_FORMAT_R8G8_UINT,
|
|
||||||
VK_FORMAT_R8G8_SINT,
|
|
||||||
VK_FORMAT_R8G8_SRGB,
|
|
||||||
VK_FORMAT_R8G8B8_UNORM,
|
|
||||||
VK_FORMAT_R8G8B8_SNORM,
|
|
||||||
VK_FORMAT_R8G8B8_USCALED,
|
|
||||||
VK_FORMAT_R8G8B8_SSCALED,
|
|
||||||
VK_FORMAT_R8G8B8_UINT,
|
|
||||||
VK_FORMAT_R8G8B8_SINT,
|
|
||||||
VK_FORMAT_R8G8B8_SRGB,
|
|
||||||
VK_FORMAT_B8G8R8_UNORM,
|
|
||||||
VK_FORMAT_B8G8R8_SNORM,
|
|
||||||
VK_FORMAT_B8G8R8_USCALED,
|
|
||||||
VK_FORMAT_B8G8R8_SSCALED,
|
|
||||||
VK_FORMAT_B8G8R8_UINT,
|
|
||||||
VK_FORMAT_B8G8R8_SINT,
|
|
||||||
VK_FORMAT_B8G8R8_SRGB,
|
|
||||||
VK_FORMAT_R8G8B8A8_UNORM,
|
|
||||||
VK_FORMAT_R8G8B8A8_SNORM,
|
|
||||||
VK_FORMAT_R8G8B8A8_USCALED,
|
|
||||||
VK_FORMAT_R8G8B8A8_SSCALED,
|
|
||||||
VK_FORMAT_R8G8B8A8_UINT,
|
|
||||||
VK_FORMAT_R8G8B8A8_SINT,
|
|
||||||
VK_FORMAT_R8G8B8A8_SRGB,
|
|
||||||
VK_FORMAT_B8G8R8A8_UNORM,
|
|
||||||
VK_FORMAT_B8G8R8A8_SNORM,
|
|
||||||
VK_FORMAT_B8G8R8A8_USCALED,
|
|
||||||
VK_FORMAT_B8G8R8A8_SSCALED,
|
|
||||||
VK_FORMAT_B8G8R8A8_UINT,
|
|
||||||
VK_FORMAT_B8G8R8A8_SINT,
|
|
||||||
VK_FORMAT_B8G8R8A8_SRGB,
|
|
||||||
VK_FORMAT_A8B8G8R8_UNORM_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_USCALED_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_SSCALED_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_UINT_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_SINT_PACK32,
|
|
||||||
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_UNORM_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_SNORM_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_USCALED_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_SSCALED_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_UINT_PACK32,
|
|
||||||
VK_FORMAT_A2R10G10B10_SINT_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_SNORM_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_USCALED_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_SSCALED_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
|
||||||
VK_FORMAT_A2B10G10R10_SINT_PACK32,
|
|
||||||
VK_FORMAT_R16_UNORM,
|
|
||||||
VK_FORMAT_R16_SNORM,
|
|
||||||
VK_FORMAT_R16_USCALED,
|
|
||||||
VK_FORMAT_R16_SSCALED,
|
|
||||||
VK_FORMAT_R16_UINT,
|
|
||||||
VK_FORMAT_R16_SINT,
|
|
||||||
VK_FORMAT_R16_SFLOAT,
|
|
||||||
VK_FORMAT_R16G16_UNORM,
|
|
||||||
VK_FORMAT_R16G16_SNORM,
|
|
||||||
VK_FORMAT_R16G16_USCALED,
|
|
||||||
VK_FORMAT_R16G16_SSCALED,
|
|
||||||
VK_FORMAT_R16G16_UINT,
|
|
||||||
VK_FORMAT_R16G16_SINT,
|
|
||||||
VK_FORMAT_R16G16_SFLOAT,
|
|
||||||
VK_FORMAT_R16G16B16_UNORM,
|
|
||||||
VK_FORMAT_R16G16B16_SNORM,
|
|
||||||
VK_FORMAT_R16G16B16_USCALED,
|
|
||||||
VK_FORMAT_R16G16B16_SSCALED,
|
|
||||||
VK_FORMAT_R16G16B16_UINT,
|
|
||||||
VK_FORMAT_R16G16B16_SINT,
|
|
||||||
VK_FORMAT_R16G16B16_SFLOAT,
|
|
||||||
VK_FORMAT_R16G16B16A16_UNORM,
|
|
||||||
VK_FORMAT_R16G16B16A16_SNORM,
|
|
||||||
VK_FORMAT_R16G16B16A16_USCALED,
|
|
||||||
VK_FORMAT_R16G16B16A16_SSCALED,
|
|
||||||
VK_FORMAT_R16G16B16A16_UINT,
|
|
||||||
VK_FORMAT_R16G16B16A16_SINT,
|
|
||||||
VK_FORMAT_R16G16B16A16_SFLOAT,
|
|
||||||
VK_FORMAT_R32_UINT,
|
|
||||||
VK_FORMAT_R32_SINT,
|
|
||||||
VK_FORMAT_R32_SFLOAT,
|
|
||||||
VK_FORMAT_R32G32_UINT,
|
|
||||||
VK_FORMAT_R32G32_SINT,
|
|
||||||
VK_FORMAT_R32G32_SFLOAT,
|
|
||||||
VK_FORMAT_R32G32B32_UINT,
|
|
||||||
VK_FORMAT_R32G32B32_SINT,
|
|
||||||
VK_FORMAT_R32G32B32_SFLOAT,
|
|
||||||
VK_FORMAT_R32G32B32A32_UINT,
|
|
||||||
VK_FORMAT_R32G32B32A32_SINT,
|
|
||||||
VK_FORMAT_R32G32B32A32_SFLOAT,
|
|
||||||
VK_FORMAT_R64_UINT,
|
|
||||||
VK_FORMAT_R64_SINT,
|
|
||||||
VK_FORMAT_R64_SFLOAT,
|
|
||||||
VK_FORMAT_R64G64_UINT,
|
|
||||||
VK_FORMAT_R64G64_SINT,
|
|
||||||
VK_FORMAT_R64G64_SFLOAT,
|
|
||||||
VK_FORMAT_R64G64B64_UINT,
|
|
||||||
VK_FORMAT_R64G64B64_SINT,
|
|
||||||
VK_FORMAT_R64G64B64_SFLOAT,
|
|
||||||
VK_FORMAT_R64G64B64A64_UINT,
|
|
||||||
VK_FORMAT_R64G64B64A64_SINT,
|
|
||||||
VK_FORMAT_R64G64B64A64_SFLOAT,
|
|
||||||
VK_FORMAT_B10G11R11_UFLOAT_PACK32,
|
|
||||||
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,
|
|
||||||
VK_FORMAT_D16_UNORM,
|
|
||||||
VK_FORMAT_X8_D24_UNORM_PACK32,
|
|
||||||
VK_FORMAT_D32_SFLOAT,
|
|
||||||
VK_FORMAT_S8_UINT,
|
|
||||||
VK_FORMAT_D16_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D24_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
|
||||||
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC1_RGB_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_BC2_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC2_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC3_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_BC4_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC4_SNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC5_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC5_SNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC6H_UFLOAT_BLOCK,
|
|
||||||
VK_FORMAT_BC6H_SFLOAT_BLOCK,
|
|
||||||
VK_FORMAT_BC7_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_BC7_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_EAC_R11_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_EAC_R11_SNORM_BLOCK,
|
|
||||||
VK_FORMAT_EAC_R11G11_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_EAC_R11G11_SNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_4x4_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_4x4_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_5x4_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_5x4_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_5x5_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_5x5_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_6x5_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_6x5_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_6x6_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_6x6_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x5_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x5_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x6_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x6_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x8_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_8x8_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x5_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x5_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x6_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x6_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x8_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x8_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x10_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_10x10_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_12x10_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
|
|
||||||
VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
|
|
||||||
VK_FORMAT_G8B8G8R8_422_UNORM,
|
|
||||||
VK_FORMAT_B8G8R8G8_422_UNORM,
|
|
||||||
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
|
|
||||||
VK_FORMAT_G8_B8R8_2PLANE_420_UNORM,
|
|
||||||
VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM,
|
|
||||||
VK_FORMAT_G8_B8R8_2PLANE_422_UNORM,
|
|
||||||
VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM,
|
|
||||||
VK_FORMAT_R10X6_UNORM_PACK16,
|
|
||||||
VK_FORMAT_R10X6G10X6_UNORM_2PACK16,
|
|
||||||
VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_R12X4_UNORM_PACK16,
|
|
||||||
VK_FORMAT_R12X4G12X4_UNORM_2PACK16,
|
|
||||||
VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,
|
|
||||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16,
|
|
||||||
VK_FORMAT_G16B16G16R16_422_UNORM,
|
|
||||||
VK_FORMAT_B16G16R16G16_422_UNORM,
|
|
||||||
VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM,
|
|
||||||
VK_FORMAT_G16_B16R16_2PLANE_420_UNORM,
|
|
||||||
VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM,
|
|
||||||
VK_FORMAT_G16_B16R16_2PLANE_422_UNORM,
|
|
||||||
VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM
|
|
||||||
};
|
|
||||||
|
|
||||||
VulkanRenderDriver::VulkanRenderDriver(WindowDriver* p_driver) : m_window_driver(p_driver) {
|
VulkanRenderDriver::VulkanRenderDriver(WindowDriver* p_driver) : m_window_driver(p_driver) {
|
||||||
NOVA_AUTO_TRACE();
|
NOVA_AUTO_TRACE();
|
||||||
_check_version();
|
_check_version();
|
||||||
@@ -375,7 +375,7 @@ void VulkanRenderDriver::select_device(const u32 p_index) {
|
|||||||
NOVA_ASSERT(!m_device);
|
NOVA_ASSERT(!m_device);
|
||||||
NOVA_ASSERT(p_index < m_devices.size());
|
NOVA_ASSERT(p_index < m_devices.size());
|
||||||
|
|
||||||
NOVA_LOG("Using device: {}", m_devices[p_index].name);
|
NOVA_INFO("Using device: {}", m_devices[p_index].name);
|
||||||
m_physical_device = static_cast<VkPhysicalDevice>(m_devices[p_index].handle);
|
m_physical_device = static_cast<VkPhysicalDevice>(m_devices[p_index].handle);
|
||||||
|
|
||||||
_check_device_extensions();
|
_check_device_extensions();
|
||||||
@@ -982,7 +982,7 @@ void VulkanRenderDriver::_check_version() const {
|
|||||||
throw std::runtime_error("Vulkan API version is too low");
|
throw std::runtime_error("Vulkan API version is too low");
|
||||||
}
|
}
|
||||||
|
|
||||||
NOVA_LOG(
|
NOVA_INFO(
|
||||||
"Vulkan API version: {}.{}.{}-{}",
|
"Vulkan API version: {}.{}.{}-{}",
|
||||||
VK_API_VERSION_MAJOR(version),
|
VK_API_VERSION_MAJOR(version),
|
||||||
VK_API_VERSION_MINOR(version),
|
VK_API_VERSION_MINOR(version),
|
||||||
@@ -1019,7 +1019,7 @@ void VulkanRenderDriver::_check_extensions() {
|
|||||||
// Check found extensions
|
// Check found extensions
|
||||||
for (const auto& extension : available) {
|
for (const auto& extension : available) {
|
||||||
if (auto it = requested.find(extension.extensionName); it != requested.end()) {
|
if (auto it = requested.find(extension.extensionName); it != requested.end()) {
|
||||||
NOVA_LOG("Using extension: {}", extension.extensionName);
|
NOVA_INFO("Using extension: {}", extension.extensionName);
|
||||||
m_extensions.push_back(it->first.data());
|
m_extensions.push_back(it->first.data());
|
||||||
requested.erase(it);
|
requested.erase(it);
|
||||||
}
|
}
|
||||||
@@ -1057,8 +1057,8 @@ void VulkanRenderDriver::_check_layers() {
|
|||||||
// Check found layers
|
// Check found layers
|
||||||
for (const auto& layer : available) {
|
for (const auto& layer : available) {
|
||||||
if (std::string_view(layer.layerName) == VALIDATION_LAYER) {
|
if (std::string_view(layer.layerName) == VALIDATION_LAYER) {
|
||||||
NOVA_LOG("Using layer: {}", layer.layerName);
|
NOVA_INFO("Using layer: {}", layer.layerName);
|
||||||
m_layers.push_back(VALIDATION_LAYER);
|
m_layers.push_back(VALIDATION_LAYER.data());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1104,14 +1104,15 @@ void VulkanRenderDriver::_init_hardware() {
|
|||||||
VkPhysicalDeviceProperties properties;
|
VkPhysicalDeviceProperties properties;
|
||||||
vkGetPhysicalDeviceProperties(device, &properties);
|
vkGetPhysicalDeviceProperties(device, &properties);
|
||||||
|
|
||||||
m_devices.emplace_back();
|
m_devices.emplace_back<RenderDevice>({
|
||||||
m_devices.back().name = properties.deviceName;
|
.name = properties.deviceName,
|
||||||
m_devices.back().vendor = static_cast<RenderDevice::Vendor>(properties.vendorID);
|
.vendor = static_cast<DeviceVendor>(properties.vendorID),
|
||||||
m_devices.back().type = static_cast<RenderDevice::Type>(properties.deviceType);
|
.type = static_cast<DeviceType>(properties.deviceType),
|
||||||
m_devices.back().deviceID = properties.deviceID;
|
.deviceID = properties.deviceID,
|
||||||
m_devices.back().handle = device;
|
.handle = device,
|
||||||
|
});
|
||||||
|
|
||||||
NOVA_LOG("Found device: {}", properties.deviceName);
|
NOVA_INFO("Found device: {}", properties.deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_devices.empty()) {
|
if (m_devices.empty()) {
|
||||||
@@ -1135,7 +1136,7 @@ void VulkanRenderDriver::_check_device_extensions() {
|
|||||||
// Check found extensions
|
// Check found extensions
|
||||||
for (const auto& extension : available) {
|
for (const auto& extension : available) {
|
||||||
if (auto it = requested.find(extension.extensionName); it != requested.end()) {
|
if (auto it = requested.find(extension.extensionName); it != requested.end()) {
|
||||||
NOVA_LOG("Using device extension: {}", extension.extensionName);
|
NOVA_INFO("Using device extension: {}", extension.extensionName);
|
||||||
m_device_extensions.push_back(it->first.data());
|
m_device_extensions.push_back(it->first.data());
|
||||||
requested.erase(it);
|
requested.erase(it);
|
||||||
}
|
}
|
||||||
@@ -1192,7 +1193,7 @@ void VulkanRenderDriver::_init_queues(std::vector<VkDeviceQueueCreateInfo>& p_qu
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
NOVA_LOG("Using queue family: {}", i);
|
NOVA_INFO("Using queue family: {}", i);
|
||||||
found |= available[i].queueFlags;
|
found |= available[i].queueFlags;
|
||||||
|
|
||||||
VkDeviceQueueCreateInfo create {};
|
VkDeviceQueueCreateInfo create {};
|
||||||
|
|||||||
@@ -9,78 +9,30 @@
|
|||||||
#ifdef NOVA_VULKAN
|
#ifdef NOVA_VULKAN
|
||||||
|
|
||||||
#include <nova/render/render_driver.h>
|
#include <nova/render/render_driver.h>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
struct CommandBuffer {
|
|
||||||
VkCommandBuffer handle = VK_NULL_HANDLE;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CommandPool {
|
|
||||||
VkCommandPool handle = VK_NULL_HANDLE;
|
|
||||||
std::vector<CommandBufferID> allocated_buffers;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Pipeline {
|
|
||||||
PipelineType type;
|
|
||||||
VkPipeline handle = VK_NULL_HANDLE;
|
|
||||||
VkPipelineLayout layout = VK_NULL_HANDLE;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Queue {
|
|
||||||
VkQueue handle = VK_NULL_HANDLE;
|
|
||||||
u32 family_index;
|
|
||||||
u32 queue_index;
|
|
||||||
u32 usage_count = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct RenderPass {
|
|
||||||
VkRenderPass handle = VK_NULL_HANDLE;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Shader {
|
|
||||||
VkShaderModule handle = VK_NULL_HANDLE;
|
|
||||||
ShaderStage stage = ShaderStage::VERTEX;
|
|
||||||
std::string name;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Surface {
|
|
||||||
VkSurfaceKHR handle = VK_NULL_HANDLE;
|
|
||||||
u32 width = 0;
|
|
||||||
u32 height = 0;
|
|
||||||
bool dirty = false; // TODO: Use state enum
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Swapchain {
|
|
||||||
VkSwapchainKHR handle = VK_NULL_HANDLE;
|
|
||||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
|
||||||
VkColorSpaceKHR color_space = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
|
||||||
std::vector<VkImage> images;
|
|
||||||
std::vector<VkImageView> image_views;
|
|
||||||
std::vector<VkFramebuffer> framebuffers;
|
|
||||||
SurfaceID surface = nullptr;
|
|
||||||
RenderPassID render_pass = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class VulkanRenderDriver final : public RenderDriver {
|
class VulkanRenderDriver final : public RenderDriver {
|
||||||
public:
|
public:
|
||||||
explicit VulkanRenderDriver(WindowDriver* window_driver);
|
explicit VulkanRenderDriver(WindowDriver* window_driver);
|
||||||
~VulkanRenderDriver() override;
|
~VulkanRenderDriver() override;
|
||||||
|
|
||||||
[[nodiscard]] RenderAPI get_api() const override;
|
RenderAPI get_api() const override;
|
||||||
[[nodiscard]] u32 get_api_version() const override;
|
u32 get_api_version() const override;
|
||||||
[[nodiscard]] std::string get_api_name() const override;
|
std::string get_api_name() const override;
|
||||||
[[nodiscard]] std::string get_api_version_string() const override;
|
std::string get_api_version_string() const override;
|
||||||
|
|
||||||
[[nodiscard]] u32 get_device_count() const override;
|
u32 get_device_count() const override;
|
||||||
[[nodiscard]] const RenderDevice& get_device(u32 index) const override;
|
const RenderDevice& get_device(u32 index) const override;
|
||||||
[[nodiscard]] bool get_device_supports_surface(u32 index, SurfaceID surface) const override;
|
bool get_device_supports_surface(u32 index, SurfaceID surface) const override;
|
||||||
void select_device(u32 index) override;
|
void select_device(u32 index) override;
|
||||||
|
|
||||||
[[nodiscard]] u32 choose_queue_family(QueueType type, SurfaceID surface) override;
|
u32 choose_queue_family(QueueType type, SurfaceID surface) override;
|
||||||
|
|
||||||
[[nodiscard]] QueueID get_queue(u32 queue_family) override;
|
[[nodiscard]] QueueID get_queue(u32 queue_family) override;
|
||||||
void free_queue(QueueID queue) override;
|
void free_queue(QueueID queue) override;
|
||||||
|
|
||||||
@@ -89,7 +41,7 @@ namespace Nova {
|
|||||||
|
|
||||||
[[nodiscard]] SwapchainID create_swapchain(SurfaceID surface) override;
|
[[nodiscard]] SwapchainID create_swapchain(SurfaceID surface) override;
|
||||||
void resize_swapchain(SwapchainID swapchain) override;
|
void resize_swapchain(SwapchainID swapchain) override;
|
||||||
[[nodiscard]] RenderPassID get_swapchain_render_pass(SwapchainID swapchain) const override;
|
RenderPassID get_swapchain_render_pass(SwapchainID swapchain) const override;
|
||||||
void destroy_swapchain(SwapchainID swapchain) override;
|
void destroy_swapchain(SwapchainID swapchain) override;
|
||||||
|
|
||||||
[[nodiscard]] ShaderID create_shader(const std::span<u8> bytes, ShaderStage stage) override;
|
[[nodiscard]] ShaderID create_shader(const std::span<u8> bytes, ShaderStage stage) override;
|
||||||
@@ -109,8 +61,8 @@ namespace Nova {
|
|||||||
void begin_command_buffer(CommandBufferID command_buffer) override;
|
void begin_command_buffer(CommandBufferID command_buffer) override;
|
||||||
void end_command_buffer(CommandBufferID command_buffer) override;
|
void end_command_buffer(CommandBufferID command_buffer) override;
|
||||||
|
|
||||||
[[nodiscard]] VkInstance get_instance() const;
|
VkInstance get_instance() const;
|
||||||
[[nodiscard]] VkAllocationCallbacks* get_allocator(VkObjectType type) const;
|
VkAllocationCallbacks* get_allocator(VkObjectType type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WindowDriver* m_window_driver = nullptr;
|
WindowDriver* m_window_driver = nullptr;
|
||||||
|
|||||||
70
engine/src/drivers/vulkan/render_structs.h
Normal file
70
engine/src/drivers/vulkan/render_structs.h
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// NOTE: This header should only be included in implementation files
|
||||||
|
|
||||||
|
#include <nova/render/render_driver.h>
|
||||||
|
#include <nova/render/render_structs.h>
|
||||||
|
#include <nova/types.h>
|
||||||
|
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct CommandBuffer {
|
||||||
|
VkCommandBuffer handle = VK_NULL_HANDLE;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CommandPool {
|
||||||
|
VkCommandPool handle = VK_NULL_HANDLE;
|
||||||
|
std::vector<CommandBufferID> allocated_buffers;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Pipeline {
|
||||||
|
PipelineType type;
|
||||||
|
VkPipeline handle = VK_NULL_HANDLE;
|
||||||
|
VkPipelineLayout layout = VK_NULL_HANDLE;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Queue {
|
||||||
|
VkQueue handle = VK_NULL_HANDLE;
|
||||||
|
u32 family_index;
|
||||||
|
u32 queue_index;
|
||||||
|
u32 usage_count = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RenderPass {
|
||||||
|
VkRenderPass handle = VK_NULL_HANDLE;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Shader {
|
||||||
|
VkShaderModule handle = VK_NULL_HANDLE;
|
||||||
|
ShaderStage stage = ShaderStage::VERTEX;
|
||||||
|
std::string name;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Surface {
|
||||||
|
VkSurfaceKHR handle = VK_NULL_HANDLE;
|
||||||
|
u32 width = 0;
|
||||||
|
u32 height = 0;
|
||||||
|
bool dirty = false; // TODO: Use state enum
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Swapchain {
|
||||||
|
VkSwapchainKHR handle = VK_NULL_HANDLE;
|
||||||
|
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||||
|
VkColorSpaceKHR color_space = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||||
|
std::vector<VkImage> images;
|
||||||
|
std::vector<VkImageView> image_views;
|
||||||
|
std::vector<VkFramebuffer> framebuffers;
|
||||||
|
SurfaceID surface = nullptr;
|
||||||
|
RenderPassID render_pass = nullptr;
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef NOVA_WINDOWS
|
|
||||||
|
|
||||||
#include "drivers/win32/window_driver.h"
|
|
||||||
|
|
||||||
#ifdef NOVA_VULKAN
|
|
||||||
#include <vulkan/vulkan.h>
|
|
||||||
#include <vulkan/vulkan_win32.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
|
||||||
|
|
||||||
using namespace Nova;
|
|
||||||
|
|
||||||
Win32WindowDriver::Win32WindowDriver() {
|
|
||||||
NOVA_AUTO_TRACE();
|
|
||||||
}
|
|
||||||
|
|
||||||
Win32WindowDriver::~Win32WindowDriver() {
|
|
||||||
NOVA_AUTO_TRACE();
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* Win32WindowDriver::get_surface_extension() const {
|
|
||||||
#ifdef NOVA_VULKAN
|
|
||||||
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
|
|
||||||
#else
|
|
||||||
return nullptr;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // NOVA_WINDOWS
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef NOVA_WINDOWS
|
|
||||||
|
|
||||||
#include <nova/platform/window_driver.h>
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
namespace Nova {
|
|
||||||
class Win32WindowDriver final : public WindowDriver {
|
|
||||||
public:
|
|
||||||
Win32WindowDriver();
|
|
||||||
~Win32WindowDriver() override;
|
|
||||||
|
|
||||||
[[nodiscard]] const char* get_surface_extension() const override;
|
|
||||||
};
|
|
||||||
} // namespace Nova
|
|
||||||
|
|
||||||
#endif // NOVA_WINDOWS
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#ifdef NOVA_WAYLAND
|
#ifdef NOVA_WAYLAND
|
||||||
|
|
||||||
#include "drivers/wayland/window_driver.h"
|
#include "platform/linux/wayland/window_driver.h"
|
||||||
|
|
||||||
#ifdef NOVA_VULKAN
|
#ifdef NOVA_VULKAN
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
@@ -6,10 +6,14 @@
|
|||||||
|
|
||||||
#ifdef NOVA_X11
|
#ifdef NOVA_X11
|
||||||
|
|
||||||
#include "drivers/x11/window_driver.h"
|
#include "platform/linux/x11/window_driver.h"
|
||||||
|
|
||||||
|
#include "platform/linux/x11/window_structs.h"
|
||||||
|
#include "platform/linux/x11/wrapper.h"
|
||||||
|
|
||||||
#ifdef NOVA_VULKAN
|
#ifdef NOVA_VULKAN
|
||||||
#include "drivers/vulkan/render_driver.h"
|
#include "drivers/vulkan/render_driver.h"
|
||||||
|
#include "drivers/vulkan/render_structs.h"
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_xlib.h>
|
#include <vulkan/vulkan_xlib.h>
|
||||||
@@ -104,7 +108,7 @@ u32 X11WindowDriver::get_window_count() const {
|
|||||||
return static_cast<u32>(m_windows.size());
|
return static_cast<u32>(m_windows.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowID X11WindowDriver::create_window(const std::string_view p_title, const u32 p_width, const u32 p_height) {
|
WindowID X11WindowDriver::create_window(const std::string& p_title, const u32 p_width, const u32 p_height) {
|
||||||
NOVA_AUTO_TRACE();
|
NOVA_AUTO_TRACE();
|
||||||
|
|
||||||
X11::Window handle = XCreateSimpleWindow(m_display, DefaultRootWindow(m_display), 0, 0, p_width, p_height, 0, 0, 0);
|
X11::Window handle = XCreateSimpleWindow(m_display, DefaultRootWindow(m_display), 0, 0, p_width, p_height, 0, 0, 0);
|
||||||
@@ -116,7 +120,7 @@ WindowID X11WindowDriver::create_window(const std::string_view p_title, const u3
|
|||||||
|
|
||||||
XSetWMProtocols(m_display, handle, &m_window_close_atom, 1);
|
XSetWMProtocols(m_display, handle, &m_window_close_atom, 1);
|
||||||
XSelectInput(m_display, handle, StructureNotifyMask);
|
XSelectInput(m_display, handle, StructureNotifyMask);
|
||||||
XStoreName(m_display, handle, p_title.data());
|
XStoreName(m_display, handle, p_title.c_str());
|
||||||
XMapWindow(m_display, handle);
|
XMapWindow(m_display, handle);
|
||||||
XFlush(m_display);
|
XFlush(m_display);
|
||||||
|
|
||||||
@@ -131,10 +135,10 @@ void X11WindowDriver::destroy_window(WindowID p_window) {
|
|||||||
m_windows.erase(p_window->handle);
|
m_windows.erase(p_window->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11WindowDriver::set_window_title(WindowID p_window, const std::string_view p_title) {
|
void X11WindowDriver::set_window_title(WindowID p_window, const std::string& p_title) {
|
||||||
NOVA_AUTO_TRACE();
|
NOVA_AUTO_TRACE();
|
||||||
NOVA_ASSERT(p_window);
|
NOVA_ASSERT(p_window);
|
||||||
XStoreName(m_display, p_window->handle, p_title.data());
|
XStoreName(m_display, p_window->handle, p_title.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void X11WindowDriver::set_window_size(WindowID p_window, const u32 p_width, const u32 p_height) {
|
void X11WindowDriver::set_window_size(WindowID p_window, const u32 p_width, const u32 p_height) {
|
||||||
@@ -8,44 +8,33 @@
|
|||||||
|
|
||||||
#ifdef NOVA_X11
|
#ifdef NOVA_X11
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include "platform/linux/x11/wrapper.h"
|
||||||
|
|
||||||
#include <nova/platform/window_driver.h>
|
#include <nova/platform/window_driver.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace X11 {
|
|
||||||
using Window = ::Window;
|
|
||||||
using Display = ::Display;
|
|
||||||
using Atom = ::Atom;
|
|
||||||
} // namespace X11
|
|
||||||
|
|
||||||
namespace Nova {
|
namespace Nova {
|
||||||
struct Window {
|
|
||||||
X11::Window handle = 0;
|
|
||||||
int width = 0;
|
|
||||||
int height = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class X11WindowDriver final : public WindowDriver {
|
class X11WindowDriver final : public WindowDriver {
|
||||||
public:
|
public:
|
||||||
X11WindowDriver();
|
X11WindowDriver();
|
||||||
~X11WindowDriver() override;
|
~X11WindowDriver() override;
|
||||||
|
|
||||||
[[nodiscard]] WindowAPI get_api() const override;
|
WindowAPI get_api() const override;
|
||||||
[[nodiscard]] std::string get_api_name() const override;
|
std::string get_api_name() const override;
|
||||||
|
|
||||||
void poll_events() override;
|
void poll_events() override;
|
||||||
void beep() override;
|
void beep() override;
|
||||||
|
|
||||||
[[nodiscard]] u32 get_window_count() const override;
|
u32 get_window_count() const override;
|
||||||
[[nodiscard]] WindowID create_window(std::string_view title, u32 width, u32 height) override;
|
[[nodiscard]] WindowID create_window(const std::string& title, u32 width, u32 height) override;
|
||||||
void destroy_window(WindowID window) override;
|
void destroy_window(WindowID window) override;
|
||||||
|
|
||||||
void set_window_title(WindowID window, std::string_view title) override;
|
void set_window_title(WindowID window, const std::string& title) override;
|
||||||
void set_window_size(WindowID window, u32 width, u32 height) override;
|
void set_window_size(WindowID window, u32 width, u32 height) override;
|
||||||
void set_window_position(WindowID window, i32 x, i32 y) override;
|
void set_window_position(WindowID window, i32 x, i32 y) override;
|
||||||
|
|
||||||
[[nodiscard]] const char* get_surface_extension() const override;
|
const char* get_surface_extension() const override;
|
||||||
[[nodiscard]] SurfaceID create_surface(WindowID window, RenderDriver* driver) override;
|
[[nodiscard]] SurfaceID create_surface(WindowID window, RenderDriver* driver) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
21
engine/src/platform/linux/x11/window_structs.h
Normal file
21
engine/src/platform/linux/x11/window_structs.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// NOTE: This header should only be included in implementation files
|
||||||
|
|
||||||
|
#include "platform/linux/x11/wrapper.h"
|
||||||
|
|
||||||
|
#include <nova/platform/platform_structs.h>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct Window {
|
||||||
|
X11::Window handle = 0;
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
15
engine/src/platform/linux/x11/wrapper.h
Normal file
15
engine/src/platform/linux/x11/wrapper.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
namespace X11 {
|
||||||
|
using Window = ::Window;
|
||||||
|
using Display = ::Display;
|
||||||
|
using Atom = ::Atom;
|
||||||
|
} // namespace X11
|
||||||
@@ -4,9 +4,9 @@
|
|||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "drivers/wayland/window_driver.h" // IWYU pragma: keep
|
#include "platform/linux/wayland/window_driver.h" // IWYU pragma: keep
|
||||||
#include "drivers/win32/window_driver.h" // IWYU pragma: keep
|
#include "platform/linux/x11/window_driver.h" // IWYU pragma: keep
|
||||||
#include "drivers/x11/window_driver.h" // IWYU pragma: keep
|
#include "platform/windows/window_driver.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
#include <nova/core/debug.h>
|
||||||
#include <nova/platform/window_driver.h>
|
#include <nova/platform/window_driver.h>
|
||||||
|
|||||||
222
engine/src/platform/windows/window_driver.cpp
Normal file
222
engine/src/platform/windows/window_driver.cpp
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef NOVA_WINDOWS
|
||||||
|
|
||||||
|
#include "platform/windows/window_driver.h"
|
||||||
|
|
||||||
|
#include "platform/windows/window_structs.h"
|
||||||
|
|
||||||
|
#ifdef NOVA_VULKAN
|
||||||
|
#include "drivers/vulkan/render_driver.h"
|
||||||
|
#include "drivers/vulkan/render_structs.h"
|
||||||
|
|
||||||
|
#include <vulkan/vulkan.h>
|
||||||
|
#include <vulkan/vulkan_win32.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <nova/core/debug.h>
|
||||||
|
#include <nova/render/render_driver.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
static constexpr LPCSTR WINDOW_CLASS_NAME = "NOVA_WindowClass";
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Nova;
|
||||||
|
|
||||||
|
Win32WindowDriver::Win32WindowDriver() {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
|
||||||
|
WNDCLASSEX wc = {};
|
||||||
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wc.lpfnWndProc = _window_proc;
|
||||||
|
wc.hInstance = GetModuleHandle(nullptr);
|
||||||
|
wc.lpszClassName = WINDOW_CLASS_NAME;
|
||||||
|
|
||||||
|
if (!RegisterClassEx(&wc)) {
|
||||||
|
throw std::runtime_error("Failed to register window class");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Win32WindowDriver::~Win32WindowDriver() {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
UnregisterClass(WINDOW_CLASS_NAME, GetModuleHandle(nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowAPI Win32WindowDriver::get_api() const {
|
||||||
|
return WindowAPI::WINDOWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Win32WindowDriver::get_api_name() const {
|
||||||
|
return "Win32";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::poll_events() {
|
||||||
|
MSG msg;
|
||||||
|
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::beep() {
|
||||||
|
MessageBeep(MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 Win32WindowDriver::get_window_count() const {
|
||||||
|
return static_cast<u32>(m_windows.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowID Win32WindowDriver::create_window(const std::string& p_title, u32 p_width, u32 p_height) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
|
||||||
|
RECT rect = {0, 0, static_cast<LONG>(p_width), static_cast<LONG>(p_height)};
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
|
||||||
|
HWND handle = CreateWindowEx(
|
||||||
|
0,
|
||||||
|
WINDOW_CLASS_NAME,
|
||||||
|
p_title.c_str(),
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
rect.right - rect.left,
|
||||||
|
rect.bottom - rect.top,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
GetModuleHandle(nullptr),
|
||||||
|
this
|
||||||
|
);
|
||||||
|
|
||||||
|
Window* window = new Window();
|
||||||
|
window->width = p_width;
|
||||||
|
window->height = p_height;
|
||||||
|
window->handle = handle;
|
||||||
|
|
||||||
|
ShowWindow(handle, SW_SHOW);
|
||||||
|
UpdateWindow(handle);
|
||||||
|
|
||||||
|
m_windows[handle] = window;
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::destroy_window(WindowID p_window) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
NOVA_ASSERT(p_window);
|
||||||
|
DestroyWindow(p_window->handle);
|
||||||
|
m_windows.erase(p_window->handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::set_window_title(WindowID p_window, const std::string& p_title) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
NOVA_ASSERT(p_window);
|
||||||
|
SetWindowText(p_window->handle, p_title.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::set_window_size(WindowID p_window, u32 p_width, u32 p_height) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
NOVA_ASSERT(p_window);
|
||||||
|
RECT rect = {0, 0, static_cast<LONG>(p_width), static_cast<LONG>(p_height)};
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
|
||||||
|
SetWindowPos(p_window->handle, nullptr, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOMOVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Win32WindowDriver::set_window_position(WindowID p_window, i32 p_x, i32 p_y) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
NOVA_ASSERT(p_window);
|
||||||
|
SetWindowPos(p_window->handle, nullptr, p_x, p_y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* Win32WindowDriver::get_surface_extension() const {
|
||||||
|
#ifdef NOVA_VULKAN
|
||||||
|
return VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SurfaceID Win32WindowDriver::create_surface(WindowID p_window, RenderDriver* p_driver) {
|
||||||
|
NOVA_AUTO_TRACE();
|
||||||
|
NOVA_ASSERT(p_window);
|
||||||
|
NOVA_ASSERT(p_driver);
|
||||||
|
NOVA_ASSERT(p_driver->get_api() == RenderAPI::VULKAN);
|
||||||
|
|
||||||
|
#ifdef NOVA_VULKAN
|
||||||
|
VkWin32SurfaceCreateInfoKHR create {};
|
||||||
|
create.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
|
||||||
|
create.hinstance = GetModuleHandle(nullptr);
|
||||||
|
create.hwnd = p_window->handle;
|
||||||
|
|
||||||
|
const auto vkrd = static_cast<VulkanRenderDriver*>(p_driver);
|
||||||
|
Surface* surface = new Surface();
|
||||||
|
|
||||||
|
if (vkCreateWin32SurfaceKHR(vkrd->get_instance(), &create, vkrd->get_allocator(VK_OBJECT_TYPE_SURFACE_KHR), &surface->handle)
|
||||||
|
!= VK_SUCCESS) {
|
||||||
|
throw std::runtime_error("Failed to create Vulkan surface");
|
||||||
|
}
|
||||||
|
|
||||||
|
return surface;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT Win32WindowDriver::_handle_message(HWND p_handle, UINT p_msg, WPARAM p_wparam, LPARAM p_lparam) {
|
||||||
|
auto iter = m_windows.find(p_handle);
|
||||||
|
if (iter == m_windows.end()) {
|
||||||
|
return DefWindowProc(p_handle, p_msg, p_wparam, p_lparam);
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowID window = iter->second;
|
||||||
|
|
||||||
|
switch (p_msg) {
|
||||||
|
case WM_DESTROY: {
|
||||||
|
NOVA_DEBUG("Window event: DESTROYED");
|
||||||
|
if (m_windows.empty()) {
|
||||||
|
PostQuitMessage(0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_SIZE: {
|
||||||
|
int width = LOWORD(p_lparam);
|
||||||
|
int height = HIWORD(p_lparam);
|
||||||
|
if (width != window->width || height != window->height) {
|
||||||
|
window->width = width;
|
||||||
|
window->height = height;
|
||||||
|
NOVA_DEBUG("Window event: RESIZED ({}x{})", width, height);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case WM_CLOSE: {
|
||||||
|
NOVA_DEBUG("Window event: CLOSED");
|
||||||
|
destroy_window(window);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return DefWindowProc(p_handle, p_msg, p_wparam, p_lparam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT CALLBACK Win32WindowDriver::_window_proc(HWND p_handle, UINT p_msg, WPARAM p_wparam, LPARAM p_lparam) {
|
||||||
|
Win32WindowDriver* driver = nullptr;
|
||||||
|
|
||||||
|
if (p_msg == WM_NCCREATE) {
|
||||||
|
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(p_lparam);
|
||||||
|
driver = static_cast<Win32WindowDriver*>(cs->lpCreateParams);
|
||||||
|
SetWindowLongPtr(p_handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(driver));
|
||||||
|
} else {
|
||||||
|
driver = reinterpret_cast<Win32WindowDriver*>(GetWindowLongPtr(p_handle, GWLP_USERDATA));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (driver) {
|
||||||
|
return driver->_handle_message(p_handle, p_msg, p_wparam, p_lparam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(p_handle, p_msg, p_wparam, p_lparam);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // NOVA_WINDOWS
|
||||||
48
engine/src/platform/windows/window_driver.h
Normal file
48
engine/src/platform/windows/window_driver.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef NOVA_WINDOWS
|
||||||
|
|
||||||
|
#include <nova/platform/window_driver.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
class Win32WindowDriver final : public WindowDriver {
|
||||||
|
public:
|
||||||
|
Win32WindowDriver();
|
||||||
|
~Win32WindowDriver() override;
|
||||||
|
|
||||||
|
WindowAPI get_api() const override;
|
||||||
|
std::string get_api_name() const override;
|
||||||
|
|
||||||
|
void poll_events() override;
|
||||||
|
void beep() override;
|
||||||
|
|
||||||
|
u32 get_window_count() const override;
|
||||||
|
[[nodiscard]] WindowID create_window(const std::string& title, u32 width, u32 height) override;
|
||||||
|
void destroy_window(WindowID window) override;
|
||||||
|
|
||||||
|
void set_window_title(WindowID window, const std::string& title) override;
|
||||||
|
void set_window_size(WindowID window, u32 width, u32 height) override;
|
||||||
|
void set_window_position(WindowID window, i32 x, i32 y) override;
|
||||||
|
|
||||||
|
[[nodiscard]] const char* get_surface_extension() const override;
|
||||||
|
[[nodiscard]] SurfaceID create_surface(WindowID window, RenderDriver* p_driver) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<HWND, WindowID> m_windows;
|
||||||
|
|
||||||
|
LRESULT _handle_message(HWND handle, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
|
|
||||||
|
static LRESULT CALLBACK _window_proc(HWND handle, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
|
|
||||||
|
#endif // NOVA_WINDOWS
|
||||||
20
engine/src/platform/windows/window_structs.h
Normal file
20
engine/src/platform/windows/window_structs.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/// NOTE: This header should only be included in implementation files
|
||||||
|
|
||||||
|
#include <nova/platform/platform_structs.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
namespace Nova {
|
||||||
|
struct Window {
|
||||||
|
HWND handle = {};
|
||||||
|
int width = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
} // namespace Nova
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <nova/render/render_device.h>
|
#include <nova/render/render_device.h>
|
||||||
#include <nova/render/render_driver.h>
|
#include <nova/render/render_driver.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using namespace Nova;
|
using namespace Nova;
|
||||||
@@ -18,31 +19,29 @@ u32 RenderDevice::choose_device(RenderDriver* p_driver, std::span<const SurfaceI
|
|||||||
u32 best_index = std::numeric_limits<u32>::max();
|
u32 best_index = std::numeric_limits<u32>::max();
|
||||||
u32 best_score = 0;
|
u32 best_score = 0;
|
||||||
|
|
||||||
|
const bool prefer_discrete = true; // TODO: Get from config
|
||||||
|
|
||||||
for (u32 i = 0; i < p_driver->get_device_count(); i++) {
|
for (u32 i = 0; i < p_driver->get_device_count(); i++) {
|
||||||
auto& device = p_driver->get_device(i);
|
auto& device = p_driver->get_device(i);
|
||||||
u32 score = 1;
|
u32 score = 1;
|
||||||
|
|
||||||
for (SurfaceID surface : p_surfaces) {
|
if (!std::all_of(p_surfaces.begin(), p_surfaces.end(), [&](SurfaceID surface) {
|
||||||
if (!p_driver->get_device_supports_surface(i, surface)) {
|
return p_driver->get_device_supports_surface(i, surface);
|
||||||
score = 0;
|
})) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (score == 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (device.type) {
|
switch (device.type) {
|
||||||
case Type::DISCRETE:
|
case DeviceType::DISCRETE:
|
||||||
score += 4;
|
score += prefer_discrete ? 4 : 3;
|
||||||
break;
|
break;
|
||||||
case Type::INTEGRATED:
|
case DeviceType::INTEGRATED:
|
||||||
score += 3;
|
score += prefer_discrete ? 3 : 4;
|
||||||
break;
|
break;
|
||||||
case Type::VIRTUAL:
|
case DeviceType::VIRTUAL:
|
||||||
score += 2;
|
score += 2;
|
||||||
break;
|
break;
|
||||||
case Type::CPU:
|
case DeviceType::CPU:
|
||||||
score += 1;
|
score += 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nova/core/debug.h>
|
|
||||||
#include <nova/render/render_driver.h>
|
|
||||||
#include <nova/render/renderer.h>
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
using namespace Nova;
|
|
||||||
|
|
||||||
static std::unique_ptr<RenderDriver> s_driver;
|
|
||||||
|
|
||||||
void Renderer::init(const RenderAPI p_api) {
|
|
||||||
NOVA_AUTO_TRACE();
|
|
||||||
NOVA_ASSERT(!s_driver);
|
|
||||||
|
|
||||||
s_driver = std::unique_ptr<RenderDriver>(RenderDriver::create(p_api, nullptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::shutdown() {
|
|
||||||
NOVA_AUTO_TRACE();
|
|
||||||
s_driver.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderDriver* Renderer::get_driver() {
|
|
||||||
NOVA_ASSERT(s_driver);
|
|
||||||
return s_driver.get();
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user