From 7697df8d7a568e3b69b727e11a96549f26d93c76 Mon Sep 17 00:00:00 2001 From: Viktor Zoutman Date: Mon, 6 May 2019 22:22:05 +0200 Subject: [PATCH] Fixed the last warnings --- demo/debug_camera.hpp | 2 +- demo/engine_interface.hpp | 2 +- demo/scene_spheres.hpp | 2 +- demo/scene_viknell.hpp | 8 ++-- src/d3d12/d3d12_command_list.cpp | 4 +- src/d3d12/d3d12_functions.hpp | 4 +- src/imgui/imgui_impl_dx12.hpp | 4 +- src/render_tasks/d3d12_accumulation.hpp | 11 +++-- .../d3d12_brdf_lut_precalculation.hpp | 9 +--- .../d3d12_build_acceleration_structures.hpp | 45 ++++++++++--------- .../d3d12_cubemap_convolution.hpp | 12 ++--- src/render_tasks/d3d12_deferred_main.hpp | 4 +- .../d3d12_deferred_render_target_copy.hpp | 6 +-- .../d3d12_equirect_to_cubemap.hpp | 22 ++++----- src/render_tasks/d3d12_hbao.hpp | 14 +++--- src/render_tasks/d3d12_imgui_render_task.hpp | 5 +-- src/render_tasks/d3d12_path_tracer.hpp | 16 +++---- src/render_tasks/d3d12_raytracing_task.hpp | 21 ++++----- src/render_tasks/d3d12_rt_hybrid_task.hpp | 19 ++++---- src/scene_graph/camera_node.hpp | 4 +- src/util/aabb.cpp | 2 +- src/util/aabb.hpp | 3 +- src/util/pair_hash.hpp | 2 +- 23 files changed, 107 insertions(+), 114 deletions(-) diff --git a/demo/debug_camera.hpp b/demo/debug_camera.hpp index a12c46e6..4177ebde 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(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.01f), m_position_lerp_speed(10.f), m_rotation_lerp_speed(5.f) { GetCursorPos(&m_last_cursor_pos); m_target_rotation_radians = m_rotation_radians; diff --git a/demo/engine_interface.hpp b/demo/engine_interface.hpp index a0e353e5..42c0a904 100644 --- a/demo/engine_interface.hpp +++ b/demo/engine_interface.hpp @@ -71,7 +71,7 @@ namespace engine ImGui::EndMenu(); } - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 0.4)); + ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.f, 1.f, 1.f, 0.4f)); ImGui::Text("Current Frame Graph: %s", fg_manager::GetFrameGraphName(fg_manager::current).c_str()); ImGui::PopStyleColor(); diff --git a/demo/scene_spheres.hpp b/demo/scene_spheres.hpp index a265988f..56c56f9a 100644 --- a/demo/scene_spheres.hpp +++ b/demo/scene_spheres.hpp @@ -78,7 +78,7 @@ namespace spheres_scene void CreateScene(wr::SceneGraph* scene_graph, wr::Window* window) { - wr::Model* spheres[49]; + //wr::Model* spheres[49]; //for (uint32_t i = 0; i <= 6; ++i) //{ diff --git a/demo/scene_viknell.hpp b/demo/scene_viknell.hpp index d451eb4d..0b415805 100644 --- a/demo/scene_viknell.hpp +++ b/demo/scene_viknell.hpp @@ -131,16 +131,16 @@ namespace viknell_scene // Lights auto point_light_0 = scene_graph->CreateChild(nullptr, wr::LightType::DIRECTIONAL, DirectX::XMVECTOR{ 1, 1, 1 }); - point_light_0->SetRotation({20.950, 0.98, 0}); - point_light_0->SetPosition({-0.002, 0.080, 1.404}); + point_light_0->SetRotation({ 20.950f, 0.98f, 0.f }); + point_light_0->SetPosition({ -0.002f, 0.080f, 1.404f }); auto point_light_1 = scene_graph->CreateChild(nullptr, wr::LightType::POINT, DirectX::XMVECTOR{1, 0, 0}); point_light_1->SetRadius(5.0f); - point_light_1->SetPosition({0.5, 0, -0.3}); + point_light_1->SetPosition({ 0.5f, 0.f, -0.3f }); auto point_light_2 = scene_graph->CreateChild(nullptr, wr::LightType::POINT, DirectX::XMVECTOR{0, 0, 1}); point_light_2->SetRadius(5.0f); - point_light_2->SetPosition({-0.5, 0.5, -0.3}); + point_light_2->SetPosition({ -0.5f, 0.5f, -0.3f }); //auto dir_light = scene_graph->CreateChild(nullptr, wr::LightType::DIRECTIONAL, DirectX::XMVECTOR{ 1, 1, 1 }); } diff --git a/src/d3d12/d3d12_command_list.cpp b/src/d3d12/d3d12_command_list.cpp index 8c63a84f..ead43390 100644 --- a/src/d3d12/d3d12_command_list.cpp +++ b/src/d3d12/d3d12_command_list.cpp @@ -317,7 +317,7 @@ namespace wr::d3d12 cmd_list->m_native->IASetPrimitiveTopology(topology); } - void Draw(CommandList* cmd_list, unsigned int vertex_count, unsigned int inst_count, unsigned int vertex_start) + void Draw(CommandList* cmd_list, std::uint32_t vertex_count, std::uint32_t inst_count, std::uint32_t vertex_start) { for (int i = 0; i < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++i) { @@ -327,7 +327,7 @@ namespace wr::d3d12 cmd_list->m_native->DrawInstanced(vertex_count, inst_count, vertex_start, 0); } - void DrawIndexed(CommandList* cmd_list, unsigned int idx_count, unsigned int inst_count, unsigned int idx_start, unsigned int vertex_start) + void DrawIndexed(CommandList* cmd_list, std::uint32_t idx_count, std::uint32_t inst_count, std::uint32_t idx_start, std::uint32_t vertex_start) { for (int i = 0; i < D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES; ++i) { diff --git a/src/d3d12/d3d12_functions.hpp b/src/d3d12/d3d12_functions.hpp index 30f9ed89..8d666672 100644 --- a/src/d3d12/d3d12_functions.hpp +++ b/src/d3d12/d3d12_functions.hpp @@ -55,8 +55,8 @@ namespace wr::d3d12 //void Bind(CommandList& cmd_list, std::vector const & heaps); void BindVertexBuffer(CommandList* cmd_list, StagingBuffer* buffer, std::size_t offset, std::size_t size, std::size_t m_stride); void BindIndexBuffer(CommandList* cmd_list, StagingBuffer* buffer, unsigned int offset, unsigned int size); - void Draw(CommandList* cmd_list, unsigned int vertex_count, unsigned int inst_count, unsigned int vertex_start); - void DrawIndexed(CommandList* cmd_list, unsigned int idx_count, unsigned int inst_count, unsigned int idx_start, unsigned int vertex_start); + void Draw(CommandList* cmd_list, std::uint32_t vertex_count, std::uint32_t inst_count, std::uint32_t vertex_start); + void DrawIndexed(CommandList* cmd_list, std::uint32_t idx_count, std::uint32_t inst_count, std::uint32_t idx_start, std::uint32_t vertex_start); void Dispatch(CommandList* cmd_list, unsigned int thread_group_count_x, unsigned int thread_group_count_y, unsigned int thread_group_count_z); void Transition(CommandList* cmd_list, RenderTarget* render_target, unsigned int frame_index, ResourceState from, ResourceState to); void Transition(CommandList* cmd_list, RenderTarget* render_target, ResourceState from, ResourceState to); diff --git a/src/imgui/imgui_impl_dx12.hpp b/src/imgui/imgui_impl_dx12.hpp index efdd2c9a..18220b67 100644 --- a/src/imgui/imgui_impl_dx12.hpp +++ b/src/imgui/imgui_impl_dx12.hpp @@ -12,7 +12,9 @@ #pragma once -enum DXGI_FORMAT; +#include + +enum DXGI_FORMAT : std::int32_t; struct ID3D12Device; struct ID3D12GraphicsCommandList; struct D3D12_CPU_DESCRIPTOR_HANDLE; diff --git a/src/render_tasks/d3d12_accumulation.hpp b/src/render_tasks/d3d12_accumulation.hpp index aed76187..79396f87 100644 --- a/src/render_tasks/d3d12_accumulation.hpp +++ b/src/render_tasks/d3d12_accumulation.hpp @@ -60,7 +60,7 @@ namespace wr } } - inline void ExecuteAccumulationTask(RenderSystem& rs, FrameGraph& fg, SceneGraph& sg, RenderTaskHandle handle) + inline void ExecuteAccumulationTask(RenderSystem& rs, FrameGraph& fg, SceneGraph&, RenderTaskHandle handle) { auto& n_render_system = static_cast(rs); auto& device = n_render_system.m_device; @@ -81,9 +81,12 @@ namespace wr bool is_fallback = d3d12::GetRaytracingType(device) == RaytracingType::FALLBACK; d3d12::BindDescriptorHeaps(cmd_list, frame_idx, is_fallback); - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(data.out_source_rt->m_render_targets[frame_idx % 1 /*versions*/])); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(data.out_source_rt->m_render_targets[frame_idx % 1 /*versions*/]); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } - auto& path_tracer_data = fg.GetPredecessorData(); + fg.GetPredecessorData(); float samples = n_render_system.temp_rough; d3d12::BindCompute32BitConstants(cmd_list, &samples, 1, 0, 1); @@ -94,7 +97,7 @@ namespace wr 1); } - inline void DestroyAccumulation(FrameGraph& fg, RenderTaskHandle handle, bool resize) + inline void DestroyAccumulation(FrameGraph& fg, RenderTaskHandle handle, bool) { auto& data = fg.GetData(handle); diff --git a/src/render_tasks/d3d12_brdf_lut_precalculation.hpp b/src/render_tasks/d3d12_brdf_lut_precalculation.hpp index 6f219db2..d1e41db0 100644 --- a/src/render_tasks/d3d12_brdf_lut_precalculation.hpp +++ b/src/render_tasks/d3d12_brdf_lut_precalculation.hpp @@ -42,7 +42,7 @@ namespace wr } } - inline void ExecuteBrdfLutPrecalculationTask(RenderSystem& rs, FrameGraph& fg, SceneGraph& scene_graph, RenderTaskHandle handle) + inline void ExecuteBrdfLutPrecalculationTask(RenderSystem& rs, FrameGraph& fg, SceneGraph&, RenderTaskHandle handle) { auto& n_render_system = static_cast(rs); auto& data = fg.GetData(handle); @@ -66,10 +66,6 @@ namespace wr n_render_system.m_brdf_lut_generated = true; } } - - inline void DestroyBrdfLutPrecalculationTask(FrameGraph& fg, RenderTaskHandle handle, bool resize) - { - } } inline void AddBrdfLutPrecalculationTask(FrameGraph& fg) @@ -99,8 +95,7 @@ namespace wr desc.m_execute_func = [](RenderSystem& rs, FrameGraph& fg, SceneGraph& sg, RenderTaskHandle handle) { internal::ExecuteBrdfLutPrecalculationTask(rs, fg, sg, handle); }; - desc.m_destroy_func = [](FrameGraph& fg, RenderTaskHandle handle, bool resize) { - internal::DestroyBrdfLutPrecalculationTask(fg, handle, resize); + desc.m_destroy_func = [](FrameGraph&, RenderTaskHandle, bool) { }; desc.m_properties = rt_properties; diff --git a/src/render_tasks/d3d12_build_acceleration_structures.hpp b/src/render_tasks/d3d12_build_acceleration_structures.hpp index 7829c1f6..fa7d9990 100644 --- a/src/render_tasks/d3d12_build_acceleration_structures.hpp +++ b/src/render_tasks/d3d12_build_acceleration_structures.hpp @@ -26,7 +26,7 @@ namespace wr std::vector> out_blas_list; std::vector out_materials; std::vector out_offsets; - std::unordered_map out_parsed_materials; + std::unordered_map out_parsed_materials; std::vector out_material_handles; d3d12::StagingBuffer* out_scene_ib; d3d12::StagingBuffer* out_scene_vb; @@ -51,7 +51,6 @@ namespace wr if (resize) return; 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); d3d12::SetName(n_render_target, L"Raytracing Target"); @@ -89,7 +88,7 @@ namespace wr //! Get a material id from a mesh. inline unsigned int ExtractMaterialFromMesh(ASBuildData& data, MaterialHandle material_handle) { - unsigned int material_id = 0; + std::size_t material_id = 0; if (data.out_parsed_materials.find(material_handle.m_id) == data.out_parsed_materials.end()) { material_id = data.out_materials.size(); @@ -98,10 +97,10 @@ namespace wr // Build material wr::temp::RayTracingMaterial_CBData material; - material.albedo_id = material_internal->GetAlbedo().m_id; - material.normal_id = material_internal->GetNormal().m_id; - material.roughness_id = material_internal->GetRoughness().m_id; - material.metallicness_id = material_internal->GetMetallic().m_id; + material.albedo_id = static_cast(material_internal->GetAlbedo().m_id); + material.normal_id = static_cast(material_internal->GetNormal().m_id); + material.roughness_id = static_cast(material_internal->GetRoughness().m_id); + material.metallicness_id = static_cast(material_internal->GetMetallic().m_id); material.material_data = material_internal->GetMaterialData(); data.out_materials.push_back(material); data.out_parsed_materials[material_handle.m_id] = material_id; @@ -113,7 +112,7 @@ namespace wr material_id = data.out_parsed_materials[material_handle.m_id]; } - return material_id; + return static_cast(material_id); } //! Add a data struct describing the mesh data offset and the material idx to `out_offsets` @@ -121,8 +120,8 @@ namespace wr { wr::temp::RayTracingOffset_CBData offset; 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; + offset.idx_offset = static_cast(mesh->m_index_staging_buffer_offset); + offset.vertex_offset = static_cast(mesh->m_vertex_staging_buffer_offset); data.out_offsets.push_back(offset); } @@ -151,7 +150,10 @@ namespace wr // Build Bottom level BVH auto blas = d3d12::CreateBottomLevelAccelerationStructures(device, cmd_list, out_heap, { obj }); - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(blas.m_native)); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(blas.m_native); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } blas.m_native->SetName(L"Bottomlevelaccel"); data.blasses.insert({ mesh_material.first->id, blas }); @@ -220,7 +222,10 @@ namespace wr // Build Bottom level BVH auto blas = d3d12::CreateBottomLevelAccelerationStructures(device, cmd_list, out_heap, { obj }); - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(blas.m_native)); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(blas.m_native); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } blas.m_native->SetName(L"Bottomlevelaccel"); data.blasses.insert({ mesh.first->id, blas }); @@ -231,12 +236,12 @@ namespace wr AppendOffset(data, n_mesh, material_id); - auto it = batchInfo.find({ model, materials }); + auto batch_it = batchInfo.find({ model, materials }); - assert(it != batchInfo.end(), "Batch was found in global array, but not in local"); + assert(batch_it != batchInfo.end() && "Batch was found in global array, but not in local"); // Push instances into a array for later use. - for (uint32_t i = 0U, j = (uint32_t)it->second.num_global_instances; i < j; i++) + for (uint32_t i = 0U, j = (uint32_t)batch_it->second.num_global_instances; i < j; i++) { auto transform = batch.second[i].m_model; @@ -258,7 +263,7 @@ namespace wr } } - inline void CreateSRVs(d3d12::CommandList* cmd_list, ASBuildData& data) + inline void CreateSRVs(ASBuildData& data) { for (auto i = 0; i < d3d12::settings::num_back_buffers; i++) { @@ -339,7 +344,7 @@ namespace wr d3d12::Transition(cmd_list, pool->GetIndexStagingBuffer(), ResourceState::NON_PIXEL_SHADER_RESOURCE, ResourceState::INDEX_BUFFER); } - CreateSRVs(cmd_list, data); + CreateSRVs(data); } @@ -388,7 +393,7 @@ namespace wr d3d12::Transition(cmd_list, n_model_pool->GetVertexStagingBuffer(), ResourceState::NON_PIXEL_SHADER_RESOURCE, ResourceState::VERTEX_AND_CONSTANT_BUFFER); d3d12::Transition(cmd_list, n_model_pool->GetIndexStagingBuffer(), ResourceState::NON_PIXEL_SHADER_RESOURCE, ResourceState::INDEX_BUFFER); - CreateSRVs(cmd_list, data); + CreateSRVs(data); blas_iterator = data.blasses.find(mesh.first->id); } @@ -401,7 +406,7 @@ namespace wr auto it = batchInfo.find({ model, materials }); - assert(it != batchInfo.end(), "Batch was found in global array, but not in local"); + assert(it != batchInfo.end() && "Batch was found in global array, but not in local"); // Push instances into a array for later use. for (uint32_t i = 0U, j = (uint32_t)it->second.num_global_instances; i < j; i++) @@ -465,7 +470,7 @@ namespace wr d3d12::Transition(cmd_list, pool->GetIndexStagingBuffer(), ResourceState::NON_PIXEL_SHADER_RESOURCE, ResourceState::INDEX_BUFFER); } - internal::CreateSRVs(cmd_list, data); + internal::CreateSRVs(data); data.out_init = false; } diff --git a/src/render_tasks/d3d12_cubemap_convolution.hpp b/src/render_tasks/d3d12_cubemap_convolution.hpp index 585f5901..2227becb 100644 --- a/src/render_tasks/d3d12_cubemap_convolution.hpp +++ b/src/render_tasks/d3d12_cubemap_convolution.hpp @@ -50,7 +50,6 @@ namespace wr return; } - auto& n_render_system = static_cast(rs); auto& data = fg.GetData(handle); auto& ps_registry = PipelineRegistry::Get(); @@ -115,10 +114,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(irradiance->m_width, irradiance->m_height); - + const auto viewport = d3d12::CreateViewport(static_cast(irradiance->m_width), static_cast(irradiance->m_height)); const auto frame_idx = n_render_system.GetRenderWindow()->m_frame_idx; d3d12::BindViewport(cmd_list, viewport); @@ -168,11 +164,11 @@ namespace wr if (n_mesh->m_index_count != 0) { - d3d12::DrawIndexed(cmd_list, n_mesh->m_index_count, 1, n_mesh->m_index_staging_buffer_offset, n_mesh->m_vertex_staging_buffer_offset); + d3d12::DrawIndexed(cmd_list, static_cast(n_mesh->m_index_count), 1, static_cast(n_mesh->m_index_staging_buffer_offset), static_cast(n_mesh->m_vertex_staging_buffer_offset)); } else { - d3d12::Draw(cmd_list, n_mesh->m_vertex_count, 1, n_mesh->m_vertex_staging_buffer_offset); + d3d12::Draw(cmd_list, static_cast(n_mesh->m_vertex_count), 1, static_cast(n_mesh->m_vertex_staging_buffer_offset)); } } } @@ -214,7 +210,7 @@ namespace wr desc.m_execute_func = [](RenderSystem& rs, FrameGraph& fg, SceneGraph& sg, RenderTaskHandle handle) { internal::ExecuteCubemapConvolutionTask(rs, fg, sg, handle); }; - desc.m_destroy_func = [](FrameGraph& fg, RenderTaskHandle handle, bool resize) { + desc.m_destroy_func = [](FrameGraph&, RenderTaskHandle, bool) { }; desc.m_properties = rt_properties; diff --git a/src/render_tasks/d3d12_deferred_main.hpp b/src/render_tasks/d3d12_deferred_main.hpp index 89ecc755..e85a44c0 100644 --- a/src/render_tasks/d3d12_deferred_main.hpp +++ b/src/render_tasks/d3d12_deferred_main.hpp @@ -26,9 +26,8 @@ namespace wr namespace internal { - inline void SetupDeferredTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle) + inline void SetupDeferredTask(RenderSystem&, FrameGraph& fg, RenderTaskHandle handle) { - auto& n_render_system = static_cast(rs); auto& data = fg.GetData(handle); auto& ps_registry = PipelineRegistry::Get(); @@ -40,7 +39,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); if (n_render_system.m_render_window.has_value()) { diff --git a/src/render_tasks/d3d12_deferred_render_target_copy.hpp b/src/render_tasks/d3d12_deferred_render_target_copy.hpp index bfd1b193..e38d64d4 100644 --- a/src/render_tasks/d3d12_deferred_render_target_copy.hpp +++ b/src/render_tasks/d3d12_deferred_render_target_copy.hpp @@ -51,9 +51,7 @@ namespace wr inline void AddRenderTargetCopyTask(FrameGraph& frame_graph) { std::string name_temp = std::string("Render Target (") + std::string(typeid(T).name()) + std::string(") Copy task"); - - std::wstring_convert> converter; - std::wstring wide = converter.from_bytes(name_temp.c_str()); + std::wstring w_name(name_temp.begin(), name_temp.end()); RenderTargetProperties rt_properties{ RenderTargetProperties::IsRenderWindow(true), @@ -67,7 +65,7 @@ namespace wr RenderTargetProperties::NumRTVFormats(1), RenderTargetProperties::Clear(false), RenderTargetProperties::ClearDepth(false), - RenderTargetProperties::ResourceName(wide) + RenderTargetProperties::ResourceName(w_name) }; RenderTaskDesc desc; diff --git a/src/render_tasks/d3d12_equirect_to_cubemap.hpp b/src/render_tasks/d3d12_equirect_to_cubemap.hpp index 22d2c978..a30a2e71 100644 --- a/src/render_tasks/d3d12_equirect_to_cubemap.hpp +++ b/src/render_tasks/d3d12_equirect_to_cubemap.hpp @@ -66,17 +66,14 @@ namespace wr for (uint32_t src_mip = 0; src_mip < dest_cubemap->m_mip_levels; ++src_mip) { - uint32_t width = dest_cubemap->m_width >> src_mip; - uint32_t height = dest_cubemap->m_height >> src_mip; + uint32_t width = static_cast(dest_cubemap->m_width) >> src_mip; + uint32_t height = static_cast(dest_cubemap->m_height) >> src_mip; - prefilter_env_cb.texture_size = DirectX::XMFLOAT2((float)width, (float)height); - prefilter_env_cb.skybox_res = DirectX::XMFLOAT2((float)source_cubemap->m_width, (float)source_cubemap->m_height); - prefilter_env_cb.roughness = (float)(src_mip) / (float)(dest_cubemap->m_mip_levels); + prefilter_env_cb.texture_size = DirectX::XMFLOAT2(static_cast(width), static_cast(height)); + prefilter_env_cb.skybox_res = DirectX::XMFLOAT2(static_cast(source_cubemap->m_width), static_cast(source_cubemap->m_height)); + prefilter_env_cb.roughness = static_cast(src_mip) / static_cast(dest_cubemap->m_mip_levels); prefilter_env_cb.cubemap_face = array_slice; - //Create views - //d3d12::CreateSRVFromCubemapFace(texture, srv_handle, 1, src_mip, array_slice); - DescriptorAllocation uav_alloc = alloc->Allocate(); d3d12::DescHeapCPUHandle uav_handle = uav_alloc.GetDescriptorHandle(); @@ -129,7 +126,6 @@ namespace wr return; } - auto& n_render_system = static_cast(rs); auto& data = fg.GetData(handle); auto& ps_registry = PipelineRegistry::Get(); @@ -193,7 +189,7 @@ namespace wr if (n_render_system.m_render_window.has_value()) { auto cmd_list = fg.GetCommandList(handle); - const auto viewport = d3d12::CreateViewport(cubemap_text->m_width, cubemap_text->m_height); + const auto viewport = d3d12::CreateViewport(static_cast(cubemap_text->m_width), static_cast(cubemap_text->m_height)); const auto frame_idx = n_render_system.GetRenderWindow()->m_frame_idx; d3d12::BindViewport(cmd_list, viewport); @@ -243,11 +239,11 @@ namespace wr if (n_mesh->m_index_count != 0) { - d3d12::DrawIndexed(cmd_list, n_mesh->m_index_count, 1, n_mesh->m_index_staging_buffer_offset, n_mesh->m_vertex_staging_buffer_offset); + d3d12::DrawIndexed(cmd_list, static_cast(n_mesh->m_index_count), 1, static_cast(n_mesh->m_index_staging_buffer_offset), static_cast(n_mesh->m_vertex_staging_buffer_offset)); } else { - d3d12::Draw(cmd_list, n_mesh->m_vertex_count, 1, n_mesh->m_vertex_staging_buffer_offset); + d3d12::Draw(cmd_list, static_cast(n_mesh->m_vertex_count), 1, static_cast(n_mesh->m_vertex_staging_buffer_offset)); } } } @@ -303,7 +299,7 @@ namespace wr desc.m_execute_func = [](RenderSystem& rs, FrameGraph& fg, SceneGraph& sg, RenderTaskHandle handle) { internal::ExecuteEquirectToCubemapTask(rs, fg, sg, handle); }; - desc.m_destroy_func = [](FrameGraph& fg, RenderTaskHandle handle, bool resize) { + desc.m_destroy_func = [](FrameGraph&, RenderTaskHandle, bool) { }; desc.m_properties = rt_properties; diff --git a/src/render_tasks/d3d12_hbao.hpp b/src/render_tasks/d3d12_hbao.hpp index a789a11a..490539ee 100644 --- a/src/render_tasks/d3d12_hbao.hpp +++ b/src/render_tasks/d3d12_hbao.hpp @@ -49,7 +49,7 @@ namespace wr namespace internal { - inline void SetupHBAOTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle, bool resize) + inline void SetupHBAOTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle, bool) { #ifdef NVIDIA_GAMEWORKS_HBAO auto& n_render_system = static_cast(rs); @@ -142,12 +142,12 @@ namespace wr // Set the viewport data.ssao_input_data.DepthData.Viewport.Enable = true; - 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); + 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; diff --git a/src/render_tasks/d3d12_imgui_render_task.hpp b/src/render_tasks/d3d12_imgui_render_task.hpp index 7fa65c80..7653e968 100644 --- a/src/render_tasks/d3d12_imgui_render_task.hpp +++ b/src/render_tasks/d3d12_imgui_render_task.hpp @@ -22,10 +22,9 @@ namespace wr namespace internal { - inline void SetupImGuiTask(RenderSystem& rs, FrameGraph& fg, RenderTaskHandle handle, bool resize) + inline void SetupImGuiTask(RenderSystem& rs, FrameGraph&, RenderTaskHandle, bool resize) { auto& n_render_system = static_cast(rs); - auto& data = fg.GetData(handle); if (!n_render_system.m_window.has_value()) { @@ -121,7 +120,7 @@ namespace wr } } - inline void DestroyImGuiTask(FrameGraph& fg, RenderTaskHandle, bool resize) + inline void DestroyImGuiTask(FrameGraph&, RenderTaskHandle, bool resize) { if (resize) { diff --git a/src/render_tasks/d3d12_path_tracer.hpp b/src/render_tasks/d3d12_path_tracer.hpp index 22389a3f..f227e76e 100644 --- a/src/render_tasks/d3d12_path_tracer.hpp +++ b/src/render_tasks/d3d12_path_tracer.hpp @@ -128,8 +128,6 @@ namespace wr if (!resize) { - auto cmd_list = fg.GetCommandList(handle); - // Get AS build data auto& as_build_data = fg.GetPredecessorData(); @@ -140,9 +138,6 @@ namespace wr data.tlas_requires_init = true; } - // Get AS build data - auto& as_build_data = fg.GetPredecessorData(); - // Versioning for (int frame_idx = 0; frame_idx < 1; ++frame_idx) { @@ -154,8 +149,6 @@ namespace wr d3d12::DescHeapCPUHandle gbuffers_handle = data.out_gbuffers.GetDescriptorHandle(); d3d12::DescHeapCPUHandle depth_buffer_handle = data.out_depthbuffer.GetDescriptorHandle(); - //cpu_handle = d3d12::GetCPUHandle(as_build_data.out_rt_heap, frame_idx, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::rt_hybrid, params::RTHybridE::GBUFFERS))); - auto deferred_main_rt = data.out_deferred_main_rt = static_cast(fg.GetPredecessorRenderTarget()); d3d12::CreateSRVFromRTV(deferred_main_rt, gbuffers_handle, 2, deferred_main_rt->m_create_info.m_rtv_formats.data()); d3d12::CreateSRVFromDSV(deferred_main_rt, depth_buffer_handle); @@ -208,7 +201,10 @@ namespace wr } // Wait for AS to be built - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native)); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } if (n_render_system.m_render_window.has_value()) { @@ -265,7 +261,7 @@ namespace wr for (size_t i = 0; i < num_textures_in_heap; ++i) { - d3d12::SetRTShaderSRV(cmd_list, 0, heap_loc_start + i, texture_resource); + d3d12::SetRTShaderSRV(cmd_list, 0, static_cast(heap_loc_start + i), texture_resource); } } @@ -278,7 +274,7 @@ namespace wr { 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); + d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::rt_hybrid, params::RTHybridE::TEXTURES)) + static_cast(texture_handle.m_id), texture_internal); }; set_srv(material_internal->GetAlbedo()); diff --git a/src/render_tasks/d3d12_raytracing_task.hpp b/src/render_tasks/d3d12_raytracing_task.hpp index 9bd5ebdf..32f6b939 100644 --- a/src/render_tasks/d3d12_raytracing_task.hpp +++ b/src/render_tasks/d3d12_raytracing_task.hpp @@ -117,8 +117,6 @@ namespace wr if (!resize) { - auto cmd_list = fg.GetCommandList(handle); - // Pipeline State Object auto& rt_registry = RTPipelineRegistry::Get(); data.out_state_object = static_cast(rt_registry.Find(state_objects::state_object))->m_native; @@ -139,8 +137,8 @@ namespace wr for (auto frame_idx = 0; frame_idx < 1; frame_idx++) { - d3d12::DescHeapCPUHandle handle = data.out_uav_from_rtv.GetDescriptorHandle(); - d3d12::CreateUAVFromSpecificRTV(n_render_target, handle, frame_idx, n_render_target->m_create_info.m_rtv_formats[frame_idx]); + d3d12::DescHeapCPUHandle desc_handle = data.out_uav_from_rtv.GetDescriptorHandle(); + d3d12::CreateUAVFromSpecificRTV(n_render_target, desc_handle, frame_idx, n_render_target->m_create_info.m_rtv_formats[frame_idx]); } CreateShaderTables(device, data, 0); @@ -156,11 +154,14 @@ namespace wr auto cmd_list = fg.GetCommandList(handle); auto& data = fg.GetData(handle); auto& as_build_data = fg.GetPredecessorData(); - const auto& convolution_data = fg.GetPredecessorData(); + fg.GetPredecessorData(); d3d12::CreateOrUpdateTLAS(device, cmd_list, data.tlas_requires_init, data.out_tlas, as_build_data.out_blas_list); - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native)); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } if (n_render_system.m_render_window.has_value()) { @@ -201,20 +202,20 @@ namespace wr for (size_t i = 0; i < num_textures_in_heap; ++i) { - d3d12::SetRTShaderSRV(cmd_list, 0, heap_loc_start + i, texture_resource); + d3d12::SetRTShaderSRV(cmd_list, 0, static_cast(heap_loc_start + i), texture_resource); } } // Fill descriptor heap with textures used by the scene - for (auto handle : as_build_data.out_material_handles) + for (auto material_handle : as_build_data.out_material_handles) { - auto* material_internal = handle.m_pool->GetMaterial(handle); + 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::full_raytracing, params::FullRaytracingE::TEXTURES)) + texture_handle.m_id, texture_internal); + d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::full_raytracing, params::FullRaytracingE::TEXTURES)) + static_cast(texture_handle.m_id), texture_internal); }; if (!material_internal->UsesConstantAlbedo()) diff --git a/src/render_tasks/d3d12_rt_hybrid_task.hpp b/src/render_tasks/d3d12_rt_hybrid_task.hpp index 1e565758..0f5a2631 100644 --- a/src/render_tasks/d3d12_rt_hybrid_task.hpp +++ b/src/render_tasks/d3d12_rt_hybrid_task.hpp @@ -124,8 +124,6 @@ namespace wr if (!resize) { - auto cmd_list = fg.GetCommandList(handle); - // Get AS build data auto& as_build_data = fg.GetPredecessorData(); @@ -186,12 +184,15 @@ namespace wr auto cmd_list = fg.GetCommandList(handle); auto& data = fg.GetData(handle); auto& as_build_data = fg.GetPredecessorData(); - const auto& convolution_data = fg.GetPredecessorData(); + fg.GetPredecessorData(); d3d12::CreateOrUpdateTLAS(device, cmd_list, data.tlas_requires_init, data.out_tlas, as_build_data.out_blas_list); // Wait for AS to be built - cmd_list->m_native->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native)); + { + auto barrier = CD3DX12_RESOURCE_BARRIER::UAV(as_build_data.out_tlas.m_native); + cmd_list->m_native->ResourceBarrier(1, &barrier); + } if (n_render_system.m_render_window.has_value()) { @@ -247,20 +248,20 @@ namespace wr for (size_t i = 0; i < num_textures_in_heap; ++i) { - d3d12::SetRTShaderSRV(cmd_list, 0, heap_loc_start + i, texture_resource); + d3d12::SetRTShaderSRV(cmd_list, 0, static_cast(heap_loc_start + i), texture_resource); } } // Fill descriptor heap with textures used by the scene - for (auto handle : as_build_data.out_material_handles) + for (auto material_handle : as_build_data.out_material_handles) { - auto* material_internal = handle.m_pool->GetMaterial(handle); + 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); + d3d12::SetRTShaderSRV(cmd_list, 0, COMPILATION_EVAL(rs_layout::GetHeapLoc(params::rt_hybrid, params::RTHybridE::TEXTURES)) + static_cast(texture_handle.m_id), texture_internal); }; if(!material_internal->UsesConstantAlbedo()) @@ -305,7 +306,7 @@ namespace wr 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); cam_data.m_intensity = n_render_system.temp_intensity; - cam_data.m_frame_idx = ++data.frame_idx; + cam_data.m_frame_idx = static_cast(++data.frame_idx); n_render_system.m_camera_pool->Update(data.out_cb_camera_handle, sizeof(temp::RTHybridCamera_CBData), 0, frame_idx, (std::uint8_t*)&cam_data); // FIXME: Uhh wrong pool? // Make sure the convolution pass wrote to the skybox. diff --git a/src/scene_graph/camera_node.hpp b/src/scene_graph/camera_node.hpp index f582e6dd..380ec12e 100644 --- a/src/scene_graph/camera_node.hpp +++ b/src/scene_graph/camera_node.hpp @@ -2,6 +2,8 @@ #include "node.hpp" +#include + #include "../util/named_type.hpp" #include "../constant_buffer_pool.hpp" @@ -99,7 +101,7 @@ namespace wr float m_projection_offset_x; // Used By Ansel For Super Resolution float m_projection_offset_y; // Used By Ansel For Super Resolution - DirectX::XMVECTOR m_planes[6]; + std::array m_planes; ConstantBufferHandle* m_camera_cb; }; diff --git a/src/util/aabb.cpp b/src/util/aabb.cpp index 5effbbe7..1d3e3f30 100644 --- a/src/util/aabb.cpp +++ b/src/util/aabb.cpp @@ -152,7 +152,7 @@ namespace wr ExpandFromVector(DirectX::XMVECTOR{ pos[0], pos[1], pos[2], 1 }); } - bool AABB::InFrustum(DirectX::XMVECTOR(&planes)[6]) + bool AABB::InFrustum(std::array planes) { for (DirectX::XMVECTOR& plane : planes) { diff --git a/src/util/aabb.hpp b/src/util/aabb.hpp index 4dc6aab3..4721d06d 100644 --- a/src/util/aabb.hpp +++ b/src/util/aabb.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace wr { @@ -54,7 +55,7 @@ namespace wr void Expand(DirectX::XMVECTOR pos); //Check if the frustum planes intersect with the AABB - bool InFrustum(DirectX::XMVECTOR(&planes)[6]); + bool InFrustum(std::array planes); //Generates AABB from transform and box static AABB FromTransform(Box box, DirectX::XMMATRIX transform); diff --git a/src/util/pair_hash.hpp b/src/util/pair_hash.hpp index adabe3f1..b1b82429 100644 --- a/src/util/pair_hash.hpp +++ b/src/util/pair_hash.hpp @@ -9,7 +9,7 @@ namespace util { std::uint64_t hash = 0; for(int i=0;i()(pair.first) ^ hash;