Skip to content

Commit

Permalink
Fixed all warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
krupitskas committed Nov 28, 2024
1 parent 7aa8609 commit 9e92fb4
Show file tree
Hide file tree
Showing 19 changed files with 57 additions and 76 deletions.
File renamed without changes.
18 changes: 0 additions & 18 deletions Shaders/Skybox_PS.hlsl
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
// #version 330 core
// out vec4 FragColor;
//
// in vec3 localPos;
//
// uniform samplerCube environmentMap;
//
// void main()
// {
// vec3 envColor = texture(environmentMap, localPos).rgb;
//
// envColor = envColor / (envColor + vec3(1.0));
// envColor = pow(envColor, vec3(1.0/2.2));
//
// FragColor = vec4(envColor, 1.0);
// }

struct PixelShaderInput
{
float2 TexCoord : TEXCOORD;
Expand All @@ -37,5 +20,4 @@ float4 main(PixelShaderInput IN) : SV_Target
{
float2 uv = SphericalCoords(normalize(IN.OriginalPosition));
return g_texture.Sample(g_linear_sampler, uv);
//return float4(255, 0, 0, 0);
}
2 changes: 0 additions & 2 deletions Yasno/Graphics/Material.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ namespace ysn

D3D12_BLEND_DESC blend_desc = {};
D3D12_RASTERIZER_DESC rasterizer_desc = {};

SurfaceShaderParameters shader_parameters;
};
}
8 changes: 4 additions & 4 deletions Yasno/Graphics/Primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ namespace ysn
4, 3, 7
};

const uint32_t vertex_buffer_size = vertices.size() * sizeof(VertexPosTexCoord);
const uint32_t index_buffer_size = indices.size() * sizeof(uint16_t);
const uint32_t vertex_buffer_size = static_cast<uint32_t>(vertices.size()) * sizeof(VertexPosTexCoord);
const uint32_t index_buffer_size = static_cast<uint32_t>(indices.size()) * sizeof(uint16_t);

MeshPrimitive new_box;
new_box.index_count = indices.size();
new_box.vertex_count = vertices.size();
new_box.index_count = static_cast<uint32_t>(indices.size());
new_box.vertex_count = static_cast<uint32_t>(vertices.size());
new_box.input_layout_desc = VertexPosTexCoord::GetVertexLayoutDesc();

const auto renderer = Application::Get().GetRenderer();
Expand Down
2 changes: 2 additions & 0 deletions Yasno/Graphics/RenderScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ namespace ysn
ModelRenderParameters render_parameters;

std::vector<Mesh> meshes;
// Merge this two below maybe?
std::vector<Material> materials;
std::vector<SurfaceShaderParameters> shader_parameters;
std::vector<NodeTransform> transforms;

// Not sure about that
Expand Down
10 changes: 10 additions & 0 deletions Yasno/Graphics/ShaderSharedStructs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@





#pragma once




5 changes: 1 addition & 4 deletions Yasno/Graphics/Techniques/ConvertToCubemap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,5 @@ namespace ysn
return true;
}

void ConvertToCubemap::EquirectangularToCubemap(std::shared_ptr<ysn::CommandQueue> command_queue, const Texture& equirectangular_map, wil::com_ptr<ID3D12Resource> target_cubemap)
{

}

}
1 change: 0 additions & 1 deletion Yasno/Graphics/Techniques/ConvertToCubemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace ysn
};
public:
bool Initialize();
void EquirectangularToCubemap(std::shared_ptr<ysn::CommandQueue> command_queue, const Texture& equirectangular_map, wil::com_ptr<ID3D12Resource> target_cubemap);
private:


Expand Down
2 changes: 0 additions & 2 deletions Yasno/Graphics/Techniques/ForwardPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,6 @@ namespace ysn

