diff --git a/README.md b/README.md
index 2ddb20f0..ac635f86 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,109 @@
-# Procedural-Ray-Tracing
-Repository for our Procedural Ray Tracing project, made by Y3 students at Breda University of Applied Science (former NHTV)
-More information: [Wiki](https://teamwisp.github.io/)
+# [ WispRenderer](https://teamwisp.github.io) - Real-Time Raytracing Renderer
+
+[![Release](https://img.shields.io/github/release/TeamWisp/WispRenderer.svg)](https://github.com/TeamWisp/WispRenderer/releases)
+[![Issues](https://img.shields.io/github/issues/TeamWisp/WispRenderer.svg)](https://github.com/TeamWisp/WispRenderer/issues)
+[![License](https://img.shields.io/badge/license-EPL%202.0-red.svg)](https://opensource.org/licenses/EPL-2.0)
+[![Discord](https://img.shields.io/discord/486967125504688128.svg?color=blueviolet&label=Discord)](https://discord.gg/Q3vDfqR)
+[![Twitter](https://img.shields.io/twitter/follow/wisprenderer.svg?style=social)](https://twitter.com/wisprenderer)
+![](https://img.shields.io/github/stars/TeamWisp/WispRenderer.svg?style=social)
+
+## [What is it?](https://teamwisp.github.io/product/)
+
+Wisp is a general purpose high level rendering library. Specially made for real time raytracing with NVIDIA RTX graphics cards. Made by a group of students from [Breda University of Applied Sciences](https://www.buas.nl/) specializing in graphics programming.
+
+**Features**
+
+* Physically Based Rendering
+* Ray Traced Global Illumination
+* Path Traced Global Illumination
+* Ray Traced Ambient Occlusion
+* Ray Traced Reflections
+* Ray Traced Shadows
+* Translucency & Transparency.
+* NVIDIA's HBAO+
+* NVIDIA's AnselSDK
+
+**Suprted Rendering Backends**
+
+* DirectX 12
+
+**Supported Platforms**
+
+* Windows 10 (Version 1903)
+
+**Supported Compilers**
+
+* Visual Studio 2017
+* Visual Studio 2019
+
+
+## [Installation](https://teamwisp.github.io/workspace_setup/)
+
+### Installer
+
+```
+git clone https://github.com/TeamWisp/WispRenderer.git
+```
+
+Then run `installer.exe` located in the new `WispRenderer` folder and follow the on-screen prompts. When finished you can find the `.sln` file in the `build_vs2019_win64` folder.
+
+
+### Manual
+
+```
+git clone https://github.com/TeamWisp/WispRenderer.git
+cd WispRenderer
+mkdir build
+cd build
+cmake -G "Visual Studio 16 2019" ..
+```
+
+Now you can run the `.sln` file inside the `build` folder. Want to use NVIDIA Gameworks? See the [advanced documation](https://teamwisp.github.io/workspace_setup/).
+
+# [Documentation](https://teamwisp.github.io/)
+
+# [Example](https://github.com/TeamWisp/WispRenderer/tree/master/demo)
+
+# [Getting Involved](https://teamwisp.github.io/)
+
+Want to help us out? That's definatly possible! Check out our [contribution page](https://teamwisp.github.io/) on how.
+
+# [Development Blog](https://teamwisp.github.io/WispBlog/)
+
+# [Discord](https://discord.gg/Q3vDfqR)
+
+Need help, want to get updates as soon as they happen or just want a chat? Join our [Discord Server](https://discord.gg/Q3vDfqR)!
+
+## Trailer
+
+
+
+## Media
+
+
+
+## [License (Eclipse Public License version 2.0)](https://opensource.org/licenses/EPL-2.0)
+
+
+
+
+
+```
+Copyright 2018-2019 Breda University of Applied Sciences
+
+If a Contributor Distributes the Program in any form, then:
+ a) the Program must also be made available as Source Code, in accordance with section 3.2, and the Contributor must accompany the Program with a statement that the Source Code for the Program is available under this Agreement, and informs Recipients how to obtain it in a reasonable manner on or through a medium customarily used for software exchange; and
+ b) the Contributor may Distribute the Program under a license different than this Agreement, provided that such license:
+ i) effectively disclaims on behalf of all other Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
+ ii) effectively excludes on behalf of all other Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
+ iii) does not attempt to limit or alter the recipients' rights in the Source Code under section 3.2; and
+ iv) requires any subsequent distribution of the Program by any party to be under a license that satisfies the requirements of this section 3.
+
+When the Program is Distributed as Source Code:
+ a) it must be made available under this Agreement, or if the Program (i) is combined with other material in a separate file or files made available under a Secondary License, and (ii) the initial Contributor attached to the Source Code the notice described in Exhibit A of this Agreement, then the Program may be made available under the terms of such Secondary Licenses, and
+ b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright, patent, trademark, attribution notices, disclaimers of warranty, or limitations of liability (‘notices’) contained within the Program from any copy of the Program which they Distribute, provided that Contributors may add their own appropriate notices.
+```
diff --git a/demo/debug_camera.hpp b/demo/debug_camera.hpp
index 5abc7c6d..a12c46e6 100644
--- a/demo/debug_camera.hpp
+++ b/demo/debug_camera.hpp
@@ -8,7 +8,7 @@ class DebugCamera : public wr::CameraNode
{
public:
DebugCamera(float fov, float aspect_ratio)
- : wr::CameraNode(fov, aspect_ratio), m_forward_axis(0), m_right_axis(0), m_up_axis(0), m_rmb_down(false), m_speed(1), m_sensitivity(0.01), m_position_lerp_speed(10.f), m_rotation_lerp_speed(5.f)
+ : wr::CameraNode(aspect_ratio), m_forward_axis(0), m_right_axis(0), m_up_axis(0), m_rmb_down(false), m_speed(1), m_sensitivity(0.01), m_position_lerp_speed(10.f), m_rotation_lerp_speed(5.f)
{
GetCursorPos(&m_last_cursor_pos);
m_target_rotation_radians = m_rotation_radians;
@@ -16,7 +16,7 @@ class DebugCamera : public wr::CameraNode
}
//Takes roll, pitch and yaw and converts it to quaternion
- virtual void SetRotation(DirectX::XMVECTOR roll_pitch_yaw) override
+ void SetRotation(DirectX::XMVECTOR roll_pitch_yaw) override
{
m_rotation_radians = roll_pitch_yaw;
m_use_quaternion = false;
@@ -24,7 +24,7 @@ class DebugCamera : public wr::CameraNode
}
//Sets position
- virtual void SetPosition(DirectX::XMVECTOR position) override
+ void SetPosition(DirectX::XMVECTOR position) override
{
m_position = position;
m_target_position = position;
@@ -61,7 +61,7 @@ class DebugCamera : public wr::CameraNode
m_target_position = DirectX::XMVectorAdd(m_target_position, DirectX::XMVectorScale(right, delta * m_speed * m_right_axis));
// Rotation
- DirectX::XMVECTOR new_rot{ cursor_pos.y - m_last_cursor_pos.y, cursor_pos.x - m_last_cursor_pos.x };
+ DirectX::XMVECTOR new_rot{ static_cast(cursor_pos.y - m_last_cursor_pos.y), static_cast(cursor_pos.x - m_last_cursor_pos.x) };
SetRotation(DirectX::XMVectorSubtract(m_target_rotation_radians, DirectX::XMVectorScale(new_rot, m_sensitivity)));
}
else
diff --git a/demo/demo.cpp b/demo/demo.cpp
index 9d9336f1..01bdeaa4 100644
--- a/demo/demo.cpp
+++ b/demo/demo.cpp
@@ -25,7 +25,7 @@ void RenderEditor(ImTextureID output)
engine::RenderEngine(output, render_system.get(), scene_graph.get());
}
-void ShaderDirChangeDetected(std::string path, util::FileWatcher::FileStatus status)
+void ShaderDirChangeDetected(std::string const & path, util::FileWatcher::FileStatus status)
{
auto& registry = wr::PipelineRegistry::Get();
auto& rt_registry = wr::RTPipelineRegistry::Get();
@@ -162,14 +162,14 @@ int WispEntry()
render_system->InitSceneGraph(*scene_graph.get());
- fg_manager::Setup(*render_system.get(), &RenderEditor);
+ fg_manager::Setup(*render_system, &RenderEditor);
window->SetResizeCallback([&](std::uint32_t width, std::uint32_t height)
{
render_system->WaitForAllPreviousWork();
render_system->Resize(width, height);
SCENE::camera->SetAspectRatio((float)width / (float)height);
- fg_manager::Resize(*render_system.get(), width, height);
+ fg_manager::Resize(*render_system, width, height);
});
auto file_watcher = new util::FileWatcher("resources/shaders", std::chrono::milliseconds(100));
diff --git a/demo/demo_frame_graphs.hpp b/demo/demo_frame_graphs.hpp
index ef504567..36c8375a 100644
--- a/demo/demo_frame_graphs.hpp
+++ b/demo/demo_frame_graphs.hpp
@@ -29,7 +29,7 @@
namespace fg_manager
{
- enum class PrebuildFrameGraph
+ enum class PrebuildFrameGraph : std::uint32_t
{
DEFERRED = 0,
RT_HYBRID = 1,
@@ -57,7 +57,7 @@ namespace fg_manager
static PrebuildFrameGraph current = fg_manager::PrebuildFrameGraph::DEFERRED;
static std::array frame_graphs = {};
- inline void Setup(wr::RenderSystem& rs, util::Delegate imgui_func)
+ inline void Setup(wr::RenderSystem& rs, util::Delegate const & imgui_func)
{
// Raytracing
{
@@ -240,12 +240,12 @@ namespace fg_manager
inline void Next()
{
- current = (PrebuildFrameGraph)(((int)current + 1) % frame_graphs.size());
+ current = (PrebuildFrameGraph)((static_cast(current) + 1ull) % frame_graphs.size());
}
inline void Prev()
{
- current = (PrebuildFrameGraph)(((int)current - 1) % frame_graphs.size());
+ current = (PrebuildFrameGraph)((static_cast(current) - 1ull) % frame_graphs.size());
}
inline void Set(PrebuildFrameGraph value)
diff --git a/demo/scene_emibl.hpp b/demo/scene_emibl.hpp
index 958d428d..61825284 100644
--- a/demo/scene_emibl.hpp
+++ b/demo/scene_emibl.hpp
@@ -21,7 +21,6 @@ namespace emibl_scene
static wr::Model* cube_model;
static wr::Model* plane_model;
- static wr::Model* test_model;
static wr::Model* material_knob;
static wr::MaterialHandle rusty_metal_material;
@@ -30,18 +29,12 @@ namespace emibl_scene
static wr::TextureHandle equirectangular_environment_map;
- static wr::TextureHandle flat_normal;
-
void CreateResources(wr::RenderSystem* render_system)
{
texture_pool = render_system->CreateTexturePool();
material_pool = render_system->CreateMaterialPool(256);
// Load Texture.
- wr::TextureHandle white = texture_pool->LoadFromFile("resources/materials/white.png", false, true);
- wr::TextureHandle black = texture_pool->LoadFromFile("resources/materials/black.png", false, true);
- flat_normal = texture_pool->LoadFromFile("resources/materials/flat_normal.png", false, true);
-
wr::TextureHandle metal_splotchy_albedo = texture_pool->LoadFromFile("resources/materials/metal-splotchy-albedo.png", true, true);
wr::TextureHandle metal_splotchy_normal = texture_pool->LoadFromFile("resources/materials/metal-splotchy-normal-dx.png", false, true);
wr::TextureHandle metal_splotchy_roughness = texture_pool->LoadFromFile("resources/materials/metal-splotchy-rough.png", false, true);
@@ -232,8 +225,6 @@ namespace emibl_scene
{
{
- test_model = model_pool->LoadWithMaterials(material_pool.get(), texture_pool.get(), "resources/models/xbot.fbx");
-
cube_model = model_pool->Load(material_pool.get(), texture_pool.get(), "resources/models/cube.fbx");
for (auto& m : cube_model->m_meshes)
{
@@ -257,23 +248,18 @@ namespace emibl_scene
model_pool.reset();
texture_pool.reset();
material_pool.reset();
- };
-
+ }
}
static std::shared_ptr camera;
static std::shared_ptr directional_light_node;
- static std::shared_ptr test_model;
- static std::shared_ptr cube_node;
static float t = 0;
- static float lerp_t = 0.0f;
std::shared_ptr models[10];
std::shared_ptr platforms[10];
static DirectX::XMVECTOR camera_start_pos = { 500.0f, 60.0f, 260.0f };
- static DirectX::XMVECTOR camera_end_pos = { -500.0f, 60.0f, 260.0f };
void CreateScene(wr::SceneGraph* scene_graph, wr::Window* window)
@@ -328,10 +314,9 @@ namespace emibl_scene
models[0]->SetPosition({ +500, 0 , 160 });
platforms[0]->SetPosition({ +500, -3 , 160 });
- for (uint32_t i = 0; i < 10; ++i)
+ for (auto& model : models)
{
- //models[i]->SetScale({ 0.5f, 0.5f, 0.5f });
- models[i]->SetRotation({ 90_deg, 0, 0 });
+ model->SetRotation({ 90_deg, 0, 0 });
}
directional_light_node = scene_graph->CreateChild(nullptr, wr::LightType::DIRECTIONAL, DirectX::XMVECTOR{ 0, 1, 0 });
@@ -340,36 +325,12 @@ namespace emibl_scene
void UpdateScene()
{
- static float waiting = 0.0f;
- static bool start_lerp = false;
-
float deltaTime = ImGui::GetIO().DeltaTime;
- //waiting += deltaTime;
-
- //if (waiting > 20.0f)
- //{
- // start_lerp = true;
- //}
-
- //t += 5.f * deltaTime;
-
- //if (lerp_t < 1.0f && start_lerp)
- //{
- // lerp_t += deltaTime * 0.05f;
-
- // if (lerp_t > 1.0f)
- // {
- // lerp_t = 1.0f;
- // }
-
- // DirectX::XMVECTOR new_cam_pos = DirectX::XMVectorLerp(camera_start_pos, camera_end_pos, lerp_t);
- // camera->SetPosition(new_cam_pos);
- //}
- for (uint32_t i = 0; i < 10; ++i)
+ for (auto& model : models)
{
- models[i]->SetRotation({ 0, DirectX::XMConvertToRadians(t), 0 });
+ model->SetRotation({ 0, DirectX::XMConvertToRadians(t), 0 });
}
camera->Update(deltaTime);
diff --git a/demo/scene_spheres.hpp b/demo/scene_spheres.hpp
index c19c3eae..a265988f 100644
--- a/demo/scene_spheres.hpp
+++ b/demo/scene_spheres.hpp
@@ -21,7 +21,6 @@ namespace spheres_scene
static std::shared_ptr material_pool;
static wr::Model* sphere_model;
- static wr::Model* test_model;
static wr::TextureHandle equirectangular_environment_map;
@@ -51,8 +50,6 @@ namespace spheres_scene
spheres_material_internal->SetMetallic(spheres_metallic);
// Create Models
- test_model = model_pool->LoadWithMaterials(material_pool.get(), texture_pool.get(), "resources/models/xbot.fbx");
-
sphere_model = model_pool->Load(material_pool.get(), texture_pool.get(), "resources/models/sphere.fbx");
for (auto& m : sphere_model->m_meshes)
{
@@ -71,7 +68,6 @@ namespace spheres_scene
static std::shared_ptr camera;
static std::shared_ptr directional_light_node;
- static std::shared_ptr test_model;
static float t = 0;
diff --git a/demo/spline_node.cpp b/demo/spline_node.cpp
index facd3e1f..4f0e1803 100644
--- a/demo/spline_node.cpp
+++ b/demo/spline_node.cpp
@@ -26,26 +26,10 @@ SplineNode::SplineNode(std::string name, bool looping) : Node(typeid(SplineNode)
[](std::shared_ptr node, wr::SceneGraph* scene_graph) {
auto spline_node = std::static_pointer_cast(node);
- bool animate = spline_node->m_animate;
-
ImGui::Checkbox("Animate", &spline_node->m_animate);
ImGui::DragFloat("Speed", &spline_node->m_speed);
ImGui::DragFloat("Time ", &spline_node->m_time);
- // Started animating
- /*if (spline_node->m_animate && animate != spline_node->m_animate)
- {
- m_initial_position = scene_graph->GetActiveCamera()->m_position;
- m_initial_rotation = scene_graph->GetActiveCamera()->m_rotation_radians;
- }
-
- // Stopped animating
- if (!spline_node->m_animate && animate != spline_node->m_animate)
- {
- scene_graph->GetActiveCamera()->SetPosition(m_initial_position);
- scene_graph->GetActiveCamera()->SetRotation(m_initial_rotation);
- }*/
-
if (ImGui::Button("Save Spline"))
{
auto result = spline_node->SaveDialog();
@@ -78,7 +62,7 @@ SplineNode::SplineNode(std::string name, bool looping) : Node(typeid(SplineNode)
if (ImGui::Button("Add Control Point"))
{
- ControlPoint cp;
+ ControlPoint cp{};
cp.m_position = scene_graph->GetActiveCamera()->m_position;
cp.m_rotation = scene_graph->GetActiveCamera()->m_rotation_radians;
@@ -126,15 +110,13 @@ SplineNode::SplineNode(std::string name, bool looping) : Node(typeid(SplineNode)
SplineNode::~SplineNode()
{
- if (m_spline) delete m_spline;
+ delete m_spline;
}
void SplineNode::UpdateSplineNode(float delta, std::shared_ptr node)
{
if (!m_spline || !m_quat_spline || !m_animate) return; // Don't try to run this code if we don't have a spline.
- auto num_points = m_control_points.size();
-
auto impl = [&](auto spline, auto quat_spline)
{
m_time += delta * m_speed;
@@ -159,17 +141,11 @@ void SplineNode::UpdateSplineNode(float delta, std::shared_ptr node)
void SplineNode::UpdateNaturalSpline()
{
- if (m_spline)
- {
- delete m_spline;
- m_spline = nullptr;
- }
+ delete m_spline;
+ m_spline = nullptr;
- if (m_quat_spline)
- {
- delete m_quat_spline;
- m_quat_spline = nullptr;
- }
+ delete m_quat_spline;
+ m_quat_spline = nullptr;
if (m_control_points.size() < (m_looping ? 2 : 3))
{
@@ -221,16 +197,16 @@ std::optional SplineNode::LoadDialog()
OPENFILENAME dialog_args;
ZeroMemory(&dialog_args, sizeof(dialog_args));
dialog_args.lStructSize = sizeof(OPENFILENAME);
- dialog_args.hwndOwner = NULL;
+ dialog_args.hwndOwner = nullptr;
dialog_args.lpstrFile = buffer;
dialog_args.lpstrFile[0] = '\0';
dialog_args.nMaxFile = sizeof(buffer);
dialog_args.lpstrFilter = "All\0*.*\0Spline\0*.SPL\0";
dialog_args.nFilterIndex = 1;
dialog_args.lpstrTitle = "Load Spline";
- dialog_args.lpstrFileTitle = NULL;
+ dialog_args.lpstrFileTitle = nullptr;
dialog_args.nMaxFileTitle = 0;
- dialog_args.lpstrInitialDir = NULL;
+ dialog_args.lpstrInitialDir = nullptr;
dialog_args.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
bool file_selected = GetOpenFileName(&dialog_args);
@@ -250,16 +226,16 @@ std::optional SplineNode::SaveDialog()
OPENFILENAME dialog_args;
ZeroMemory(&dialog_args, sizeof(dialog_args));
dialog_args.lStructSize = sizeof(OPENFILENAME);
- dialog_args.hwndOwner = NULL;
+ dialog_args.hwndOwner = nullptr;
dialog_args.lpstrFile = buffer;
//dialog_args.lpstrFile[0] = '\0';
dialog_args.nMaxFile = sizeof(buffer);
dialog_args.lpstrFilter = "Spline\0*.SPL\0";
dialog_args.nFilterIndex = 1;
- dialog_args.lpstrFileTitle = NULL;
+ dialog_args.lpstrFileTitle = nullptr;
dialog_args.lpstrTitle = "Save Spline";
dialog_args.nMaxFileTitle = 0;
- dialog_args.lpstrInitialDir = NULL;
+ dialog_args.lpstrInitialDir = nullptr;
dialog_args.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
bool file_selected = GetSaveFileName(&dialog_args);
@@ -308,7 +284,7 @@ void SplineNode::LoadSplineFromFile(std::string const& path)
while (numbers.size() > 5)
{
- ControlPoint cp;
+ ControlPoint cp{};
cp.m_position = { numbers[0], numbers[1], numbers[2] };
cp.m_rotation = { numbers[3], numbers[4], numbers[5] };
m_control_points.push_back(cp);
diff --git a/demo/spline_node.hpp b/demo/spline_node.hpp
index 7e076c24..fe2155b3 100644
--- a/demo/spline_node.hpp
+++ b/demo/spline_node.hpp
@@ -14,7 +14,7 @@ class SplineNode : public wr::Node
};
public:
- SplineNode(std::string name, bool looping = false);
+ explicit SplineNode(std::string name, bool looping = false);
~SplineNode();
void UpdateSplineNode(float delta, std::shared_ptr node);
@@ -22,16 +22,13 @@ class SplineNode : public wr::Node
private:
void UpdateNaturalSpline();
- std::optional LoadDialog();
- std::optional SaveDialog();
+ static std::optional LoadDialog();
+ static std::optional SaveDialog();
void SaveSplineToFile(std::string const & path);
void LoadSplineFromFile(std::string const & path);
bool m_animate;
- DirectX::XMVECTOR m_initial_position;
- DirectX::XMVECTOR m_initial_rotation;
-
void* m_spline;
void* m_quat_spline;
diff --git a/resources/shaders/deferred_composition.hlsl b/resources/shaders/deferred_composition.hlsl
index 20e85bdd..ef0ec313 100644
--- a/resources/shaders/deferred_composition.hlsl
+++ b/resources/shaders/deferred_composition.hlsl
@@ -30,6 +30,7 @@ cbuffer CameraProperties : register(b0)
float4x4 inv_view;
uint is_hybrid;
uint is_path_tracer;
+ uint is_hbao;
};
static uint min_depth = 0xFFFFFFFF;
@@ -77,7 +78,6 @@ void main_cs(int3 dispatch_thread_id : SV_DispatchThreadID)
float irradiance = lerp(
irradiance_map.SampleLevel(linear_sampler, flipped_N, 0).xyz,
screen_space_irradiance[screen_coord].xyz,
- // Lerp factor (0: env map, 1: path traced)
is_path_tracer);
// Get ao
@@ -85,7 +85,7 @@ void main_cs(int3 dispatch_thread_id : SV_DispatchThreadID)
1,
screen_space_ao[screen_coord].xyz,
// Lerp factor (0: env map, 1: path traced)
- true);
+ is_hbao);
// Get shadow factor (0: fully shadowed, 1: no shadow)
float shadow_factor = lerp(
diff --git a/src/d3d12/d3d12_defines.hpp b/src/d3d12/d3d12_defines.hpp
index 21f761c6..6c78f52d 100644
--- a/src/d3d12/d3d12_defines.hpp
+++ b/src/d3d12/d3d12_defines.hpp
@@ -2,6 +2,8 @@
#include "../util/log.hpp"
+#pragma warning(push, 0)
+
#define D3DX12_INC d3dx12_rt.h
//! Checks whether the d3d12 object exists before releasing it.
@@ -34,3 +36,5 @@ constexpr inline T SizeAlignAnyAlignment(T size, A alignment)
{
return (size / alignment + (size%alignment > 0))*alignment;
}
+
+#pragma warning(pop)
diff --git a/src/d3d12/d3d12_renderer.cpp b/src/d3d12/d3d12_renderer.cpp
index 473a4ea5..42470ed9 100644
--- a/src/d3d12/d3d12_renderer.cpp
+++ b/src/d3d12/d3d12_renderer.cpp
@@ -1094,7 +1094,7 @@ namespace wr
LOGC("Nice try boiii! That's not a shape.");
}
- return m_simple_shapes[type];
+ return m_simple_shapes[static_cast(type)];
}
void D3D12RenderSystem::ResetBatches(SceneGraph & sg)
@@ -1152,7 +1152,7 @@ namespace wr
{ -1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
- m_simple_shapes[SimpleShapes::CUBE] = m_shapes_pool->LoadCustom({ mesh });
+ m_simple_shapes[static_cast(SimpleShapes::CUBE)] = m_shapes_pool->LoadCustom({ mesh });
}
{
@@ -1170,7 +1170,7 @@ namespace wr
{ -1, 1, 0, 0, 1, 0, 0, -1, 0, 0, 1, 0, 1, 0, 0, 0, 0 },
};
- m_simple_shapes[SimpleShapes::PLANE] = m_shapes_pool->LoadCustom({ mesh });
+ m_simple_shapes[static_cast(SimpleShapes::PLANE)] = m_shapes_pool->LoadCustom({ mesh });
}
}
diff --git a/src/d3d12/d3d12_renderer.hpp b/src/d3d12/d3d12_renderer.hpp
index 9aa5f3ca..199f7747 100644
--- a/src/d3d12/d3d12_renderer.hpp
+++ b/src/d3d12/d3d12_renderer.hpp
@@ -37,6 +37,7 @@ namespace wr
DirectX::XMMATRIX m_inverse_view;
unsigned int m_is_hybrid;
unsigned int m_is_path_tracer;
+ unsigned int m_is_hbao;
};
struct RTHybridCamera_CBData
diff --git a/src/d3d12/d3d12_resource_pool_texture.cpp b/src/d3d12/d3d12_resource_pool_texture.cpp
index d004a781..1313a821 100644
--- a/src/d3d12/d3d12_resource_pool_texture.cpp
+++ b/src/d3d12/d3d12_resource_pool_texture.cpp
@@ -40,7 +40,7 @@ SOFTWARE.
#include "../d3d12/d3d12_pipeline_registry.hpp"
#include "d3d12_descriptors_allocations.hpp"
-#include "DirectXTex.h"
+#include
#include
@@ -52,6 +52,8 @@ namespace wr
{
auto device = m_render_system.m_device;
+ m_staging_textures.resize(d3d12::settings::num_back_buffers);
+
//Staging heap
for (int i = 0; i < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++i)
{
@@ -181,7 +183,7 @@ namespace wr
GenerateMips(t, cmd_list);
}
- MoveStagedTextures();
+ MoveStagedTextures(m_render_system.GetFrameIdx());
}
}
@@ -215,6 +217,19 @@ namespace wr
d3d12::Destroy(h);
}
+ auto& vec = m_staging_textures[frame_idx];
+
+ for (auto& elem : vec)
+ {
+ auto* tex = (d3d12::TextureResource*) elem.second;
+
+ if(tex->m_intermediate)
+ SAFE_RELEASE(tex->m_intermediate);
+
+ ((d3d12::TextureResource*)m_staged_textures[elem.first])->m_intermediate = nullptr;
+ }
+
+ vec.clear();
m_temporary_heaps[frame_idx].clear();
}
@@ -391,7 +406,9 @@ namespace wr
m_staged_textures.erase(texture_id);
SAFE_RELEASE(texture->m_resource);
- SAFE_RELEASE(texture->m_intermediate);
+
+ if(texture->m_intermediate)
+ SAFE_RELEASE(texture->m_intermediate);
delete texture;
@@ -626,11 +643,12 @@ namespace wr
return handle;
}
- void D3D12TexturePool::MoveStagedTextures()
+ void D3D12TexturePool::MoveStagedTextures(unsigned int frame_idx)
{
for (auto itr = m_unstaged_textures.begin(); itr != m_unstaged_textures.end(); ++itr)
{
m_staged_textures.insert(std::make_pair(itr->first, itr->second.first));
+ m_staging_textures[frame_idx].insert(std::make_pair(itr->first, itr->second.first));
//Free the ScratchImage as it's not needed anymore after staging
delete itr->second.second;
diff --git a/src/d3d12/d3d12_resource_pool_texture.hpp b/src/d3d12/d3d12_resource_pool_texture.hpp
index b1a04415..c4005f06 100644
--- a/src/d3d12/d3d12_resource_pool_texture.hpp
+++ b/src/d3d12/d3d12_resource_pool_texture.hpp
@@ -75,7 +75,7 @@ namespace wr
protected:
- void MoveStagedTextures();
+ void MoveStagedTextures(unsigned int frame_idx);
void GenerateMips(d3d12::TextureResource* texture, CommandList* cmd_list);
void GenerateMips_UAV(d3d12::TextureResource* texture, CommandList* cmd_list);
@@ -89,6 +89,7 @@ namespace wr
using StagedTextures = std::unordered_map;
StagedTextures m_staged_textures;
+ std::vector m_staging_textures;
D3D12RenderSystem& m_render_system;
diff --git a/src/d3d12/d3d12_structs.hpp b/src/d3d12/d3d12_structs.hpp
index a3c8c628..3288b418 100644
--- a/src/d3d12/d3d12_structs.hpp
+++ b/src/d3d12/d3d12_structs.hpp
@@ -47,15 +47,15 @@ namespace wr::d3d12
struct TextureDesc
{
ResourceState m_initial_state = ResourceState::COPY_DEST;
- Format m_texture_format;
+ Format m_texture_format = Format::UNKNOWN;
- unsigned int m_width;
- unsigned int m_height;
- unsigned int m_depth;
- unsigned int m_array_size;
- unsigned int m_mip_levels;
+ unsigned int m_width = 0;
+ unsigned int m_height = 0;;
+ unsigned int m_depth = 0;;
+ unsigned int m_array_size = 0;;
+ unsigned int m_mip_levels = 0;;
- bool m_is_cubemap;
+ bool m_is_cubemap = false;
};
struct ReadbackDesc
@@ -97,23 +97,23 @@ namespace wr::d3d12
struct DescriptorHeapDesc
{
- unsigned int m_num_descriptors;
- DescriptorHeapType m_type;
+ unsigned int m_num_descriptors = 1;
+ DescriptorHeapType m_type = DescriptorHeapType::DESC_HEAP_TYPE_CBV_SRV_UAV;
bool m_shader_visible = true;
uint32_t m_versions = 1;
};
struct GeometryDesc
{
- StagingBuffer* vertex_buffer;
+ StagingBuffer* vertex_buffer = nullptr;
std::optional index_buffer;
- std::uint64_t m_num_vertices;
- std::uint64_t m_num_indices;
- std::uint64_t m_vertices_offset;
- std::uint64_t m_indices_offset;
+ std::uint64_t m_num_vertices = 0;
+ std::uint64_t m_num_indices = 0;
+ std::uint64_t m_vertices_offset = 0;
+ std::uint64_t m_indices_offset = 0;
- std::uint64_t m_vertex_stride;
+ std::uint64_t m_vertex_stride = 0;
};
struct StateObjectDesc
diff --git a/src/d3d12/d3d12_texture_resources.hpp b/src/d3d12/d3d12_texture_resources.hpp
index 225fa441..a8c32aa8 100644
--- a/src/d3d12/d3d12_texture_resources.hpp
+++ b/src/d3d12/d3d12_texture_resources.hpp
@@ -7,7 +7,7 @@
#include "d3d12_descriptors_allocations.hpp"
-#include "DirectXTex.h"
+#include
namespace wr::d3d12
{
diff --git a/src/d3d12/d3dx12.hpp b/src/d3d12/d3dx12.hpp
index 865e7977..f6d7ff5d 100644
--- a/src/d3d12/d3dx12.hpp
+++ b/src/d3d12/d3dx12.hpp
@@ -12,6 +12,8 @@
#ifndef __D3DX12_H__
#define __D3DX12_H__
+#pragma warning(push, 0)
+
#include "d3d12.h"
#if defined( __cplusplus )
@@ -3446,6 +3448,8 @@ class CD3DX12_NODE_MASK_SUBOBJECT
#endif // defined( __cplusplus )
+#pragma warning(pop)
+
#endif //__D3DX12_H__
diff --git a/src/engine_registry.cpp b/src/engine_registry.cpp
index b63cb606..79e73341 100644
--- a/src/engine_registry.cpp
+++ b/src/engine_registry.cpp
@@ -18,8 +18,6 @@
#define DESC_RANGE_H(...) [] { CD3DX12_DESCRIPTOR_RANGE r; r.Init(__VA_ARGS__); return r; }()
// Root parameter
#define ROOT_PARAM(func) [] { return func; }()
-// Root paramter hard coded
-#define ROOT_PARAM_H(func) [] { CD3DX12_ROOT_PARAMETER d; d.func; return d; }()
// Root Parameter for descriptor tables
#define ROOT_PARAM_DESC_TABLE(arr, visibility) [] { CD3DX12_ROOT_PARAMETER d; d.InitAsDescriptorTable(arr.size(), arr.data(), visibility); return d; }()
diff --git a/src/engine_registry.hpp b/src/engine_registry.hpp
index da6e2809..10c27681 100644
--- a/src/engine_registry.hpp
+++ b/src/engine_registry.hpp
@@ -108,7 +108,7 @@ namespace wr
unsigned int size = 0;
// Find its range equivelant or visa versa
- Type other_type = Type::SRV;
+ Type other_type = Type::SRV;
switch (type)
{
case Type::SRV:
@@ -171,9 +171,7 @@ namespace wr
template
constexpr CD3DX12_ROOT_PARAMETER GetCBV(const T data, const E name, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
- const Type type = Type::CBV_OR_CONST;
unsigned int start = 0;
- unsigned int size = 0;
// Find Start & Size
for (std::size_t i = 0; i < data.size(); i++)
@@ -181,7 +179,6 @@ namespace wr
auto entry = data[i];
if (static_cast(entry.name) == name)
{
- size = entry.size;
break;
}
else if (entry.type == Type::CBV_OR_CONST || entry.type == Type::CBV_RANGE)
@@ -200,7 +197,6 @@ namespace wr
constexpr CD3DX12_ROOT_PARAMETER GetSRV(const T data, const E name, D3D12_SHADER_VISIBILITY visibility = D3D12_SHADER_VISIBILITY_ALL)
{
unsigned int start = 0;
- unsigned int size = 0;
// Find Start & Size
for (std::size_t i = 0; i < data.size(); i++)
@@ -208,7 +204,6 @@ namespace wr
auto entry = data[i];
if (static_cast(entry.name) == name)
{
- size = entry.size;
break;
}
else if (entry.type == Type::SRV || entry.type == Type::SRV_RANGE)
diff --git a/src/entry.hpp b/src/entry.hpp
index e5153ad0..80bd4402 100644
--- a/src/entry.hpp
+++ b/src/entry.hpp
@@ -1,11 +1,11 @@
#pragma once
-#define WISP_ENTRY(func) \
-int main() \
-{ \
- return func(); \
-} \
-int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int) \
-{ \
- return main(); \
+#define WISP_ENTRY(func) \
+int main() \
+{ \
+ return func(); \
+} \
+int CALLBACK WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int) \
+{ \
+ return main(); \
}
\ No newline at end of file
diff --git a/src/frame_graph/frame_graph.hpp b/src/frame_graph/frame_graph.hpp
index 12edd1f4..2bbb910a 100644
--- a/src/frame_graph/frame_graph.hpp
+++ b/src/frame_graph/frame_graph.hpp
@@ -69,7 +69,7 @@ namespace wr
using destroy_func_t = util::Delegate;
/*! The type of the render task.*/
- RenderTaskType m_type;
+ RenderTaskType m_type = RenderTaskType::DIRECT;
/*! The function pointers for the task.*/
setup_func_t m_setup_func;
execute_func_t m_execute_func;
@@ -78,7 +78,7 @@ namespace wr
/*! The properties for the render target this task renders to. If this is `std::nullopt` no render target will be created. */
std::optional m_properties;
- bool m_allow_multithreading;
+ bool m_allow_multithreading = true;
};
//! Frame Graph
@@ -257,8 +257,8 @@ namespace wr
if (!m_rt_properties[i].value().m_is_render_window)
{
render_system.ResizeRenderTarget(&m_render_targets[i],
- width * m_rt_properties[i].value().m_resolution_scale.Get(),
- height * m_rt_properties[i].value().m_resolution_scale.Get());
+ static_cast(width * m_rt_properties[i].value().m_resolution_scale.Get()),
+ static_cast(height * m_rt_properties[i].value().m_resolution_scale.Get()));
}
m_setup_funcs[i](render_system, *this, i, true);
@@ -395,7 +395,7 @@ namespace wr
}
}
- LOGC("Failed to find predecessor data! Please check your task order.");
+ LOGC("Failed to find predecessor data! Please check your task order.")
return *static_cast(nullptr);
}
@@ -583,7 +583,7 @@ namespace wr
#ifndef FG_MAX_PERFORMANCE
m_dependencies.emplace_back(dependencies);
#endif
- m_settings.resize(m_num_tasks + 1);
+ m_settings.resize(m_num_tasks + 1ull);
m_types.emplace_back(desc.m_type);
m_rt_properties.emplace_back(desc.m_properties);
m_data.emplace_back(new (std::nothrow) T());
@@ -624,7 +624,7 @@ namespace wr
{
case wr::CPUTextureType::PIXEL_DATA:
if (m_output_cpu_textures.pixel_data != std::nullopt)
- LOGW("Warning: CPU texture pixel data is written to more than once a frame!");
+ LOGW("Warning: CPU texture pixel data is written to more than once a frame!")
// Save the pixel data
m_output_cpu_textures.pixel_data = output_texture;
@@ -632,7 +632,7 @@ namespace wr
case wr::CPUTextureType::DEPTH_DATA:
if (m_output_cpu_textures.depth_data != std::nullopt)
- LOGW("Warning: CPU texture depth data is written to more than once a frame!");
+ LOGW("Warning: CPU texture depth data is written to more than once a frame!")
// Save the depth data
m_output_cpu_textures.depth_data = output_texture;
@@ -640,7 +640,7 @@ namespace wr
default:
// Should never happen
- LOGC("Invalid CPU texture type supplied!");
+ LOGC("Invalid CPU texture type supplied!")
break;
}
}
@@ -809,7 +809,7 @@ namespace wr
/*! Get a free unique ID. */
WISPRENDERER_EXPORT static std::uint64_t GetFreeUID()
{
- if (m_free_uids.size() > 0)
+ if (!m_free_uids.empty())
{
std::uint64_t uid = m_free_uids.top();
m_free_uids.pop();
diff --git a/src/id_factory.cpp b/src/id_factory.cpp
index 8cd17015..ff73c9f0 100644
--- a/src/id_factory.cpp
+++ b/src/id_factory.cpp
@@ -2,6 +2,7 @@
namespace wr
{
+
IDFactory::IDFactory()
: m_id(0)
{
@@ -30,6 +31,4 @@ namespace wr
return ret_id;
}
-
-
-}
\ No newline at end of file
+} /* wr */
\ No newline at end of file
diff --git a/src/id_factory.hpp b/src/id_factory.hpp
index 7b77a830..242c8a98 100644
--- a/src/id_factory.hpp
+++ b/src/id_factory.hpp
@@ -4,6 +4,7 @@
namespace wr
{
+
class IDFactory
{
public:
@@ -24,4 +25,5 @@ namespace wr
std::uint64_t m_id;
std::vector m_unused_ids;
};
-}
\ No newline at end of file
+
+} /* wr */
\ No newline at end of file
diff --git a/src/imgui/imgui.hpp b/src/imgui/imgui.hpp
index c82bc581..d529ba58 100644
--- a/src/imgui/imgui.hpp
+++ b/src/imgui/imgui.hpp
@@ -28,6 +28,8 @@ Index of this file:
#pragma once
+#pragma warning(push, 0)
+
// Configuration file with compile-time options (edit imconfig.h or define IMGUI_USER_CONFIG to your own filename)
#ifdef IMGUI_USER_CONFIG
#include IMGUI_USER_CONFIG
@@ -2387,5 +2389,7 @@ struct ImGuiViewport
// Include imgui_user.h at the end of imgui.h (convenient for user to only explicitly include vanilla imgui.h)
#ifdef IMGUI_INCLUDE_IMGUI_USER_H
-#include "imgui_user.h"
+#include "imgui_user.hpp"
#endif
+
+#pragma warning(pop)
\ No newline at end of file
diff --git a/src/model_pool.hpp b/src/model_pool.hpp
index 0dce4591..67b70b46 100644
--- a/src/model_pool.hpp
+++ b/src/model_pool.hpp
@@ -309,10 +309,8 @@ namespace wr
return texture_pool->LoadFromRawMemory(texture->m_data.data(), texture->m_width, texture->m_height, true, true);
}
}
- else if (texture_location == TextureLocation::EXTERNAL)
- {
- return texture_pool->LoadFromFile(dir + material_texture, true, true);
- }
+
+ return texture_pool->LoadFromFile(dir + material_texture, true, true);
};
if (material->m_albedo_texture_location!=TextureLocation::NON_EXISTENT)
diff --git a/src/platform_independend_structs.hpp b/src/platform_independend_structs.hpp
index 7b66faaa..df66f006 100644
--- a/src/platform_independend_structs.hpp
+++ b/src/platform_independend_structs.hpp
@@ -48,7 +48,7 @@ namespace wr
enum class LightType : int
{
- POINT, DIRECTIONAL, SPOT, FREE /* MAX LighType value; but unused */
+ POINT, DIRECTIONAL, SPOT, FREE
};
struct Light
diff --git a/src/render_tasks/d3d12_accumulation.hpp b/src/render_tasks/d3d12_accumulation.hpp
index 89b6d23a..aed76187 100644
--- a/src/render_tasks/d3d12_accumulation.hpp
+++ b/src/render_tasks/d3d12_accumulation.hpp
@@ -11,11 +11,10 @@ namespace wr
{
struct AccumulationData
{
- d3d12::RenderTarget* out_source_rt;
- d3d12::PipelineState* out_pipeline;
- ID3D12Resource* out_previous;
+ d3d12::RenderTarget* out_source_rt = nullptr;
+ d3d12::PipelineState* out_pipeline = nullptr;
- DescriptorAllocator* out_allocator;
+ DescriptorAllocator* out_allocator = nullptr;
DescriptorAllocation out_allocation;
};
@@ -66,10 +65,8 @@ namespace wr
auto& n_render_system = static_cast(rs);
auto& device = n_render_system.m_device;
auto& data = fg.GetData(handle);
- auto n_render_target = fg.GetRenderTarget(handle);
auto frame_idx = n_render_system.GetFrameIdx();
auto cmd_list = fg.GetCommandList(handle);
- const auto viewport = n_render_system.m_viewport;
d3d12::BindComputePipeline(cmd_list, data.out_pipeline);
@@ -84,8 +81,6 @@ namespace wr
bool is_fallback = d3d12::GetRaytracingType(device) == RaytracingType::FALLBACK;
d3d12::BindDescriptorHeaps(cmd_list, frame_idx, is_fallback);
- //cmd_list->m_dynamic_descriptor_heaps[D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV]->StageDescriptors(0, 0, 2, data.out_allocation.GetDescriptorHandle());
-
cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(data.out_source_rt->m_render_targets[frame_idx % 1 /*versions*/]));
auto& path_tracer_data = fg.GetPredecessorData();
diff --git a/src/render_tasks/d3d12_ansel.hpp b/src/render_tasks/d3d12_ansel.hpp
index d14107b4..91eabe78 100644
--- a/src/render_tasks/d3d12_ansel.hpp
+++ b/src/render_tasks/d3d12_ansel.hpp
@@ -41,7 +41,7 @@ namespace wr
struct AnselData
{
- bool out_ansel_support;
+ bool out_ansel_support = false;
#ifdef NVIDIA_GAMEWORKS_ANSEL
std::optional out_original_camera; // Used to restore the camera to the original settings when exiting Ansel.
#endif
@@ -93,11 +93,11 @@ namespace wr
}
- ansel::Camera NativeToAnselCamera(std::shared_ptr const camera)
+ ansel::Camera NativeToAnselCamera(std::shared_ptr const & camera)
{
auto proj_offset = camera->GetProjectionOffset();
- ansel::Camera ansel_camera;
+ ansel::Camera ansel_camera{};
ansel_camera.aspectRatio = camera->m_aspect_ratio;
ansel_camera.fov = DirectX::XMConvertToDegrees(camera->m_fov.m_fov);
ansel_camera.position = { camera->m_position.m128_f32[0], camera->m_position.m128_f32[1], camera->m_position.m128_f32[2] };
@@ -110,7 +110,7 @@ namespace wr
return ansel_camera;
}
- void AnselToNativeCamera(ansel::Camera const & ansel_camera, std::shared_ptr camera)
+ void AnselToNativeCamera(ansel::Camera const & ansel_camera, std::shared_ptr & camera)
{
camera->SetProjectionOffset(ansel_camera.projectionOffsetX, ansel_camera.projectionOffsetY);
camera->SetPosition({ ansel_camera.position.x, ansel_camera.position.y, ansel_camera.position.z });
@@ -130,9 +130,7 @@ namespace wr
}
auto& n_render_system = static_cast(rs);
- auto n_device = n_render_system.m_device;
auto& data = fg.GetData(handle);
- auto n_render_target = fg.GetRenderTarget(handle);
ansel_settings = fg.GetSettings(handle);
if (!n_render_system.m_window.has_value())
diff --git a/src/render_tasks/d3d12_brdf_lut_precalculation.hpp b/src/render_tasks/d3d12_brdf_lut_precalculation.hpp
index 00749994..6f219db2 100644
--- a/src/render_tasks/d3d12_brdf_lut_precalculation.hpp
+++ b/src/render_tasks/d3d12_brdf_lut_precalculation.hpp
@@ -50,11 +50,10 @@ namespace wr
if (!n_render_system.m_brdf_lut_generated)
{
auto cmd_list = fg.GetCommandList(handle);
- auto render_target = fg.GetRenderTarget(handle);
d3d12::BindComputePipeline(cmd_list, data.in_pipeline->m_native);
- d3d12::TextureResource* brdf_lut = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
+ auto* brdf_lut = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
d3d12::Transition(cmd_list, brdf_lut, ResourceState::COPY_DEST, ResourceState::UNORDERED_ACCESS);
diff --git a/src/render_tasks/d3d12_build_acceleration_structures.hpp b/src/render_tasks/d3d12_build_acceleration_structures.hpp
index 33d520cc..7829c1f6 100644
--- a/src/render_tasks/d3d12_build_acceleration_structures.hpp
+++ b/src/render_tasks/d3d12_build_acceleration_structures.hpp
@@ -7,7 +7,6 @@
#include "../d3d12/d3d12_rt_descriptor_heap.hpp"
#include "../frame_graph/frame_graph.hpp"
#include "../engine_registry.hpp"
-#include "../util/math.hpp"
#include "../render_tasks/d3d12_deferred_main.hpp"
#include "../imgui_tools.hpp"
@@ -16,14 +15,14 @@ namespace wr
{
struct ASBuildData
{
- DescriptorAllocator* out_allocator;
+ DescriptorAllocator* out_allocator = nullptr;
DescriptorAllocation out_scene_ib_alloc;
DescriptorAllocation out_scene_mat_alloc;
DescriptorAllocation out_scene_offset_alloc;
- d3d12::AccelerationStructure out_tlas;
- D3D12StructuredBufferHandle* out_sb_material_handle;
- D3D12StructuredBufferHandle* out_sb_offset_handle;
+ d3d12::AccelerationStructure out_tlas = {};
+ D3D12StructuredBufferHandle* out_sb_material_handle = nullptr;
+ D3D12StructuredBufferHandle* out_sb_offset_handle = nullptr;
std::vector> out_blas_list;
std::vector out_materials;
std::vector out_offsets;
@@ -37,11 +36,11 @@ namespace wr
std::vector> old_blasses;
std::vector old_tlas;
- unsigned int previous_frame_index;
- unsigned int current_frame_index;
+ unsigned int previous_frame_index = 0;
+ unsigned int current_frame_index = 0;
- bool out_init;
- bool out_materials_require_update;
+ bool out_init = true;
+ bool out_materials_require_update = true;
};
namespace internal
@@ -104,9 +103,6 @@ namespace wr
material.roughness_id = material_internal->GetRoughness().m_id;
material.metallicness_id = material_internal->GetMetallic().m_id;
material.material_data = material_internal->GetMaterialData();
- int x = sizeof(wr::temp::RayTracingMaterial_CBData);
- int y = sizeof(DirectX::XMVECTOR);
- int z = sizeof(Material::MaterialData);
data.out_materials.push_back(material);
data.out_parsed_materials[material_handle.m_id] = material_id;
@@ -124,7 +120,7 @@ namespace wr
inline void AppendOffset(ASBuildData& data, wr::internal::D3D12MeshInternal* mesh, unsigned int material_id)
{
wr::temp::RayTracingOffset_CBData offset;
- offset.material_idx = material_id;
+ offset.material_idx = static_cast(material_id);
offset.idx_offset = mesh->m_index_staging_buffer_offset;
offset.vertex_offset = mesh->m_vertex_staging_buffer_offset;
data.out_offsets.push_back(offset);
diff --git a/src/render_tasks/d3d12_cubemap_convolution.hpp b/src/render_tasks/d3d12_cubemap_convolution.hpp
index bfb98353..585f5901 100644
--- a/src/render_tasks/d3d12_cubemap_convolution.hpp
+++ b/src/render_tasks/d3d12_cubemap_convolution.hpp
@@ -21,17 +21,16 @@ namespace wr
{
struct CubemapConvolutionTaskData
{
- D3D12Pipeline* in_pipeline;
+ D3D12Pipeline* in_pipeline = nullptr;
- TextureHandle in_radiance;
- TextureHandle out_irradiance;
- TextureHandle out_pref_env_map;
+ TextureHandle in_radiance = {};
+ TextureHandle out_irradiance = {};
std::shared_ptr camera_cb_pool;
D3D12ConstantBufferHandle* cb_handle;
- DirectX::XMMATRIX proj_mat;
- DirectX::XMMATRIX view_mat[6];
+ DirectX::XMMATRIX proj_mat = { DirectX::XMMatrixIdentity() };
+ DirectX::XMMATRIX view_mat[6] = { };
bool should_run = true;
};
@@ -103,7 +102,6 @@ namespace wr
}
data.in_radiance = pred_data.out_cubemap;
- data.out_pref_env_map = pred_data.out_pref_env;
skybox_node->m_irradiance = skybox_node->m_skybox.value().m_pool->CreateCubemap("ConvolutedMap", 128, 128, 1, wr::Format::R32G32B32A32_FLOAT, true);;
@@ -187,14 +185,6 @@ namespace wr
//if (data.should_run)
}
- inline void DestroyCubemapConvolutionTask(FrameGraph& fg, RenderTaskHandle handle, bool resize)
- {
- if (resize)
- {
- return;
- }
- }
-
} /* internal */
inline void AddCubemapConvolutionTask(FrameGraph& fg)
@@ -225,7 +215,6 @@ namespace wr
internal::ExecuteCubemapConvolutionTask(rs, fg, sg, handle);
};
desc.m_destroy_func = [](FrameGraph& fg, RenderTaskHandle handle, bool resize) {
- internal::DestroyCubemapConvolutionTask(fg, handle, resize);
};
desc.m_properties = rt_properties;
diff --git a/src/render_tasks/d3d12_deferred_composition.cpp b/src/render_tasks/d3d12_deferred_composition.cpp
index 4b40351a..7b179497 100644
--- a/src/render_tasks/d3d12_deferred_composition.cpp
+++ b/src/render_tasks/d3d12_deferred_composition.cpp
@@ -57,7 +57,7 @@ namespace wr
constexpr unsigned int brdf_lut_loc = rs_layout::GetHeapLoc(params::deferred_composition, params::DeferredCompositionE::BRDF_LUT);
auto& n_render_system = static_cast(render_system);
- d3d12::TextureResource* brdf_lut_text = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
+ auto* brdf_lut_text = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
d3d12::SetShaderSRV(cmd_list, 1, brdf_lut_loc, brdf_lut_text);
constexpr unsigned int shadow = rs_layout::GetHeapLoc(params::deferred_composition, params::DeferredCompositionE::BUFFER_REFLECTION_SHADOW);
@@ -153,13 +153,18 @@ namespace wr
// Update camera constant buffer pool
auto active_camera = scene_graph.GetActiveCamera();
- temp::ProjectionView_CBData camera_data;
+ temp::ProjectionView_CBData camera_data{};
camera_data.m_projection = active_camera->m_projection;
camera_data.m_inverse_projection = active_camera->m_inverse_projection;
camera_data.m_view = active_camera->m_view;
camera_data.m_inverse_view = active_camera->m_inverse_view;
camera_data.m_is_hybrid = data.is_hybrid;
camera_data.m_is_path_tracer = data.is_path_tracer;
+#ifdef NVIDIA_GAMEWORKS_HBAO
+ camera_data.m_is_hbao = data.is_hbao;
+#else
+ camera_data.m_is_hbao = false;
+#endif
active_camera->m_camera_cb->m_pool->Update(active_camera->m_camera_cb, sizeof(temp::ProjectionView_CBData), 0, (uint8_t*)&camera_data);
const auto camera_cb = static_cast(active_camera->m_camera_cb);
@@ -196,9 +201,9 @@ namespace wr
// Get HBAO+ Texture
if (data.is_hbao)
{
- auto handle = data.out_rtv_srv_allocation.GetDescriptorHandle(rs_layout::GetHeapLoc(params::deferred_composition, params::DeferredCompositionE::BUFFER_SCREEN_SPACE_AO));
+ auto hbao_handle = data.out_rtv_srv_allocation.GetDescriptorHandle(rs_layout::GetHeapLoc(params::deferred_composition, params::DeferredCompositionE::BUFFER_SCREEN_SPACE_AO));
auto ao_rt = static_cast(fg.GetPredecessorRenderTarget());
- d3d12::CreateSRVFromSpecificRTV(ao_rt, handle, 0, ao_rt->m_create_info.m_rtv_formats[0]);
+ d3d12::CreateSRVFromSpecificRTV(ao_rt, hbao_handle, 0, ao_rt->m_create_info.m_rtv_formats[0]);
}
// Get Irradiance Map
diff --git a/src/render_tasks/d3d12_depth_data_readback.hpp b/src/render_tasks/d3d12_depth_data_readback.hpp
index 142208f5..3aa29abf 100644
--- a/src/render_tasks/d3d12_depth_data_readback.hpp
+++ b/src/render_tasks/d3d12_depth_data_readback.hpp
@@ -10,12 +10,12 @@ namespace wr
struct DepthReadbackTaskData
{
// Render target of the previous render task (should be the render target from the main deferred task)
- d3d12::RenderTarget* predecessor_render_target;
+ d3d12::RenderTarget* predecessor_render_target = nullptr;
// Read back buffer used to retrieve the pixel data on the GPU
- d3d12::ReadbackBufferResource* readback_buffer;
+ d3d12::ReadbackBufferResource* readback_buffer = nullptr;
- d3d12::desc::ReadbackDesc readback_buffer_desc;
+ d3d12::desc::ReadbackDesc readback_buffer_desc = {};
// Stores the final pixel data
CPUTexture cpu_texture_output;
@@ -69,8 +69,8 @@ namespace wr
destination.Type = D3D12_TEXTURE_COPY_TYPE::D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
destination.SubresourceIndex = 0;
destination.PlacedFootprint.Footprint.Format = static_cast(data.predecessor_render_target->m_create_info.m_dsv_format);
- destination.PlacedFootprint.Footprint.Width = dx12_render_system.m_viewport.m_viewport.Width;
- destination.PlacedFootprint.Footprint.Height = dx12_render_system.m_viewport.m_viewport.Height;
+ destination.PlacedFootprint.Footprint.Width = static_cast(dx12_render_system.m_viewport.m_viewport.Width);
+ destination.PlacedFootprint.Footprint.Height = static_cast(dx12_render_system.m_viewport.m_viewport.Height);
destination.PlacedFootprint.Footprint.Depth = 1;
std::uint32_t row_pitch = destination.PlacedFootprint.Footprint.Width * BytesPerPixel(data.predecessor_render_target->m_create_info.m_dsv_format);
diff --git a/src/render_tasks/d3d12_equirect_to_cubemap.hpp b/src/render_tasks/d3d12_equirect_to_cubemap.hpp
index 3992bbaf..22d2c978 100644
--- a/src/render_tasks/d3d12_equirect_to_cubemap.hpp
+++ b/src/render_tasks/d3d12_equirect_to_cubemap.hpp
@@ -21,17 +21,17 @@ namespace wr
{
struct EquirectToCubemapTaskData
{
- D3D12Pipeline* in_pipeline;
+ D3D12Pipeline* in_pipeline = nullptr;
- TextureHandle in_equirect;
- TextureHandle out_cubemap;
- TextureHandle out_pref_env;
+ TextureHandle in_equirect = {};
+ TextureHandle out_cubemap = {};
+ TextureHandle out_pref_env = {};
std::shared_ptr camera_cb_pool;
- D3D12ConstantBufferHandle* cb_handle;
+ D3D12ConstantBufferHandle* cb_handle = nullptr;
- DirectX::XMMATRIX proj_mat;
- DirectX::XMMATRIX view_mat[6];
+ DirectX::XMMATRIX proj_mat = { DirectX::XMMatrixIdentity() };
+ DirectX::XMMATRIX view_mat[6] = {};
bool should_run = true;
};
@@ -193,10 +193,7 @@ namespace wr
if (n_render_system.m_render_window.has_value())
{
auto cmd_list = fg.GetCommandList(handle);
- auto render_target = fg.GetRenderTarget(handle);
-
const auto viewport = d3d12::CreateViewport(cubemap_text->m_width, cubemap_text->m_height);
-
const auto frame_idx = n_render_system.GetRenderWindow()->m_frame_idx;
d3d12::BindViewport(cmd_list, viewport);
@@ -277,14 +274,6 @@ namespace wr
}
}
- inline void DestroyEquirectToCubemapTask(FrameGraph& fg, RenderTaskHandle handle, bool resize)
- {
- if (resize)
- {
- return;
- }
- }
-
} /* internal */
inline void AddEquirectToCubemapTask(FrameGraph& fg)
@@ -315,7 +304,6 @@ namespace wr
internal::ExecuteEquirectToCubemapTask(rs, fg, sg, handle);
};
desc.m_destroy_func = [](FrameGraph& fg, RenderTaskHandle handle, bool resize) {
- internal::DestroyEquirectToCubemapTask(fg, handle, resize);
};
desc.m_properties = rt_properties;
diff --git a/src/render_tasks/d3d12_hbao.hpp b/src/render_tasks/d3d12_hbao.hpp
index 900e0248..a789a11a 100644
--- a/src/render_tasks/d3d12_hbao.hpp
+++ b/src/render_tasks/d3d12_hbao.hpp
@@ -30,12 +30,12 @@ namespace wr
struct HBAOData
{
- d3d12::RenderTarget* out_deferred_main_rt;
- d3d12::DescriptorHeap* out_descriptor_heap_srv;
- d3d12::DescriptorHeap* out_descriptor_heap_rtv;
+ d3d12::RenderTarget* out_deferred_main_rt = nullptr;
+ d3d12::DescriptorHeap* out_descriptor_heap_srv = nullptr;
+ d3d12::DescriptorHeap* out_descriptor_heap_rtv = nullptr;
#ifdef NVIDIA_GAMEWORKS_HBAO
- GFSDK_SSAO_Context_D3D12* ssao_context;
+ GFSDK_SSAO_Context_D3D12* ssao_context = nullptr;
GFSDK_SSAO_InputData_D3D12 ssao_input_data;
#endif
@@ -44,8 +44,6 @@ namespace wr
d3d12::DescHeapCPUHandle cpu_normal_handle;
d3d12::DescHeapGPUHandle gpu_normal_handle;
d3d12::DescHeapCPUHandle cpu_target_handle;
- d3d12::DescHeapGPUHandle gpu_target_handle;
-
};
namespace internal
@@ -82,7 +80,6 @@ namespace wr
heap_desc.m_versions = 1;
data.out_descriptor_heap_rtv = d3d12::CreateDescriptorHeap(n_device, heap_desc);
- data.gpu_target_handle = d3d12::GetGPUHandle(data.out_descriptor_heap_rtv, 0);
data.cpu_target_handle = d3d12::GetCPUHandle(data.out_descriptor_heap_rtv, 0);
}
@@ -122,7 +119,7 @@ namespace wr
GFSDK_SSAO_Status status = GFSDK_SSAO_CreateContext_D3D12(n_device->m_native, 1, DescriptorHeaps, &data.ssao_context, &custom_heap);
if (status != GFSDK_SSAO_Status::GFSDK_SSAO_OK)
{
- LOGW("Failed to initialize the NVIDIA HBAO+ context.");
+ LOGW("Failed to initialize the NVIDIA HBAO+ context.")
}
#endif
}
@@ -145,12 +142,12 @@ namespace wr
// Set the viewport
data.ssao_input_data.DepthData.Viewport.Enable = true;
- data.ssao_input_data.DepthData.Viewport.Height = viewport.m_viewport.Height;
- data.ssao_input_data.DepthData.Viewport.Width = viewport.m_viewport.Width;
- data.ssao_input_data.DepthData.Viewport.TopLeftX = viewport.m_viewport.TopLeftX;
- data.ssao_input_data.DepthData.Viewport.TopLeftY = viewport.m_viewport.TopLeftY;
- data.ssao_input_data.DepthData.Viewport.MinDepth = viewport.m_viewport.MinDepth;
- data.ssao_input_data.DepthData.Viewport.MaxDepth = viewport.m_viewport.MaxDepth;
+ data.ssao_input_data.DepthData.Viewport.Height = static_cast(viewport.m_viewport.Height);
+ data.ssao_input_data.DepthData.Viewport.Width = static_cast(viewport.m_viewport.Width);
+ data.ssao_input_data.DepthData.Viewport.TopLeftX = static_cast(viewport.m_viewport.TopLeftX);
+ data.ssao_input_data.DepthData.Viewport.TopLeftY = static_cast(viewport.m_viewport.TopLeftY);
+ data.ssao_input_data.DepthData.Viewport.MinDepth = static_cast(viewport.m_viewport.MinDepth);
+ data.ssao_input_data.DepthData.Viewport.MaxDepth = static_cast(viewport.m_viewport.MaxDepth);
GFSDK_SSAO_Parameters ao_parameters = {};
ao_parameters.Radius = settings.m_runtime.m_radius;
@@ -180,14 +177,14 @@ namespace wr
#endif
}
- inline void DestroyHBAOTask(FrameGraph& fg, RenderTaskHandle handle, bool resize)
+ inline void DestroyHBAOTask(FrameGraph& fg, RenderTaskHandle handle, bool)
{
#ifdef NVIDIA_GAMEWORKS_HBAO
auto& data = fg.GetData(handle);
d3d12::Destroy(data.out_descriptor_heap_srv);
d3d12::Destroy(data.out_descriptor_heap_rtv);
- if (data.ssao_context) delete data.ssao_context;
+ delete data.ssao_context;
#endif
}
diff --git a/src/render_tasks/d3d12_imgui_render_task.hpp b/src/render_tasks/d3d12_imgui_render_task.hpp
index af84a244..7fa65c80 100644
--- a/src/render_tasks/d3d12_imgui_render_task.hpp
+++ b/src/render_tasks/d3d12_imgui_render_task.hpp
@@ -47,8 +47,8 @@ namespace wr
heap_desc.m_num_descriptors = 2;
heap_desc.m_shader_visible = true;
heap_desc.m_type = DescriptorHeapType::DESC_HEAP_TYPE_CBV_SRV_UAV;
- data.out_descriptor_heap = d3d12::CreateDescriptorHeap(n_render_system.m_device, heap_desc);
- SetName(data.out_descriptor_heap, L"ImGui Descriptor Heap");
+ ImGuiTaskData::out_descriptor_heap = d3d12::CreateDescriptorHeap(n_render_system.m_device, heap_desc);
+ SetName(ImGuiTaskData::out_descriptor_heap, L"ImGui Descriptor Heap");
IMGUI_CHECKVERSION();
ImGui::CreateContext();
@@ -63,8 +63,8 @@ namespace wr
ImGui_ImplDX12_Init(n_render_system.m_device->m_native,
d3d12::settings::num_back_buffers,
(DXGI_FORMAT)d3d12::settings::back_buffer_format,
- d3d12::GetCPUHandle(data.out_descriptor_heap, 0 /* TODO: Solve versioning for ImGui */).m_native,
- d3d12::GetGPUHandle(data.out_descriptor_heap, 0 /* TODO: Solve versioning for ImGui */).m_native);
+ d3d12::GetCPUHandle(ImGuiTaskData::out_descriptor_heap, 0 /* TODO: Solve versioning for ImGui */).m_native,
+ d3d12::GetGPUHandle(ImGuiTaskData::out_descriptor_heap, 0 /* TODO: Solve versioning for ImGui */).m_native);
ImGui::StyleColorsCherry();
}
@@ -75,7 +75,6 @@ namespace wr
auto& n_render_system = static_cast(rs);
auto& data = fg.GetData(handle);
auto cmd_list = fg.GetCommandList(handle);
- auto render_target = fg.GetRenderTarget(handle);
// Temp rendering
if (n_render_system.m_render_window.has_value())
@@ -84,7 +83,6 @@ namespace wr
// Create handle to the render target you want to display. and put it in descriptor slot 2.
auto display_rt = static_cast(fg.GetPredecessorRenderTarget());
- constexpr unsigned int source_idx = rs_layout::GetHeapLoc(params::post_processing, params::PostProcessingE::SOURCE);
auto cpu_handle = d3d12::GetCPUHandle(data.out_descriptor_heap, frame_idx, 1);
d3d12::CreateSRVFromSpecificRTV(display_rt, cpu_handle, 0, display_rt->m_create_info.m_rtv_formats[frame_idx]);
@@ -123,7 +121,7 @@ namespace wr
}
}
- inline void DestroyImGuiTask(FrameGraph& fg, RenderTaskHandle handle, bool resize)
+ inline void DestroyImGuiTask(FrameGraph& fg, RenderTaskHandle, bool resize)
{
if (resize)
{
diff --git a/src/render_tasks/d3d12_path_tracer.hpp b/src/render_tasks/d3d12_path_tracer.hpp
index db7da9ec..22389a3f 100644
--- a/src/render_tasks/d3d12_path_tracer.hpp
+++ b/src/render_tasks/d3d12_path_tracer.hpp
@@ -9,7 +9,6 @@
#include "../d3d12/d3d12_rt_pipeline_registry.hpp"
#include "../d3d12/d3d12_root_signature_registry.hpp"
#include "../engine_registry.hpp"
-#include "../util/math.hpp"
#include "../render_tasks/d3d12_deferred_main.hpp"
#include "../render_tasks/d3d12_build_acceleration_structures.hpp"
@@ -19,7 +18,7 @@ namespace wr
{
struct PathTracerData
{
- d3d12::AccelerationStructure out_tlas;
+ d3d12::AccelerationStructure out_tlas = {};
// Shader tables
std::array out_raygen_shader_table = { nullptr, nullptr, nullptr };
@@ -27,21 +26,20 @@ namespace wr
std::array out_hitgroup_shader_table = { nullptr, nullptr, nullptr };
// Pipeline objects
- d3d12::StateObject* out_state_object;
- d3d12::RootSignature* out_root_signature;
+ d3d12::StateObject* out_state_object = nullptr;
// Structures and buffers
- D3D12ConstantBufferHandle* out_cb_camera_handle;
- d3d12::RenderTarget* out_deferred_main_rt;
+ D3D12ConstantBufferHandle* out_cb_camera_handle = nullptr;
+ d3d12::RenderTarget* out_deferred_main_rt = nullptr;
- DirectX::XMVECTOR last_cam_pos;
- DirectX::XMVECTOR last_cam_rot;
+ DirectX::XMVECTOR last_cam_pos = {};
+ DirectX::XMVECTOR last_cam_rot = {};
DescriptorAllocation out_uav_from_rtv;
DescriptorAllocation out_gbuffers;
DescriptorAllocation out_depthbuffer;
- bool tlas_requires_init;
+ bool tlas_requires_init = true;
};
namespace internal
@@ -171,10 +169,6 @@ namespace wr
// Pipeline State Object
auto& rt_registry = RTPipelineRegistry::Get();
data.out_state_object = static_cast(rt_registry.Find(state_objects::path_tracer_state_object))->m_native;
-
- // Root Signature
- auto& rs_registry = RootSignatureRegistry::Get();
- data.out_root_signature = static_cast(rs_registry.Find(root_signatures::path_tracing_global))->m_native;
}
// Create Shader Tables
@@ -197,7 +191,7 @@ namespace wr
auto cmd_list = fg.GetCommandList(handle);
auto& data = fg.GetData(handle);
auto& as_build_data = fg.GetPredecessorData();
-
+
d3d12::CreateOrUpdateTLAS(device, cmd_list, data.tlas_requires_init, data.out_tlas, as_build_data.out_blas_list);
// Reset accmulation if nessessary
@@ -220,77 +214,77 @@ namespace wr
{
auto frame_idx = n_render_system.GetFrameIdx();
-
- d3d12::BindRaytracingPipeline(cmd_list, data.out_state_object, d3d12::GetRaytracingType(device) == RaytracingType::FALLBACK);
-
- // Bind output, indices and materials, offsets, etc
- auto out_uav_handle = data.out_uav_from_rtv.GetDescriptorHandle();
- d3d12::SetRTShaderUAV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OUTPUT)), out_uav_handle);
- //out_uav_handle = data.out_uav_from_rtv.GetDescriptorHandle(1);
- //d3d12::SetRTShaderUAV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OUTPUT)) + 1, out_uav_handle);
-
- auto out_scene_ib_handle = as_build_data.out_scene_ib_alloc.GetDescriptorHandle();
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::INDICES)), out_scene_ib_handle);
-
- auto out_scene_mat_handle = as_build_data.out_scene_mat_alloc.GetDescriptorHandle();
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::MATERIALS)), out_scene_mat_handle);
-
- auto out_scene_offset_handle = as_build_data.out_scene_offset_alloc.GetDescriptorHandle();
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OFFSETS)), out_scene_offset_handle);
-
- auto out_scene_gbuffers_handle1 = data.out_gbuffers.GetDescriptorHandle(0);
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 0, out_scene_gbuffers_handle1);
-
- auto out_scene_gbuffers_handle2 = data.out_gbuffers.GetDescriptorHandle(1);
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 1, out_scene_gbuffers_handle2);
-
- auto out_scene_depth_handle = data.out_depthbuffer.GetDescriptorHandle();
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 2, out_scene_depth_handle);
-
- /*
- To keep the CopyDescriptors function happy, we need to fill the descriptor table with valid descriptors
- We fill the table with a single descriptor, then overwrite some spots with the he correct textures
- If a spot is unused, then a default descriptor will be still bound, but not used in the shaders.
- Since the renderer creates a texture pool that can be used by the render tasks, and
- the texture pool also has default textures for albedo/roughness/etc... one of those textures is a good
- candidate for this.
- */
- {
- auto texture_pool = render_system.GetDefaultTexturePool();
-
- if (texture_pool == nullptr)
- {
- LOGC("ERROR: Texture Pool in Raytracing Task is nullptr. This is not supposed to happen.");
- }
-
- auto texture_handle = texture_pool->GetDefaultAlbedo();
- auto* texture_resource = static_cast(texture_pool->GetTextureResource(texture_handle));
-
- size_t num_textures_in_heap = COMPILATION_EVAL(rs_layout::GetSize(params::path_tracing, params::PathTracingE::TEXTURES));
- unsigned int heap_loc_start = COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::TEXTURES));
-
- for (size_t i = 0; i < num_textures_in_heap; ++i)
- {
- d3d12::SetRTShaderSRV(cmd_list, 0, heap_loc_start + i, texture_resource);
- }
- }
-
- // Fill descriptor heap with textures used by the scene
- for (auto handle : as_build_data.out_material_handles)
- {
- auto* material_internal = handle.m_pool->GetMaterial(handle);
-
- auto set_srv = [&data, material_internal, cmd_list](auto texture_handle)
- {
- auto* texture_internal = static_cast(texture_handle.m_pool->GetTextureResource(texture_handle));
-
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::rt_hybrid, params::RTHybridE::TEXTURES)) + texture_handle.m_id, texture_internal);
- };
-
- set_srv(material_internal->GetAlbedo());
- set_srv(material_internal->GetMetallic());
- set_srv(material_internal->GetNormal());
- set_srv(material_internal->GetRoughness());
+
+ d3d12::BindRaytracingPipeline(cmd_list, data.out_state_object, d3d12::GetRaytracingType(device) == RaytracingType::FALLBACK);
+
+ // Bind output, indices and materials, offsets, etc
+ auto out_uav_handle = data.out_uav_from_rtv.GetDescriptorHandle();
+ d3d12::SetRTShaderUAV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OUTPUT)), out_uav_handle);
+ //out_uav_handle = data.out_uav_from_rtv.GetDescriptorHandle(1);
+ //d3d12::SetRTShaderUAV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OUTPUT)) + 1, out_uav_handle);
+
+ auto out_scene_ib_handle = as_build_data.out_scene_ib_alloc.GetDescriptorHandle();
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::INDICES)), out_scene_ib_handle);
+
+ auto out_scene_mat_handle = as_build_data.out_scene_mat_alloc.GetDescriptorHandle();
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::MATERIALS)), out_scene_mat_handle);
+
+ auto out_scene_offset_handle = as_build_data.out_scene_offset_alloc.GetDescriptorHandle();
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::OFFSETS)), out_scene_offset_handle);
+
+ auto out_scene_gbuffers_handle1 = data.out_gbuffers.GetDescriptorHandle(0);
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 0, out_scene_gbuffers_handle1);
+
+ auto out_scene_gbuffers_handle2 = data.out_gbuffers.GetDescriptorHandle(1);
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 1, out_scene_gbuffers_handle2);
+
+ auto out_scene_depth_handle = data.out_depthbuffer.GetDescriptorHandle();
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::GBUFFERS)) + 2, out_scene_depth_handle);
+
+ /*
+ To keep the CopyDescriptors function happy, we need to fill the descriptor table with valid descriptors
+ We fill the table with a single descriptor, then overwrite some spots with the he correct textures
+ If a spot is unused, then a default descriptor will be still bound, but not used in the shaders.
+ Since the renderer creates a texture pool that can be used by the render tasks, and
+ the texture pool also has default textures for albedo/roughness/etc... one of those textures is a good
+ candidate for this.
+ */
+ {
+ auto texture_pool = render_system.GetDefaultTexturePool();
+
+ if (texture_pool == nullptr)
+ {
+ LOGC("ERROR: Texture Pool in Raytracing Task is nullptr. This is not supposed to happen.");
+ }
+
+ auto texture_handle = texture_pool->GetDefaultAlbedo();
+ auto* texture_resource = static_cast(texture_pool->GetTextureResource(texture_handle));
+
+ size_t num_textures_in_heap = COMPILATION_EVAL(rs_layout::GetSize(params::path_tracing, params::PathTracingE::TEXTURES));
+ unsigned int heap_loc_start = COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::TEXTURES));
+
+ for (size_t i = 0; i < num_textures_in_heap; ++i)
+ {
+ d3d12::SetRTShaderSRV(cmd_list, 0, heap_loc_start + i, texture_resource);
+ }
+ }
+
+ // Fill descriptor heap with textures used by the scene
+ for (auto material_handle : as_build_data.out_material_handles)
+ {
+ auto* material_internal = material_handle.m_pool->GetMaterial(material_handle);
+
+ auto set_srv = [&data, material_internal, cmd_list](auto texture_handle)
+ {
+ auto* texture_internal = static_cast(texture_handle.m_pool->GetTextureResource(texture_handle));
+
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::rt_hybrid, params::RTHybridE::TEXTURES)) + texture_handle.m_id, texture_internal);
+ };
+
+ set_srv(material_internal->GetAlbedo());
+ set_srv(material_internal->GetMetallic());
+ set_srv(material_internal->GetNormal());
+ set_srv(material_internal->GetRoughness());
}
// Get light buffer
@@ -317,7 +311,7 @@ namespace wr
// Update camera constant buffer
auto camera = scene_graph.GetActiveCamera();
- temp::RTHybridCamera_CBData cam_data;
+ temp::RTHybridCamera_CBData cam_data{};
cam_data.m_inverse_view = DirectX::XMMatrixInverse(nullptr, camera->m_view);
cam_data.m_inverse_projection = DirectX::XMMatrixInverse(nullptr, camera->m_projection);
cam_data.m_inv_vp = DirectX::XMMatrixInverse(nullptr, camera->m_view * camera->m_projection);
@@ -335,18 +329,18 @@ namespace wr
d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::SKYBOX)), skybox_t);
}
- // Get Pre-filtered environment
- if (scene_graph.m_skybox.has_value())
- {
- auto irradiance_t = static_cast(scene_graph.GetCurrentSkybox()->m_prefiltered_env_map->m_pool->GetTextureResource(scene_graph.GetCurrentSkybox()->m_prefiltered_env_map.value()));
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::PREF_ENV_MAP)), irradiance_t);
- }
-
- // Get brdf lookup texture
- if (scene_graph.m_skybox.has_value())
- {
- auto brdf_lut_text = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
- d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::BRDF_LUT)), brdf_lut_text);
+ // Get Pre-filtered environment
+ if (scene_graph.m_skybox.has_value())
+ {
+ auto irradiance_t = static_cast(scene_graph.GetCurrentSkybox()->m_prefiltered_env_map->m_pool->GetTextureResource(scene_graph.GetCurrentSkybox()->m_prefiltered_env_map.value()));
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::PREF_ENV_MAP)), irradiance_t);
+ }
+
+ // Get brdf lookup texture
+ if (scene_graph.m_skybox.has_value())
+ {
+ auto brdf_lut_text = static_cast(n_render_system.m_brdf_lut.value().m_pool->GetTextureResource(n_render_system.m_brdf_lut.value()));
+ d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::path_tracing, params::PathTracingE::BRDF_LUT)), brdf_lut_text);
}
// Get Environment Map
@@ -378,7 +372,7 @@ namespace wr
CreateShaderTables(device, data, frame_idx);
//#endif
- // Dispatch hybrid ray tracing rays
+ // Dispatch hybrid ray tracing rays
d3d12::DispatchRays(cmd_list, data.out_hitgroup_shader_table[frame_idx], data.out_miss_shader_table[frame_idx], data.out_raygen_shader_table[frame_idx], window->GetWidth(), window->GetHeight(), 1, frame_idx);
// Transition depth back to DEPTH_WRITE
@@ -401,9 +395,9 @@ namespace wr
RenderTargetProperties::DSVFormat(Format::UNKNOWN),
RenderTargetProperties::RTVFormats({ Format::R32G32B32A32_FLOAT }),
RenderTargetProperties::NumRTVFormats(1),
- RenderTargetProperties::Clear(false),
+ RenderTargetProperties::Clear(false),
RenderTargetProperties::ClearDepth(false),
- RenderTargetProperties::ResourceName(L"Path Tracer")
+ RenderTargetProperties::ResourceName(L"Path Tracer")
};
RenderTaskDesc desc;
@@ -418,7 +412,7 @@ namespace wr
desc.m_destroy_func = [](FrameGraph&, RenderTaskHandle, bool)
{
// Nothing to destroy
- };
+ };
desc.m_properties = rt_properties;
desc.m_type = RenderTaskType::COMPUTE;
desc.m_allow_multithreading = true;
diff --git a/src/render_tasks/d3d12_pixel_data_readback.hpp b/src/render_tasks/d3d12_pixel_data_readback.hpp
index 647a1fb6..a156ecc5 100644
--- a/src/render_tasks/d3d12_pixel_data_readback.hpp
+++ b/src/render_tasks/d3d12_pixel_data_readback.hpp
@@ -10,12 +10,12 @@ namespace wr
struct PixelReadbackTaskData
{
// Render target of the previous render task (should be the output from the composition task
- d3d12::RenderTarget* predecessor_render_target;
+ d3d12::RenderTarget* predecessor_render_target = nullptr;
// Read back buffer used to retrieve the depth data on the GPU
- d3d12::ReadbackBufferResource* readback_buffer;
+ d3d12::ReadbackBufferResource* readback_buffer = nullptr;
- d3d12::desc::ReadbackDesc readback_buffer_desc;
+ d3d12::desc::ReadbackDesc readback_buffer_desc = {};
// Stores the final depth data
CPUTexture cpu_texture_output;
@@ -69,8 +69,8 @@ namespace wr
destination.Type = D3D12_TEXTURE_COPY_TYPE::D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
destination.SubresourceIndex = 0;
destination.PlacedFootprint.Footprint.Format = static_cast(data.predecessor_render_target->m_create_info.m_rtv_formats[0]);
- destination.PlacedFootprint.Footprint.Width = dx12_render_system.m_viewport.m_viewport.Width;
- destination.PlacedFootprint.Footprint.Height = dx12_render_system.m_viewport.m_viewport.Height;
+ destination.PlacedFootprint.Footprint.Width = static_cast(dx12_render_system.m_viewport.m_viewport.Width);
+ destination.PlacedFootprint.Footprint.Height = static_cast(dx12_render_system.m_viewport.m_viewport.Height);
destination.PlacedFootprint.Footprint.Depth = 1;
std::uint32_t row_pitch = destination.PlacedFootprint.Footprint.Width * BytesPerPixel(data.predecessor_render_target->m_create_info.m_rtv_formats[0]);
diff --git a/src/render_tasks/d3d12_post_processing.hpp b/src/render_tasks/d3d12_post_processing.hpp
index 0d3a8d33..be5f9581 100644
--- a/src/render_tasks/d3d12_post_processing.hpp
+++ b/src/render_tasks/d3d12_post_processing.hpp
@@ -10,11 +10,10 @@ namespace wr
{
struct PostProcessingData
{
- d3d12::RenderTarget* out_source_rt;
- d3d12::PipelineState* out_pipeline;
- ID3D12Resource* out_previous;
+ d3d12::RenderTarget* out_source_rt = nullptr;
+ d3d12::PipelineState* out_pipeline = nullptr;
- DescriptorAllocator* out_allocator;
+ DescriptorAllocator* out_allocator = nullptr;
DescriptorAllocation out_allocation;
};
@@ -24,7 +23,7 @@ namespace wr
{
template
- inline void SetupPostProcessingTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle, bool resize)
+ inline void SetupPostProcessingTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle, bool)
{
auto& n_render_system = static_cast(rs);
auto& data = fg.GetData(handle);
@@ -67,10 +66,8 @@ namespace wr
auto& n_render_system = static_cast(rs);
auto& device = n_render_system.m_device;
auto& data = fg.GetData(handle);
- auto n_render_target = fg.GetRenderTarget(handle);
auto frame_idx = n_render_system.GetFrameIdx();
auto cmd_list = fg.GetCommandList(handle);
- const auto viewport = n_render_system.m_viewport;
d3d12::BindComputePipeline(cmd_list, data.out_pipeline);
@@ -89,7 +86,7 @@ namespace wr
cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(data.out_source_rt->m_render_targets[frame_idx % versions]));
- float hdr_type = static_cast(d3d12::settings::output_hdr);
+ auto hdr_type = static_cast(d3d12::settings::output_hdr);
d3d12::BindCompute32BitConstants(cmd_list, &hdr_type, 1, 0, 1);
d3d12::Dispatch(cmd_list,
@@ -98,7 +95,7 @@ namespace wr
1);
}
- inline void DestroyPostProcessing(FrameGraph& fg, RenderTaskHandle handle, bool resize)
+ inline void DestroyPostProcessing(FrameGraph& fg, RenderTaskHandle handle, bool)
{
auto& data = fg.GetData(handle);
diff --git a/src/render_tasks/d3d12_raytracing_task.hpp b/src/render_tasks/d3d12_raytracing_task.hpp
index 029ff2c9..9bd5ebdf 100644
--- a/src/render_tasks/d3d12_raytracing_task.hpp
+++ b/src/render_tasks/d3d12_raytracing_task.hpp
@@ -11,7 +11,6 @@
#include "../render_tasks/d3d12_build_acceleration_structures.hpp"
#include "../engine_registry.hpp"
-#include "../util/math.hpp"
#include "../scene_graph/skybox_node.hpp"
#include "../render_tasks/d3d12_deferred_main.hpp"
diff --git a/src/render_tasks/d3d12_rt_hybrid_task.hpp b/src/render_tasks/d3d12_rt_hybrid_task.hpp
index 4c73d278..1e565758 100644
--- a/src/render_tasks/d3d12_rt_hybrid_task.hpp
+++ b/src/render_tasks/d3d12_rt_hybrid_task.hpp
@@ -10,7 +10,6 @@
#include "../d3d12/d3d12_rt_pipeline_registry.hpp"
#include "../d3d12/d3d12_root_signature_registry.hpp"
#include "../engine_registry.hpp"
-#include "../util/math.hpp"
#include "../render_tasks/d3d12_deferred_main.hpp"
#include "../render_tasks/d3d12_build_acceleration_structures.hpp"
@@ -20,7 +19,7 @@ namespace wr
{
struct RTHybridData
{
- d3d12::AccelerationStructure out_tlas;
+ d3d12::AccelerationStructure out_tlas = {};
// Shader tables
std::array out_raygen_shader_table = { nullptr, nullptr, nullptr };
@@ -28,20 +27,20 @@ namespace wr
std::array out_hitgroup_shader_table = { nullptr, nullptr, nullptr };
// Pipeline objects
- d3d12::StateObject* out_state_object;
- d3d12::RootSignature* out_root_signature;
+ d3d12::StateObject* out_state_object = nullptr;
+ d3d12::RootSignature* out_root_signature = nullptr;
// Structures and buffers
- D3D12ConstantBufferHandle* out_cb_camera_handle;
- d3d12::RenderTarget* out_deferred_main_rt;
+ D3D12ConstantBufferHandle* out_cb_camera_handle = nullptr;
+ d3d12::RenderTarget* out_deferred_main_rt = nullptr;
- unsigned int frame_idx;
+ unsigned int frame_idx = 0;
DescriptorAllocation out_uav_from_rtv;
DescriptorAllocation out_gbuffers;
DescriptorAllocation out_depthbuffer;
- bool tlas_requires_init;
+ bool tlas_requires_init = false;
};
namespace internal
diff --git a/src/renderer.hpp b/src/renderer.hpp
index b533f4a1..38d54f9d 100644
--- a/src/renderer.hpp
+++ b/src/renderer.hpp
@@ -69,7 +69,7 @@ namespace wr
std::optional m_window;
- enum SimpleShapes : std::size_t
+ enum class SimpleShapes : std::size_t
{
CUBE,
PLANE,
@@ -81,7 +81,7 @@ namespace wr
virtual wr::Model* GetSimpleShape(SimpleShapes type) = 0;
std::shared_ptr m_shapes_pool;
- wr::Model* m_simple_shapes[COUNT];
+ std::array(SimpleShapes::COUNT)> m_simple_shapes;
};
} /* wr */
\ No newline at end of file
diff --git a/src/scene_graph/camera_node.cpp b/src/scene_graph/camera_node.cpp
index 0d2c16f1..0fda0e3a 100644
--- a/src/scene_graph/camera_node.cpp
+++ b/src/scene_graph/camera_node.cpp
@@ -73,7 +73,6 @@ namespace wr
//Frustum culling code;
//optimized and refactored version of
//https://www.braynzarsoft.net/viewtutorial/q16390-34-aabb-cpu-side-frustum-culling
-
void CameraNode::CalculatePlanes()
{
//Left plane
diff --git a/src/scene_graph/camera_node.hpp b/src/scene_graph/camera_node.hpp
index 8f81b421..f582e6dd 100644
--- a/src/scene_graph/camera_node.hpp
+++ b/src/scene_graph/camera_node.hpp
@@ -19,7 +19,7 @@ namespace wr
struct FoV
{
- FoV(FovDefault deg) : m_fov(deg.Get() / 180.0f * 3.1415926535f)
+ explicit FoV(FovDefault deg) : m_fov(deg.Get() / 180.0f * 3.1415926535f)
{
}
@@ -31,7 +31,7 @@ namespace wr
float m_fov;
};
- CameraNode(float fov_deg, float aspect_ratio)
+ CameraNode(float aspect_ratio)
: Node(typeid(CameraNode)),
m_active(true),
m_frustum_near(0.1f),
@@ -46,7 +46,14 @@ namespace wr
m_focus_dist(0),
m_override_projection(false),
m_projection_offset_x(0),
- m_projection_offset_y(0)
+ m_projection_offset_y(0),
+ m_view(),
+ m_inverse_view(),
+ m_projection(),
+ m_inverse_projection(),
+ m_view_projection(),
+ m_camera_cb(),
+ m_planes()
{
}
diff --git a/src/scene_graph/light_node.hpp b/src/scene_graph/light_node.hpp
index fdc64a49..2ed82a27 100644
--- a/src/scene_graph/light_node.hpp
+++ b/src/scene_graph/light_node.hpp
@@ -9,8 +9,8 @@ namespace wr
struct LightNode : Node
{
- LightNode(LightType tid, DirectX::XMVECTOR col = { 1, 1, 1 });
- LightNode(DirectX::XMVECTOR rot, DirectX::XMVECTOR col = { 1, 1, 1 });
+ explicit LightNode(LightType tid, DirectX::XMVECTOR col = { 1, 1, 1 });
+ explicit LightNode(DirectX::XMVECTOR rot, DirectX::XMVECTOR col = { 1, 1, 1 });
LightNode(DirectX::XMVECTOR pos, float rad, DirectX::XMVECTOR col = { 1, 1, 1 });
LightNode(DirectX::XMVECTOR pos, float rad, DirectX::XMVECTOR rot, float ang, DirectX::XMVECTOR col = { 1, 1, 1 });
diff --git a/src/scene_graph/mesh_node.cpp b/src/scene_graph/mesh_node.cpp
index c2743cb1..3b91c4ed 100644
--- a/src/scene_graph/mesh_node.cpp
+++ b/src/scene_graph/mesh_node.cpp
@@ -41,7 +41,7 @@ namespace wr {
{
if (m_materials.size() > m_model->m_meshes.size())
{
- LOGW("A mesh node has more materials than meshes.");
+ LOGW("A mesh node has more materials than meshes.")
}
}
diff --git a/src/scene_graph/mesh_node.hpp b/src/scene_graph/mesh_node.hpp
index 7d1000fd..a7ac923e 100644
--- a/src/scene_graph/mesh_node.hpp
+++ b/src/scene_graph/mesh_node.hpp
@@ -9,7 +9,7 @@ namespace wr
struct MeshNode : Node
{
- MeshNode(Model* model);
+ explicit MeshNode(Model* model);
void Update(uint32_t frame_idx);
/*! Add a material */
diff --git a/src/scene_graph/node.hpp b/src/scene_graph/node.hpp
index ea35ecda..b43c24e4 100644
--- a/src/scene_graph/node.hpp
+++ b/src/scene_graph/node.hpp
@@ -10,7 +10,7 @@ namespace wr
struct Node : std::enable_shared_from_this
{
Node();
- Node(std::type_info const & type_info);
+ explicit Node(std::type_info const & type_info);
void SignalChange();
void SignalUpdate(unsigned int frame_idx);
diff --git a/src/scene_graph/scene_graph.cpp b/src/scene_graph/scene_graph.cpp
index 132d319b..bfd8ff80 100644
--- a/src/scene_graph/scene_graph.cpp
+++ b/src/scene_graph/scene_graph.cpp
@@ -19,8 +19,10 @@
namespace wr
{
- SceneGraph::SceneGraph(RenderSystem* render_system)
- : m_render_system(render_system), m_root(std::make_shared())
+ SceneGraph::SceneGraph(RenderSystem* render_system) :
+ m_render_system(render_system),
+ m_root(std::make_shared()),
+ m_light_buffer()
{
m_lights.resize(d3d12::settings::num_lights);
}
@@ -106,9 +108,9 @@ namespace wr
// Create Light Buffer
- uint64_t light_count = (uint64_t) m_lights.size();
- uint64_t light_buffer_stride = sizeof(Light), light_buffer_size = light_buffer_stride * light_count;
- uint64_t light_buffer_aligned_size = SizeAlignTwoPower(light_buffer_size, 65536) * d3d12::settings::num_back_buffers;
+ std::uint64_t light_count = (std::uint64_t) m_lights.size();
+ std::uint64_t light_buffer_stride = sizeof(Light), light_buffer_size = light_buffer_stride * light_count;
+ std::uint64_t light_buffer_aligned_size = SizeAlignTwoPower(light_buffer_size, 65536) * d3d12::settings::num_back_buffers;
m_structured_buffer = m_render_system->CreateStructuredBufferPool((size_t)light_buffer_aligned_size );
m_light_buffer = m_structured_buffer->Create(light_buffer_size, light_buffer_stride, false);
@@ -175,12 +177,12 @@ namespace wr
//Update light count
- if (m_lights.size() != 0)
+ if (!m_lights.empty())
{
m_lights[0].tid &= 0x3; //Keep id
m_lights[0].tid |= uint32_t(m_light_nodes.size() + 1) << 2; //Set lights
- if (m_light_nodes.size() != 0)
+ if (!m_light_nodes.empty())
{
m_light_nodes[0]->SignalChange();
}
@@ -195,7 +197,7 @@ namespace wr
{
//Update batches
- bool should_update = m_batches.size() == 0;
+ bool should_update = m_batches.empty();
for (auto& elem : m_batches)
{
@@ -212,9 +214,8 @@ namespace wr
constexpr auto model_size = sizeof(temp::ObjectData) * max_size;
- for (unsigned int i = 0; i < m_mesh_nodes.size(); ++i) {
+ for (auto& node : m_mesh_nodes) {
- auto node = m_mesh_nodes[i];
auto mesh_materials_pair = std::make_pair(node->m_model, node->m_materials);
auto it = m_batches.find(mesh_materials_pair);
diff --git a/src/scene_graph/scene_graph.hpp b/src/scene_graph/scene_graph.hpp
index 6a834957..d829acc8 100644
--- a/src/scene_graph/scene_graph.hpp
+++ b/src/scene_graph/scene_graph.hpp
@@ -78,7 +78,7 @@ namespace wr
template
std::shared_ptr CreateChild(std::shared_ptr const & parent = nullptr, Args... args);
std::vector> GetChildren(std::shared_ptr const & parent = nullptr);
- void RemoveChildren(std::shared_ptr const & parent);
+ static void RemoveChildren(std::shared_ptr const & parent);
std::shared_ptr GetActiveCamera();
std::vector>& GetLightNodes();
@@ -107,7 +107,6 @@ namespace wr
protected:
void RegisterLight(std::shared_ptr& light_node);
- void UpdateTransforms(std::shared_ptr& node);
private:
diff --git a/src/scene_graph/skybox_node.hpp b/src/scene_graph/skybox_node.hpp
index 00a04044..7eb9aa88 100644
--- a/src/scene_graph/skybox_node.hpp
+++ b/src/scene_graph/skybox_node.hpp
@@ -5,7 +5,7 @@ namespace wr {
struct SkyboxNode : Node
{
- SkyboxNode(wr::TextureHandle hdr_texture, std::optional cubemap = std::nullopt, std::optional irradiance = std::nullopt)
+ explicit SkyboxNode(wr::TextureHandle hdr_texture, std::optional cubemap = std::nullopt, std::optional irradiance = std::nullopt)
: Node::Node(typeid(SkyboxNode))
, m_hdr(hdr_texture)
, m_skybox(cubemap)
diff --git a/src/settings.hpp b/src/settings.hpp
index 3cfa1f7f..ef642ea5 100644
--- a/src/settings.hpp
+++ b/src/settings.hpp
@@ -3,11 +3,11 @@
namespace wr::settings
{
- static const constexpr bool use_multithreading = true;
+ static const constexpr bool use_multithreading = false;
static const constexpr unsigned int num_frame_graph_threads = 4;
static const constexpr std::uint8_t default_textures_count = 5;
- static const constexpr std::uint8_t default_textures_size_in_bytes = 4*1024*1024;
+ static const constexpr std::uint32_t default_textures_size_in_bytes = 4ul * 1024ul * 1024ul;
static constexpr const char* default_albedo_path = "resources/materials/metalgrid2_basecolor.png";
static constexpr const char* default_normal_path = "resources/materials/flat_normal.png";
static constexpr const char* default_roughness_path = "resources/materials/white.png";
diff --git a/src/util/aabb.cpp b/src/util/aabb.cpp
index a3c451d6..5effbbe7 100644
--- a/src/util/aabb.cpp
+++ b/src/util/aabb.cpp
@@ -4,7 +4,7 @@ namespace wr
{
Box::Box() :
- m_corners
+ m_data
{
{
std::numeric_limits::max(),
@@ -43,58 +43,57 @@ namespace wr
Box::Box(DirectX::XMVECTOR(&corners)[6])
{
- memcpy(m_corners, corners, sizeof(corners));
+ memcpy(m_data, corners, sizeof(corners));
}
DirectX::XMVECTOR& Box::operator[](size_t i)
{
- return m_corners[i];
+ return m_data[i];
}
DirectX::XMVECTOR& AABB::operator[](size_t i)
{
- return m_bounds[i];
+ return m_data[i];
}
void AABB::Expand(DirectX::XMVECTOR pos)
{
- m_min =
+ m_corners.m_min =
{
- std::min(pos.m128_f32[0], *m_min.m128_f32),
- std::min(pos.m128_f32[1], m_min.m128_f32[1]),
- std::min(pos.m128_f32[2], m_min.m128_f32[2]),
+ std::min(pos.m128_f32[0], *m_corners.m_min.m128_f32),
+ std::min(pos.m128_f32[1], m_corners.m_min.m128_f32[1]),
+ std::min(pos.m128_f32[2], m_corners.m_min.m128_f32[2]),
1
};
- m_max =
+ m_corners.m_max =
{
- std::max(pos.m128_f32[0], *m_max.m128_f32),
- std::max(pos.m128_f32[1], m_max.m128_f32[1]),
- std::max(pos.m128_f32[2], m_max.m128_f32[2]),
+ std::max(pos.m128_f32[0], *m_corners.m_max.m128_f32),
+ std::max(pos.m128_f32[1], m_corners.m_max.m128_f32[1]),
+ std::max(pos.m128_f32[2], m_corners.m_max.m128_f32[2]),
1
};
}
AABB::AABB() :
-
- m_min
- {
- std::numeric_limits::max(),
- std::numeric_limits::max(),
- std::numeric_limits::max()
- },
-
- m_max
+ m_corners
{
- -std::numeric_limits::max(),
- -std::numeric_limits::max(),
- -std::numeric_limits::max()
+ {
+ std::numeric_limits::max(),
+ std::numeric_limits::max(),
+ std::numeric_limits::max()
+ },
+ {
+ -std::numeric_limits::max(),
+ -std::numeric_limits::max(),
+ -std::numeric_limits::max()
+ }
}
{
}
- AABB::AABB(DirectX::XMVECTOR min, DirectX::XMVECTOR max) : m_min(m_min), m_max(m_max)
+ AABB::AABB(DirectX::XMVECTOR min, DirectX::XMVECTOR max) : m_corners{ min, max }
{
}
@@ -105,7 +104,7 @@ namespace wr
//Transform all coords from model to world space
//Pick the min/max bounds
- for (DirectX::XMVECTOR& vec : box.m_corners)
+ for (DirectX::XMVECTOR& vec : box.m_data)
{
DirectX::XMVECTOR tvec = DirectX::XMVector4Transform(vec, transform);
aabb.Expand(tvec);
@@ -117,34 +116,34 @@ namespace wr
void Box::ExpandFromVector(DirectX::XMVECTOR pos)
{
- if (pos.m128_f32[0] < m_xmin.m128_f32[0])
+ if (pos.m128_f32[0] < m_corners.m_xmin.m128_f32[0])
{
- m_xmin = pos;
+ m_corners.m_xmin = pos;
}
- if (pos.m128_f32[0] > m_xmax.m128_f32[0])
+ if (pos.m128_f32[0] > m_corners.m_xmax.m128_f32[0])
{
- m_xmax = pos;
+ m_corners.m_xmax = pos;
}
- if (pos.m128_f32[1] < m_ymin.m128_f32[1])
+ if (pos.m128_f32[1] < m_corners.m_ymin.m128_f32[1])
{
- m_ymin = pos;
+ m_corners.m_ymin = pos;
}
- if (pos.m128_f32[1] > m_ymax.m128_f32[1])
+ if (pos.m128_f32[1] > m_corners.m_ymax.m128_f32[1])
{
- m_ymax = pos;
+ m_corners.m_ymax = pos;
}
- if (pos.m128_f32[2] < m_zmin.m128_f32[2])
+ if (pos.m128_f32[2] < m_corners.m_zmin.m128_f32[2])
{
- m_zmin = pos;
+ m_corners.m_zmin = pos;
}
- if (pos.m128_f32[2] > m_zmax.m128_f32[2])
+ if (pos.m128_f32[2] > m_corners.m_zmax.m128_f32[2])
{
- m_zmax = pos;
+ m_corners.m_zmax = pos;
}
}
@@ -160,9 +159,9 @@ namespace wr
/* Get point of AABB that's into the plane the most */
DirectX::XMVECTOR axis_vert = {
- *m_bounds[*plane.m128_f32 >= 0].m128_f32,
- m_bounds[plane.m128_f32[1] >= 0].m128_f32[1],
- m_bounds[plane.m128_f32[2] >= 0].m128_f32[2]
+ *m_data[*plane.m128_f32 >= 0].m128_f32,
+ m_data[plane.m128_f32[1] >= 0].m128_f32[1],
+ m_data[plane.m128_f32[2] >= 0].m128_f32[2]
};
/* Check if it's outside */
diff --git a/src/util/aabb.hpp b/src/util/aabb.hpp
index d267e33c..4dc6aab3 100644
--- a/src/util/aabb.hpp
+++ b/src/util/aabb.hpp
@@ -5,20 +5,17 @@
namespace wr
{
-
struct Box
{
+ struct Corners
+ {
+ DirectX::XMVECTOR m_xmin, m_xmax, m_ymin, m_ymax, m_zmin, m_zmax;
+ };
union
{
-
- struct
- {
- DirectX::XMVECTOR m_xmin, m_xmax, m_ymin, m_ymax, m_zmin, m_zmax;
- };
-
- DirectX::XMVECTOR m_corners[6];
-
+ Corners m_corners;
+ DirectX::XMVECTOR m_data[6];
};
//Max bounds on each corner
@@ -37,17 +34,15 @@ namespace wr
struct AABB
{
+ struct Corners
+ {
+ DirectX::XMVECTOR m_min, m_max;
+ };
union
{
-
- struct
- {
- DirectX::XMVECTOR m_min, m_max;
- };
-
- DirectX::XMVECTOR m_bounds[2];
-
+ Corners m_corners;
+ DirectX::XMVECTOR m_data[6];
};
AABB();
diff --git a/src/util/bitmap_allocator.hpp b/src/util/bitmap_allocator.hpp
index b6c04b7e..0d45320e 100644
--- a/src/util/bitmap_allocator.hpp
+++ b/src/util/bitmap_allocator.hpp
@@ -115,7 +115,7 @@ namespace util
}
//Have we found enough free pages? If so, break
- if (found == true)
+ if (found)
{
break;
}
diff --git a/src/util/delegate.hpp b/src/util/delegate.hpp
index eb96e422..86e8cefa 100644
--- a/src/util/delegate.hpp
+++ b/src/util/delegate.hpp
@@ -23,7 +23,12 @@ namespace util
}
public:
- Delegate() = default;
+ Delegate() :
+ m_object_ptr(),
+ m_deleter(),
+ m_store_size()
+ {
+ }
Delegate(Delegate const&) = default;
@@ -117,7 +122,8 @@ namespace util
{
using functor_type = typename ::std::decay::type;
- if ((sizeof(functor_type) > m_store_size) || !m_store.unique())
+ // Note that use_count is an approximation in multithreaded environments.
+ if ((sizeof(functor_type) > m_store_size) || m_store.use_count() != 1)
{
m_store.reset(operator new(sizeof(functor_type)),
functor_deleter);
diff --git a/src/util/file_watcher.cpp b/src/util/file_watcher.cpp
index 2bbab173..f596a3df 100644
--- a/src/util/file_watcher.cpp
+++ b/src/util/file_watcher.cpp
@@ -28,7 +28,7 @@ namespace util
}
}
- void FileWatcher::Start(util::Delegate const & callback)
+ void FileWatcher::Start(util::Delegate const & callback)
{
if (m_running)
{
@@ -90,7 +90,7 @@ namespace util
}
}
- void FileWatcher::StartAsync(util::Delegate const & callback)
+ void FileWatcher::StartAsync(util::Delegate const & callback)
{
if (m_running)
{
diff --git a/src/util/file_watcher.hpp b/src/util/file_watcher.hpp
index cb84a868..1adaa0bd 100644
--- a/src/util/file_watcher.hpp
+++ b/src/util/file_watcher.hpp
@@ -38,9 +38,9 @@ namespace util
~FileWatcher();
//! Launches the file watcher. This will stall the current thread.
- void Start(util::Delegate const & callback);
+ void Start(util::Delegate const & callback);
//! Launches the file watcher asynchrounously. When the file watcher goes out of scope the thread gets killed.
- void StartAsync(util::Delegate const & callback);
+ void StartAsync(util::Delegate const & callback);
private:
//! C++20's path::contains function.
diff --git a/src/util/log.hpp b/src/util/log.hpp
index 564bc3d5..06316454 100644
--- a/src/util/log.hpp
+++ b/src/util/log.hpp
@@ -17,8 +17,8 @@
#include
#endif
-#include "fmt/format.h"
-#include "fmt/chrono.h"
+#include
+#include
#ifdef LOG_CALLBACK
#include
@@ -36,21 +36,18 @@ namespace util
};
#endif
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#pragma warning(disable : 4100)
+
namespace util::internal
{
-#ifdef LOG_CALLBACK
- //struct callback
- //{
-
- //};
-#endif
-
enum class MSGB_ICON
{
- CRITICAL_ERROR = MB_OK | MB_ICONERROR
+ CRITICAL_ERROR = (unsigned)MB_OK | (unsigned)MB_ICONERROR
};
- template
+ template
inline void log_impl(int color, char type, std::string file, std::string func, int line, S const & format, Args const &... args)
{
std::string str = "";
@@ -146,9 +143,10 @@ namespace util::internal
break;
}
}
-
} /* internal */
+#pragma warning( pop )
+
#define LOG(csr, ...) { util::internal::log_impl(7, 'I', __FILE__, __func__, __LINE__, csr, ##__VA_ARGS__); }
#define LOGW(csr, ...) { util::internal::log_impl(6, 'W', __FILE__, __func__, __LINE__, csr, ##__VA_ARGS__); }
#define LOGE(csr, ...) { util::internal::log_impl(4, 'E', __FILE__, __func__, __LINE__, csr, ##__VA_ARGS__); }
diff --git a/src/util/math.hpp b/src/util/math.hpp
deleted file mode 100644
index a59c7ef4..00000000
--- a/src/util/math.hpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include
-
-namespace util
-{
-
- inline DirectX::XMMATRIX StripTranslationAndLowerVector(DirectX::XMMATRIX matrix)
- {
- DirectX::XMMATRIX upper3x3 = matrix;
- upper3x3.r[0].m128_f32[3] = 0.f;
- upper3x3.r[1].m128_f32[3] = 0.f;
- upper3x3.r[2].m128_f32[3] = 0.f;
- upper3x3.r[3].m128_f32[0] = 0.f;
- upper3x3.r[3].m128_f32[1] = 0.f;
- upper3x3.r[3].m128_f32[2] = 0.f;
- upper3x3.r[3].m128_f32[3] = 1.f;
-
- return upper3x3;
- }
-} /* util */
\ No newline at end of file
diff --git a/src/util/pair_hash.hpp b/src/util/pair_hash.hpp
index 5d829d44..adabe3f1 100644
--- a/src/util/pair_hash.hpp
+++ b/src/util/pair_hash.hpp
@@ -7,7 +7,7 @@ namespace util
template
std::size_t operator() (const std::pair &pair) const
{
- int hash = 0;
+ std::uint64_t hash = 0;
for(int i=0;i= dot_position) ? true : false;
+ return last_occurrence_pos >= dot_position;
}
}
\ No newline at end of file
diff --git a/src/util/user_literals.hpp b/src/util/user_literals.hpp
index 7629bc36..9472d8b8 100644
--- a/src/util/user_literals.hpp
+++ b/src/util/user_literals.hpp
@@ -20,12 +20,12 @@ constexpr float operator"" _rad(unsigned long long int rad)
return DirectX::XMConvertToDegrees(static_cast(rad));
}
-constexpr int operator"" _kb(unsigned long long int kilobytes)
+constexpr std::size_t operator"" _kb(std::size_t kilobytes)
{
return kilobytes * 1024;
}
-constexpr int operator"" _mb(unsigned long long int megabytes)
+constexpr std::size_t operator"" _mb(std::size_t megabytes)
{
return megabytes * 1024 * 1024;
}
\ No newline at end of file
diff --git a/src/window.cpp b/src/window.cpp
index cbb8c8fd..e121427a 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -19,8 +19,8 @@ namespace wr
wc.cbClsExtra = NULL;
wc.cbWndExtra = NULL;
wc.hInstance = instance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
+ wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = nullptr;
wc.lpszClassName = name.c_str();
@@ -60,7 +60,7 @@ namespace wr
if (!m_handle)
{
- LOGC("Failed to create window." + GetLastError());
+ LOGC("Failed to create window." + GetLastError())
}
SetWindowLongPtr(m_handle, GWLP_USERDATA, (LONG_PTR)this);
@@ -107,7 +107,7 @@ namespace wr
void Window::SetRenderLoop(std::function render_func)
{
- m_render_func = render_func;
+ m_render_func = std::move(render_func);
}
void Window::StartRenderLoop()
@@ -120,22 +120,22 @@ namespace wr
void Window::SetKeyCallback(KeyCallback callback)
{
- m_key_callback = callback;
+ m_key_callback = std::move(callback);
}
void Window::SetMouseCallback(MouseCallback callback)
{
- m_mouse_callback = callback;
+ m_mouse_callback = std::move(callback);
}
void Window::SetMouseWheelCallback(MouseWheelCallback callback)
{
- m_mouse_wheel_callback = callback;
+ m_mouse_wheel_callback = std::move(callback);
}
void Window::SetResizeCallback(ResizeCallback callback)
{
- m_resize_callback = callback;
+ m_resize_callback = std::move(callback);
}
bool Window::IsRunning() const
@@ -184,7 +184,7 @@ namespace wr
if (ImGui_ImplWin32_WndProcHandler(handle, msg, w_param, l_param))
return true;
- Window* window = (Window*)GetWindowLongPtr(handle, GWLP_USERDATA);
+ auto window = (Window*)GetWindowLongPtr(handle, GWLP_USERDATA);
if (window) return window->WindowProc_Impl(handle, msg, w_param, l_param);
return DefWindowProc(handle, msg, w_param, l_param);