diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/include/Device.h b/include/Device.h
index 849e307..5c396b7 100644
--- a/include/Device.h
+++ b/include/Device.h
@@ -7,7 +7,7 @@
class Device
{
const std::vector required_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
-
+ // List of wanted formats for swapchain image presentation.
const vk::Format wanted_formats[2] = { vk::Format::eR8G8B8A8Srgb, vk::Format::eB8G8R8A8Srgb };
vk::UniqueDevice m_logical_device;
@@ -27,9 +27,7 @@
bool IsRequiredExtensionsSupported(vk::PhysicalDevice device) const;
vk::SurfaceFormatKHR QueryBestSurfaceFormat(const std::vector& formats);
-
public:
-
Device(vk::SurfaceKHR surface, vk::Instance& instance);
[[nodiscard]] uint32_t GetGraphicsQueueIndex() const FPR_NOEXCEPT;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/include/Device.h b/include/Device.h
index 849e307..5c396b7 100644
--- a/include/Device.h
+++ b/include/Device.h
@@ -7,7 +7,7 @@
class Device
{
const std::vector required_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
-
+ // List of wanted formats for swapchain image presentation.
const vk::Format wanted_formats[2] = { vk::Format::eR8G8B8A8Srgb, vk::Format::eB8G8R8A8Srgb };
vk::UniqueDevice m_logical_device;
@@ -27,9 +27,7 @@
bool IsRequiredExtensionsSupported(vk::PhysicalDevice device) const;
vk::SurfaceFormatKHR QueryBestSurfaceFormat(const std::vector& formats);
-
public:
-
Device(vk::SurfaceKHR surface, vk::Instance& instance);
[[nodiscard]] uint32_t GetGraphicsQueueIndex() const FPR_NOEXCEPT;
diff --git a/include/InputHandler.h b/include/InputHandler.h
index 054b877..5b37dc4 100644
--- a/include/InputHandler.h
+++ b/include/InputHandler.h
@@ -186,6 +186,12 @@
static glm::highp_dvec2 new_cursor_pos;
static glm::highp_dvec2 dx_dy;
+ //IMPORTANT:
+ //An input handler is registered and held in this **STATIC** vector when constructed. This allows for multiple input handlers.
+ //Therefore, I can bind different keys to different actions based on what they are resposible for.
+ //For example, a camera input handler may bind the mouse for movoement.
+ //However, I may also want to use the mouse for camera picking.
+ //Having seperate input handlers allows for usage of same keys, and the user can pick between different input handlers based on the internal state of their program.
static std::vector S_INPUT_HANDLERS;
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/include/Device.h b/include/Device.h
index 849e307..5c396b7 100644
--- a/include/Device.h
+++ b/include/Device.h
@@ -7,7 +7,7 @@
class Device
{
const std::vector required_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
-
+ // List of wanted formats for swapchain image presentation.
const vk::Format wanted_formats[2] = { vk::Format::eR8G8B8A8Srgb, vk::Format::eB8G8R8A8Srgb };
vk::UniqueDevice m_logical_device;
@@ -27,9 +27,7 @@
bool IsRequiredExtensionsSupported(vk::PhysicalDevice device) const;
vk::SurfaceFormatKHR QueryBestSurfaceFormat(const std::vector& formats);
-
public:
-
Device(vk::SurfaceKHR surface, vk::Instance& instance);
[[nodiscard]] uint32_t GetGraphicsQueueIndex() const FPR_NOEXCEPT;
diff --git a/include/InputHandler.h b/include/InputHandler.h
index 054b877..5b37dc4 100644
--- a/include/InputHandler.h
+++ b/include/InputHandler.h
@@ -186,6 +186,12 @@
static glm::highp_dvec2 new_cursor_pos;
static glm::highp_dvec2 dx_dy;
+ //IMPORTANT:
+ //An input handler is registered and held in this **STATIC** vector when constructed. This allows for multiple input handlers.
+ //Therefore, I can bind different keys to different actions based on what they are resposible for.
+ //For example, a camera input handler may bind the mouse for movoement.
+ //However, I may also want to use the mouse for camera picking.
+ //Having seperate input handlers allows for usage of same keys, and the user can pick between different input handlers based on the internal state of their program.
static std::vector S_INPUT_HANDLERS;
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
diff --git a/include/Light.h b/include/Light.h
index 0f8ee70..a1de4c8 100644
--- a/include/Light.h
+++ b/include/Light.h
@@ -1,28 +1,21 @@
#pragma once
#include
+
#include "Buffer/Buffer.h"
+#include "Context.h"
namespace fpr
{
-struct PointLightUBO
-{
- alignas(16) glm::vec3 color;
- alignas(4) float luminance;
- alignas(16) glm::vec3 position;
-};
-
class PointLight
{
static size_t light_count;
-
glm::vec3 m_position;
glm::vec3 m_color;
float m_luminance;
- PointLightUBO m_ubo;
+ PointLightData m_ubo;
public:
size_t light_index;
- static constexpr uint32_t MAX_LIGHTS = 1024;
- static PointLightUBO s_point_light_data[MAX_LIGHTS];
+ static PointLightUBO s_point_light_data;
PointLight(glm::vec3 m_position, glm::vec3 color = { 1.0f, 1.0f, 1.0f }, float radius = 50.0f);
PointLight() = default;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/include/Device.h b/include/Device.h
index 849e307..5c396b7 100644
--- a/include/Device.h
+++ b/include/Device.h
@@ -7,7 +7,7 @@
class Device
{
const std::vector required_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
-
+ // List of wanted formats for swapchain image presentation.
const vk::Format wanted_formats[2] = { vk::Format::eR8G8B8A8Srgb, vk::Format::eB8G8R8A8Srgb };
vk::UniqueDevice m_logical_device;
@@ -27,9 +27,7 @@
bool IsRequiredExtensionsSupported(vk::PhysicalDevice device) const;
vk::SurfaceFormatKHR QueryBestSurfaceFormat(const std::vector& formats);
-
public:
-
Device(vk::SurfaceKHR surface, vk::Instance& instance);
[[nodiscard]] uint32_t GetGraphicsQueueIndex() const FPR_NOEXCEPT;
diff --git a/include/InputHandler.h b/include/InputHandler.h
index 054b877..5b37dc4 100644
--- a/include/InputHandler.h
+++ b/include/InputHandler.h
@@ -186,6 +186,12 @@
static glm::highp_dvec2 new_cursor_pos;
static glm::highp_dvec2 dx_dy;
+ //IMPORTANT:
+ //An input handler is registered and held in this **STATIC** vector when constructed. This allows for multiple input handlers.
+ //Therefore, I can bind different keys to different actions based on what they are resposible for.
+ //For example, a camera input handler may bind the mouse for movoement.
+ //However, I may also want to use the mouse for camera picking.
+ //Having seperate input handlers allows for usage of same keys, and the user can pick between different input handlers based on the internal state of their program.
static std::vector S_INPUT_HANDLERS;
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
diff --git a/include/Light.h b/include/Light.h
index 0f8ee70..a1de4c8 100644
--- a/include/Light.h
+++ b/include/Light.h
@@ -1,28 +1,21 @@
#pragma once
#include
+
#include "Buffer/Buffer.h"
+#include "Context.h"
namespace fpr
{
-struct PointLightUBO
-{
- alignas(16) glm::vec3 color;
- alignas(4) float luminance;
- alignas(16) glm::vec3 position;
-};
-
class PointLight
{
static size_t light_count;
-
glm::vec3 m_position;
glm::vec3 m_color;
float m_luminance;
- PointLightUBO m_ubo;
+ PointLightData m_ubo;
public:
size_t light_index;
- static constexpr uint32_t MAX_LIGHTS = 1024;
- static PointLightUBO s_point_light_data[MAX_LIGHTS];
+ static PointLightUBO s_point_light_data;
PointLight(glm::vec3 m_position, glm::vec3 color = { 1.0f, 1.0f, 1.0f }, float radius = 50.0f);
PointLight() = default;
diff --git a/include/Material.h b/include/Material.h
deleted file mode 100644
index 61dc43d..0000000
--- a/include/Material.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-#include
-#include "Texture.h"
-#include "ConstrainedMap.h"
-namespace fpr
-{
-enum class ETextureType
-{
- ETT_Diffuse,
- ETT_Unlit,
- ETT_AmbientOcclusion,
- ETT_BaseColor,
- ETT_DiffuseRoughness,
- ETT_Displacement,
- ETT_EmissionColor,
- ETT_Emissive,
- ETT_Height,
- ETT_Lightmap,
- ETT_Metalness,
- ETT_Normals,
- ETT_NormalCamera,
- ETT_Opacity,
- ETT_Reflection,
- ETT_Shininess,
- ETT_Specular,
- ETT_Unknown,
- ETT_MetallicRoughness
-};
-enum class EAlphaMode
-{
- EAM_MASK,
- EAM_OPAQUE
-};
-
-class Material
-{
- std::string m_name;
-public:
- ConstrainedMap> Textures;
- Material();
-};
-
-class gltfPBRMaterial : public fpr::Material
-{
- EAlphaMode m_alpha_mode;
- float m_base_color_factor;
-};
-
-} // namespace fpr
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type::type;
+ //helper function to extract iterator to mapped value.
map_type hash_table;
iterator found_value_iter(const std::string& value)
{
return hash_table.find(value);
};
public:
+
+ //Get overload that requires an unique handle
handle_element_type Get(const std::string& name) requires(unique_handle)
{
return found_value_iter(name)->second.get();
};
+ //Add overload that requires a unique handle
handle_element_type Add(const std::string& name, map_value& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Add overload that requires a unique handle and takes an r-value ref
handle_element_type Add(const std::string& name, map_value&& resource) requires(unique_handle)
{
hash_table[name] = std::move(resource);
return hash_table[name].get();
};
+ //Get overload that returns a reference to the value and that the held value is not an unique handle.
mapped_type& Get(const std::string& name) requires(not(unique_handle))
{
return found_value_iter(name)->second;
};
+ //Add overload that requires the mapped valuee to not be an unique handle.
mapped_type& Add(const std::string& name, map_value resource) requires(not(unique_handle))
{
hash_table[name] = resource;
diff --git a/include/Context.h b/include/Context.h
index d5c6689..344ee7a 100644
--- a/include/Context.h
+++ b/include/Context.h
@@ -11,7 +11,6 @@
#include "InputHandler.h"
namespace fpr
{
-
struct Version
{
uint32_t m_variant;
@@ -25,6 +24,7 @@
uint32_t MakeVersion() const FPR_NOEXCEPT;
};
+// Context singleton, cannot be derived from, has no public constructor. Init() has to be called before it is used.
class Context final
{
static VulkanWindow* s_window;
@@ -34,6 +34,7 @@
static fpr::Version s_engine_version;
static fpr::Version s_vulkan_version;
+ // Vulkan validation layer handling. Massive performance overhead so turned off if not in debug.
#ifdef NDEBUG
const bool validation_layers_enabled = false;
const std::vector m_validation_layers;
@@ -46,6 +47,7 @@
vk::UniqueInstance m_instance;
std::vector m_extensions;
+ // Vulkan struct initialiser helper function.
[[nodiscard]] vk::ApplicationInfo ApplicationInfo(
const char* application_name,
const Version& app_version,
@@ -68,27 +70,23 @@
vk::UniqueSwapchainKHR m_old_swapchain;
;
public:
+ // Type alias for what a PipelineCreation function should consume.
// Type, name, settings, parent(optional);
using PipelineCreationData =
std::vector>>;
private:
-
std::unique_ptr m_device;
vk::UniqueSurfaceKHR m_surface;
vk::UniqueCommandPool m_command_pool;
vk::UniqueCommandPool m_compute_comand_pool;
std::unique_ptr m_swapchain;
std::function m_pipeline_creation_fn;
-
vk::UniqueDescriptorPool m_descriptor_pool;
-
-
vk::UniqueCommandBuffer m_single_time_cmd_buffer;
-
VulkanWindow* m_window;
-
uint32_t m_dynamic_alignment = sizeof(glm::mat4);
+ // Default pipeline creation callback for "out-of-the-box" renderer usage.
static std::function DEFAULT_PIPELINE_CREATION_CALLBACK;
Context(
@@ -103,6 +101,8 @@
void CreateSingleTimeCommandBuffer();
+ // Myers' singleton pattern, requires a public "Get" function with a private constructor and public "Init()" function.
+ // Ensures no memory.
static Context& GetImpl(
VulkanWindow* Window = nullptr,
const std::string& app_name = s_app_name,
@@ -112,8 +112,6 @@
fpr::Version vulkan_version = s_vulkan_version);
-
-
void CreateModelDescriptorSet();
void CreateCameraDescriptorSet();
void CreateCameraDescriptorSetLayout();
@@ -127,9 +125,9 @@
static constexpr glm::vec3 RIGHT_VECTOR = glm::vec3(1, 0, 0);
- void CreateDescriptorSets();
+ void CreateDescriptorSets();
- struct PerModelData
+ struct PerModelData
{
glm::mat4* model_matrix;
} PER_MODEL_UBO;
@@ -160,9 +158,8 @@
void CreatePipelines(std::function fn = DEFAULT_PIPELINE_CREATION_CALLBACK);
void CreateSceneBuffers();
- void LoadScene(const char* file_name);
-
vk::CommandPool& GetGraphicsCmdPool() FPR_NOEXCEPT;
+ vk::CommandPool& GetComputeCmdPool() FPR_NOEXCEPT;
vk::DescriptorPool& GetDescriptorPool();
vk::SurfaceKHR& GetSurface() FPR_NOEXCEPT;
[[nodiscard]] Device* GetDevice() const FPR_NOEXCEPT;
diff --git a/include/Device.h b/include/Device.h
index 849e307..5c396b7 100644
--- a/include/Device.h
+++ b/include/Device.h
@@ -7,7 +7,7 @@
class Device
{
const std::vector required_extensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME };
-
+ // List of wanted formats for swapchain image presentation.
const vk::Format wanted_formats[2] = { vk::Format::eR8G8B8A8Srgb, vk::Format::eB8G8R8A8Srgb };
vk::UniqueDevice m_logical_device;
@@ -27,9 +27,7 @@
bool IsRequiredExtensionsSupported(vk::PhysicalDevice device) const;
vk::SurfaceFormatKHR QueryBestSurfaceFormat(const std::vector& formats);
-
public:
-
Device(vk::SurfaceKHR surface, vk::Instance& instance);
[[nodiscard]] uint32_t GetGraphicsQueueIndex() const FPR_NOEXCEPT;
diff --git a/include/InputHandler.h b/include/InputHandler.h
index 054b877..5b37dc4 100644
--- a/include/InputHandler.h
+++ b/include/InputHandler.h
@@ -186,6 +186,12 @@
static glm::highp_dvec2 new_cursor_pos;
static glm::highp_dvec2 dx_dy;
+ //IMPORTANT:
+ //An input handler is registered and held in this **STATIC** vector when constructed. This allows for multiple input handlers.
+ //Therefore, I can bind different keys to different actions based on what they are resposible for.
+ //For example, a camera input handler may bind the mouse for movoement.
+ //However, I may also want to use the mouse for camera picking.
+ //Having seperate input handlers allows for usage of same keys, and the user can pick between different input handlers based on the internal state of their program.
static std::vector S_INPUT_HANDLERS;
static void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
diff --git a/include/Light.h b/include/Light.h
index 0f8ee70..a1de4c8 100644
--- a/include/Light.h
+++ b/include/Light.h
@@ -1,28 +1,21 @@
#pragma once
#include
+
#include "Buffer/Buffer.h"
+#include "Context.h"
namespace fpr
{
-struct PointLightUBO
-{
- alignas(16) glm::vec3 color;
- alignas(4) float luminance;
- alignas(16) glm::vec3 position;
-};
-
class PointLight
{
static size_t light_count;
-
glm::vec3 m_position;
glm::vec3 m_color;
float m_luminance;
- PointLightUBO m_ubo;
+ PointLightData m_ubo;
public:
size_t light_index;
- static constexpr uint32_t MAX_LIGHTS = 1024;
- static PointLightUBO s_point_light_data[MAX_LIGHTS];
+ static PointLightUBO s_point_light_data;
PointLight(glm::vec3 m_position, glm::vec3 color = { 1.0f, 1.0f, 1.0f }, float radius = 50.0f);
PointLight() = default;
diff --git a/include/Material.h b/include/Material.h
deleted file mode 100644
index 61dc43d..0000000
--- a/include/Material.h
+++ /dev/null
@@ -1,49 +0,0 @@
-#pragma once
-#include
-#include "Texture.h"
-#include "ConstrainedMap.h"
-namespace fpr
-{
-enum class ETextureType
-{
- ETT_Diffuse,
- ETT_Unlit,
- ETT_AmbientOcclusion,
- ETT_BaseColor,
- ETT_DiffuseRoughness,
- ETT_Displacement,
- ETT_EmissionColor,
- ETT_Emissive,
- ETT_Height,
- ETT_Lightmap,
- ETT_Metalness,
- ETT_Normals,
- ETT_NormalCamera,
- ETT_Opacity,
- ETT_Reflection,
- ETT_Shininess,
- ETT_Specular,
- ETT_Unknown,
- ETT_MetallicRoughness
-};
-enum class EAlphaMode
-{
- EAM_MASK,
- EAM_OPAQUE
-};
-
-class Material
-{
- std::string m_name;
-public:
- ConstrainedMap> Textures;
- Material();
-};
-
-class gltfPBRMaterial : public fpr::Material
-{
- EAlphaMode m_alpha_mode;
- float m_base_color_factor;
-};
-
-} // namespace fpr
diff --git a/include/Model.h b/include/Model.h
index 9f1be76..8d6b798 100644
--- a/include/Model.h
+++ b/include/Model.h
@@ -4,6 +4,7 @@
namespace fpr
{
+ //Helper struct to pass on primitive data to construct meshes and buffers.
struct ModelPrimitives
{
std::vector vertices;
diff --git a/Forward Plus Renderer.vcxproj b/Forward Plus Renderer.vcxproj
index db3a3af..2eae8d7 100644
--- a/Forward Plus Renderer.vcxproj
+++ b/Forward Plus Renderer.vcxproj
@@ -170,6 +170,7 @@
true
MultiThreadedDebugDLL
+ OldStyle
Console
@@ -228,6 +229,7 @@
+
false
@@ -279,15 +281,14 @@
-
+
-
diff --git a/Forward Plus Renderer.vcxproj.filters b/Forward Plus Renderer.vcxproj.filters
index 4615c5f..7a63d94 100644
--- a/Forward Plus Renderer.vcxproj.filters
+++ b/Forward Plus Renderer.vcxproj.filters
@@ -45,6 +45,7 @@
Resource Files\Shaders
+
@@ -139,9 +140,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -166,9 +164,6 @@
Header Files\Buffers
-
- Header Files
-
Header Files
@@ -181,5 +176,8 @@
Header Files
+
+ Header Files
+
\ No newline at end of file
diff --git a/cpp.hint b/cpp.hint
new file mode 100644
index 0000000..76fb673
--- /dev/null
+++ b/cpp.hint
@@ -0,0 +1,4 @@
+// Hint files help the Visual Studio IDE interpret Visual C++ identifiers
+// such as names of functions and macros.
+// For more information see https://go.microsoft.com/fwlink/?linkid=865984
+#define FPR_NOEXCEPT
diff --git a/include/Buffer/Buffer.h b/include/Buffer/Buffer.h
index 8bb66d7..8bff9cb 100644
--- a/include/Buffer/Buffer.h
+++ b/include/Buffer/Buffer.h
@@ -22,8 +22,6 @@
Buffer operator=(const Buffer& other) = delete;
- Buffer(const Buffer& other) = delete;
- //Buffer(Buffer&& other) FPR_NOEXCEPT;
virtual void Transfer(Buffer* other);
void Update(const void* new_data);
diff --git a/include/Buffer/DepthBuffer.h b/include/Buffer/DepthBuffer.h
index b56fb62..28a4919 100644
--- a/include/Buffer/DepthBuffer.h
+++ b/include/Buffer/DepthBuffer.h
@@ -20,6 +20,8 @@
vk::FormatFeatureFlagBits::eDepthStencilAttachment;
vk::Format QueryBestFormat(fpr::Device* device);
+
+
public:
DepthBuffer(fpr::Device* device, fpr::SwapChain* swapchain, vk::ImageTiling tiling = vk::ImageTiling::eOptimal);
@@ -34,9 +36,12 @@
vk::ImageTiling tiling,
vk::FormatFeatureFlags required_flags);
- static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = { vk::Format::eD32SfloatS8Uint,
- vk::Format::eD16Unorm,
- vk::Format::eD24UnormS8Uint };
+ static constexpr std::array DEPTH_BUFFER_IMAGE_FORMATS = {
+ vk::Format::eD32SfloatS8Uint,
+ vk::Format::eD24UnormS8Uint,
+
+
+ };
DepthBuffer(const DepthBuffer& other) = delete;
DepthBuffer(const DepthBuffer&& other) = delete;
diff --git a/include/Camera.h b/include/Camera.h
index 89f93d9..664387b 100644
--- a/include/Camera.h
+++ b/include/Camera.h
@@ -21,8 +21,8 @@
glm::vec3 position = { 0.0f, 0, 0.0f },
glm::quat rotation = { 1.0f, 0.0f, 0.0f, 0.0f },
float FOV = 60.0f,
- float near = 1.5f,
- float far = 100000.0f);
+ float near = 1.0f,
+ float far = 10000);
void Update();
diff --git a/include/ConstrainedMap.h b/include/ConstrainedMap.h
index afb91bb..c09f595 100644
--- a/include/ConstrainedMap.h
+++ b/include/ConstrainedMap.h
@@ -1,17 +1,21 @@
#pragma once
#include
+
+//Concept constraining a type to have a .get() method.
template
concept unique_handle = requires
{
{ std::declval().get() }; //-> std::same_as())>;
};
+
template
struct unique_handle_type
{
using type = T;
};
+//Requires a type to have a ::element_type alias.
template
requires unique_handle
struct unique_handle_type
@@ -19,12 +23,14 @@
using type = T::element_type;
};
+//Not every type has a pointer that is functionally equivalent, i.e file handles.
template
struct unique_handle_type>
{
using type = std::unique_ptr::pointer;
};
+//Requires that std::hash overload is provided for the given type.
template
concept Hashable = requires(T a)
{
@@ -36,39 +42,47 @@
template
class ConstrainedMap
{
+ //Type aliases
using map_type = typename std::unordered_map;
using iterator = typename map_type::iterator;
using mapped_type = typename map_type::mapped_type;
using handle_element_type = typename unique_handle_type