if(pso.has_value())
{
const Material& material = model.materials[primitive.material_id];

command_list->SetGraphicsRootSignature(pso.value().root_signature.get());
command_list->SetPipelineState(pso.value().pso.get());

Expand Down
2 changes: 0 additions & 2 deletions Yasno/Graphics/Techniques/ShadowMapPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ namespace ysn

if(pso.has_value())
{
const Material& material = model.materials[primitive.material_id];

command_list->SetGraphicsRootSignature(pso.value().root_signature.get());
command_list->SetPipelineState(pso.value().pso.get());

Expand Down
2 changes: 1 addition & 1 deletion Yasno/Renderer/GpuTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace ysn

D3D12_RESOURCE_DESC texture_desc = {};
texture_desc.Format = format;
texture_desc.MipLevels = num_mips;
texture_desc.MipLevels = static_cast<UINT16>(num_mips);
texture_desc.Width = width;
texture_desc.Height = height;
texture_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
Expand Down
2 changes: 0 additions & 2 deletions Yasno/Renderer/Pso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ namespace ysn
{
const PsoId pso_id = pso_desc.GenerateId();

ID3D12PipelineState** pso_ref = nullptr;

bool should_create_new = !m_graphics_pso_pool.contains(pso_id);

if (should_create_new)
Expand Down
4 changes: 2 additions & 2 deletions Yasno/Renderer/Pso.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ namespace ysn
struct Pso
{
PsoId pso_id = -1;
wil::com_ptr<ID3D12RootSignature> root_signature = nullptr;
wil::com_ptr<ID3D12PipelineState> pso = nullptr;
wil::com_ptr<ID3D12RootSignature> root_signature;
wil::com_ptr<ID3D12PipelineState> pso;
};

struct PsoStorage
Expand Down
4 changes: 2 additions & 2 deletions Yasno/Renderer/ShaderStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace ysn

wil::com_ptr<IDxcBlobEncoding> dxc_text_blob;

if (auto result = m_dxc_utils->CreateBlob(shader_code.c_str(), shader_code.size(), CP_UTF8, dxc_text_blob.addressof()); result != S_OK)
if (auto result = m_dxc_utils->CreateBlob(shader_code.c_str(), static_cast<uint32_t>(shader_code.size()), CP_UTF8, dxc_text_blob.addressof()); result != S_OK)
{
LogFatal << "Can't create shader blob\n";
return std::nullopt;
Expand Down Expand Up @@ -269,6 +269,7 @@ namespace ysn
return shader_data;
}

#ifndef YSN_RELEASE
void ShaderStorage::VerifyAnyShaderChanged()
{
for(const auto& [shader_path, time] : m_shaders_modified_time)
Expand All @@ -292,7 +293,6 @@ namespace ysn
}
}

#ifndef YSN_RELEASE
std::optional<std::time_t> ShaderStorage::GetShaderModificationTime(const std::filesystem::path& shader_path)
{
struct stat result;
Expand Down
10 changes: 5 additions & 5 deletions Yasno/Renderer/ShaderStorage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ namespace ysn

struct ShaderCompileParameters
{
std::wstring shader_path = L"";
std::wstring entry_point = L"main";
bool disable_optimizations = false;
ShaderType shader_type = ShaderType::None;
std::vector<std::wstring> defines;
std::wstring shader_path = L"";
std::wstring entry_point = L"main";
bool disable_optimizations = false;
ShaderType shader_type = ShaderType::None;
std::vector<std::wstring> defines;
};

struct ShaderStorage
Expand Down
21 changes: 9 additions & 12 deletions Yasno/System/GltfLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static bool BuildPrimitiveTopology(ysn::Primitive& primitive, int gltf_primitive
return true;
}

static uint32_t BuildIndexBuffer(ysn::Primitive& primitive, const ysn::Model& model, int indices_index, const tinygltf::Model& gltf_model)
static uint32_t BuildIndexBuffer(ysn::Primitive& primitive, int indices_index, const tinygltf::Model& gltf_model)
{
if (indices_index >= 0)
{
Expand Down Expand Up @@ -430,7 +430,7 @@ static uint32_t BuildIndexBuffer(ysn::Primitive& primitive, const ysn::Model& mo
memcpy(primitive.indices.data(), base_address, (index_accessor.count * index_stride));
}

return index_accessor.count;
return static_cast<uint32_t>(index_accessor.count);
}
else
{
Expand Down Expand Up @@ -566,7 +566,7 @@ static uint32_t BuildVertexBuffer(ysn::Primitive& primitive, const tinygltf::Pri
primitive.vertices.push_back(v);
}

return position_accessor.count;
return static_cast<uint32_t>(position_accessor.count);
}

static BuildMeshResult BuildMeshes(ysn::Model& model, const tinygltf::Model& gltf_model)
Expand All @@ -583,10 +583,8 @@ static BuildMeshResult BuildMeshes(ysn::Model& model, const tinygltf::Model& glt
for (const tinygltf::Primitive& gltf_primitive : gltf_mesh.primitives)
{
ysn::Primitive primitive;

result.mesh_vertices_count += BuildVertexBuffer(primitive, gltf_primitive, gltf_model);
//BuildAttributesAccessors(primitive, model, gltf_model, gltf_primitive.attributes);
result.mesh_indices_count += BuildIndexBuffer(primitive, model, gltf_primitive.indices, gltf_model);
result.mesh_indices_count += BuildIndexBuffer(primitive, gltf_primitive.indices, gltf_model);
BuildPrimitiveTopology(primitive, gltf_primitive.mode);

primitive.material_id = gltf_primitive.material;
Expand All @@ -597,7 +595,7 @@ static BuildMeshResult BuildMeshes(ysn::Model& model, const tinygltf::Model& glt
primitive_index_count++;
}

result.primitives_count += gltf_mesh.primitives.size();
result.primitives_count += static_cast<uint32_t>(gltf_mesh.primitives.size());

model.meshes.push_back(mesh);
}
Expand Down Expand Up @@ -635,7 +633,7 @@ static void BuildNodes(ysn::Model& model, const tinygltf::Model& gltf_model, con
}
}

static uint32_t BuildMaterials(ysn::Model& model, LoadGltfContext& build_context, const tinygltf::Model& gltf_model)
static uint32_t BuildMaterials(ysn::Model& model, const tinygltf::Model& gltf_model)
{
auto dx_renderer = ysn::Application::Get().GetRenderer();

Expand Down Expand Up @@ -781,12 +779,11 @@ static uint32_t BuildMaterials(ysn::Model& model, LoadGltfContext& build_context
texture.name = L"Emissive Texture";
}

material.shader_parameters = shader_parameters;

model.materials.push_back(material);
model.shader_parameters.push_back(shader_parameters);
}

return gltf_model.materials.size();
return static_cast<uint32_t>(gltf_model.materials.size());
}

namespace ysn
Expand All @@ -806,7 +803,7 @@ namespace ysn
return false;
}

render_scene.materials_count += BuildMaterials(model, load_gltf_context, gltf_model);
render_scene.materials_count += BuildMaterials(model, gltf_model);

// Build pipelines
// Compute mips
Expand Down
7 changes: 6 additions & 1 deletion Yasno/Yasno.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\Shaders\CommonStructures.hlsl" />
<None Include="..\Shaders\ConvertEquirectangularMap_VS.hlsl" />
<None Include="..\Shaders\Skybox_PS.hlsl" />
<None Include="..\Shaders\Skybox_VS.hlsl" />
Expand Down Expand Up @@ -320,6 +319,7 @@
<ClInclude Include="Graphics\RenderScene.hpp" />
<ClInclude Include="Graphics\EngineStats.hpp" />
<ClInclude Include="Graphics\RtxMaterial.hpp" />
<ClInclude Include="Graphics\ShaderSharedStructs.h" />
<ClInclude Include="Graphics\SurfaceMaterial.hpp" />
<ClInclude Include="Graphics\Techniques\ShadowMapPass.hpp" />
<ClInclude Include="Graphics\Techniques\ConvertToCubemap.hpp" />
Expand Down Expand Up @@ -441,6 +441,11 @@
<FileType>Document</FileType>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\Shaders\Shared.hlsl">
<FileType>Document</FileType>
</None>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\Build\NuGet\Microsoft.Direct3D.DXC.1.8.2405.17\build\native\Microsoft.Direct3D.DXC.targets" Condition="Exists('..\Build\NuGet\Microsoft.Direct3D.DXC.1.8.2405.17\build\native\Microsoft.Direct3D.DXC.targets')" />
Expand Down
25 changes: 11 additions & 14 deletions Yasno/Yasno.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@
<ClCompile Include="Graphics\RtxMaterial.cpp">
<Filter>Source\Graphics</Filter>
</ClCompile>
<ClCompile Include="Renderer\CommandSignature.cpp">
<Filter>Source\Renderer</Filter>
</ClCompile>
<ClCompile Include="Renderer\GpuBuffer.cpp">
<Filter>Source</Filter>
<Filter>Source\Renderer</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -385,6 +388,12 @@
<ClInclude Include="Graphics\AABB.hpp">
<Filter>Source\Graphics</Filter>
</ClInclude>
<ClInclude Include="Graphics\ShaderSharedStructs.h">
<Filter>Source\Graphics</Filter>
</ClInclude>
<ClInclude Include="Renderer\CommandSignature.hpp">
<Filter>Source\Renderer</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\Shaders\ForwardPassPS.hlsl">
Expand Down Expand Up @@ -445,12 +454,6 @@
<None Include="..\Shaders\ConvertEquirectangularMap_PS.hlsl">
<Filter>Shaders</Filter>
</None>
<None Include="..\Docs\Docs.md">
<Filter>Docs</Filter>
</None>
<None Include="..\Docs\Tasks.md">
<Filter>Docs</Filter>
</None>
<None Include="..\Shaders\ShadowPassPS.hlsl">
<Filter>Shaders</Filter>
</None>
Expand All @@ -463,13 +466,7 @@
<None Include="..\Shaders\IndirectForwardPass_PS.hlsl">
<Filter>Shaders</Filter>
</None>
<None Include="..\Docs\Task_Indirect_Draw.md">
<Filter>Docs</Filter>
</None>
<None Include="..\Docs\Task_Reference_PT.md">
<Filter>Docs</Filter>
</None>
<None Include="..\Shaders\CommonStructures.hlsl">
<None Include="..\Shaders\Shared.hlsl">
<Filter>Shaders</Filter>
</None>
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Yasno/Yasno/Yasno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ namespace ysn
for (auto& primitive : mesh.primitives)
{
primitive.index_buffer_view.BufferLocation = m_render_scene.indices_buffer.GetGPUVirtualAddress() + all_indices_buffer.size() * sizeof(uint32_t);
primitive.index_buffer_view.SizeInBytes = primitive.indices.size() * sizeof(uint32_t);
primitive.index_buffer_view.SizeInBytes = static_cast<uint32_t>(primitive.indices.size()) * sizeof(uint32_t);
primitive.index_buffer_view.Format = DXGI_FORMAT_R32_UINT;

primitive.index_count = primitive.indices.size();
primitive.index_count = static_cast<uint32_t>(primitive.indices.size());

// Append indices
all_indices_buffer.insert(all_indices_buffer.end(), primitive.indices.begin(), primitive.indices.end());
Expand Down Expand Up @@ -398,9 +398,9 @@ namespace ysn

for (auto& model : m_render_scene.models)
{
for (auto& material : model.materials)
for (auto& material : model.shader_parameters)
{
all_materials_buffer.push_back(material.shader_parameters);
all_materials_buffer.push_back(material);
}
}

Expand Down

0 comments on commit 9e92fb4

Please sign in to comment.