Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Fixed the last warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
VZout committed May 6, 2019
1 parent 40ce139 commit 7697df8
Show file tree
Hide file tree
Showing 23 changed files with 107 additions and 114 deletions.
2 changes: 1 addition & 1 deletion demo/debug_camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion demo/engine_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion demo/scene_spheres.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
//{
Expand Down
8 changes: 4 additions & 4 deletions demo/scene_viknell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ namespace viknell_scene

// Lights
auto point_light_0 = scene_graph->CreateChild<wr::LightNode>(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<wr::LightNode>(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<wr::LightNode>(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<wr::LightNode>(nullptr, wr::LightType::DIRECTIONAL, DirectX::XMVECTOR{ 1, 1, 1 });
}
Expand Down
4 changes: 2 additions & 2 deletions src/d3d12/d3d12_command_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/d3d12/d3d12_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace wr::d3d12
//void Bind(CommandList& cmd_list, std::vector<DescriptorHeap*> 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);
Expand Down
4 changes: 3 additions & 1 deletion src/imgui/imgui_impl_dx12.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

#pragma once

enum DXGI_FORMAT;
#include <cstdint>

enum DXGI_FORMAT : std::int32_t;
struct ID3D12Device;
struct ID3D12GraphicsCommandList;
struct D3D12_CPU_DESCRIPTOR_HANDLE;
Expand Down
11 changes: 7 additions & 4 deletions src/render_tasks/d3d12_accumulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<D3D12RenderSystem&>(rs);
auto& device = n_render_system.m_device;
Expand All @@ -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<PathTracerData>();
fg.GetPredecessorData<PathTracerData>();

float samples = n_render_system.temp_rough;
d3d12::BindCompute32BitConstants(cmd_list, &samples, 1, 0, 1);
Expand All @@ -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<AccumulationData>(handle);

Expand Down
9 changes: 2 additions & 7 deletions src/render_tasks/d3d12_brdf_lut_precalculation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<D3D12RenderSystem&>(rs);
auto& data = fg.GetData<BrdfLutTaskData>(handle);
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
45 changes: 25 additions & 20 deletions src/render_tasks/d3d12_build_acceleration_structures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace wr
std::vector<std::tuple<d3d12::AccelerationStructure, unsigned int, DirectX::XMMATRIX>> out_blas_list;
std::vector<temp::RayTracingMaterial_CBData> out_materials;
std::vector<temp::RayTracingOffset_CBData> out_offsets;
std::unordered_map<unsigned int, unsigned int> out_parsed_materials;
std::unordered_map<std::uint64_t, std::uint64_t> out_parsed_materials;
std::vector<MaterialHandle> out_material_handles;
d3d12::StagingBuffer* out_scene_ib;
d3d12::StagingBuffer* out_scene_vb;
Expand All @@ -51,7 +51,6 @@ namespace wr
if (resize) return;

auto& n_render_system = static_cast<D3D12RenderSystem&>(rs);
auto& device = n_render_system.m_device;
auto& data = fg.GetData<ASBuildData>(handle);
auto n_render_target = fg.GetRenderTarget<d3d12::RenderTarget>(handle);
d3d12::SetName(n_render_target, L"Raytracing Target");
Expand Down Expand Up @@ -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();
Expand All @@ -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<float>(material_internal->GetAlbedo().m_id);
material.normal_id = static_cast<float>(material_internal->GetNormal().m_id);
material.roughness_id = static_cast<float>(material_internal->GetRoughness().m_id);
material.metallicness_id = static_cast<float>(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;
Expand All @@ -113,16 +112,16 @@ namespace wr
material_id = data.out_parsed_materials[material_handle.m_id];
}

return material_id;
return static_cast<std::uint32_t>(material_id);
}

//! Add a data struct describing the mesh data offset and the material idx to `out_offsets`
inline void AppendOffset(ASBuildData& data, wr::internal::D3D12MeshInternal* mesh, unsigned int material_id)
{
wr::temp::RayTracingOffset_CBData offset;
offset.material_idx = static_cast<float>(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<float>(mesh->m_index_staging_buffer_offset);
offset.vertex_offset = static_cast<float>(mesh->m_vertex_staging_buffer_offset);
data.out_offsets.push_back(offset);
}

Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
Expand All @@ -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;

Expand All @@ -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++)
{
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}
Expand All @@ -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++)
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 4 additions & 8 deletions src/render_tasks/d3d12_cubemap_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ namespace wr
return;
}

auto& n_render_system = static_cast<D3D12RenderSystem&>(rs);
auto& data = fg.GetData<CubemapConvolutionTaskData>(handle);

auto& ps_registry = PipelineRegistry::Get();
Expand Down Expand Up @@ -115,10 +114,7 @@ namespace wr
if (n_render_system.m_render_window.has_value())
{
auto cmd_list = fg.GetCommandList<d3d12::CommandList>(handle);
auto render_target = fg.GetRenderTarget<d3d12::RenderTarget>(handle);

const auto viewport = d3d12::CreateViewport(irradiance->m_width, irradiance->m_height);

const auto viewport = d3d12::CreateViewport(static_cast<int>(irradiance->m_width), static_cast<int>(irradiance->m_height));
const auto frame_idx = n_render_system.GetRenderWindow()->m_frame_idx;

d3d12::BindViewport(cmd_list, viewport);
Expand Down Expand Up @@ -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<std::uint32_t>(n_mesh->m_index_count), 1, static_cast<std::uint32_t>(n_mesh->m_index_staging_buffer_offset), static_cast<std::uint32_t>(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<std::uint32_t>(n_mesh->m_vertex_count), 1, static_cast<std::uint32_t>(n_mesh->m_vertex_staging_buffer_offset));
}
}
}
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/render_tasks/d3d12_deferred_main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<D3D12RenderSystem&>(rs);
auto& data = fg.GetData<DeferredMainTaskData>(handle);

auto& ps_registry = PipelineRegistry::Get();
Expand All @@ -40,7 +39,6 @@ namespace wr
auto& n_render_system = static_cast<D3D12RenderSystem&>(rs);
auto& data = fg.GetData<DeferredMainTaskData>(handle);
auto cmd_list = fg.GetCommandList<d3d12::CommandList>(handle);
auto render_target = fg.GetRenderTarget<d3d12::RenderTarget>(handle);

if (n_render_system.m_render_window.has_value())
{
Expand Down
6 changes: 2 additions & 4 deletions src/render_tasks/d3d12_deferred_render_target_copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::codecvt_utf8_utf16<wchar_t>> 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),
Expand All @@ -67,7 +65,7 @@ namespace wr
RenderTargetProperties::NumRTVFormats(1),
RenderTargetProperties::Clear(false),
RenderTargetProperties::ClearDepth(false),
RenderTargetProperties::ResourceName(wide)
RenderTargetProperties::ResourceName(w_name)
};

RenderTaskDesc desc;
Expand Down
Loading

0 comments on commit 7697df8

Please sign in to comment.