diff --git a/Shaders/CommonStructures.hlsl b/Shaders/Shared.hlsl similarity index 100% rename from Shaders/CommonStructures.hlsl rename to Shaders/Shared.hlsl diff --git a/Shaders/Skybox_PS.hlsl b/Shaders/Skybox_PS.hlsl index bbe9047..7f5bd39 100644 --- a/Shaders/Skybox_PS.hlsl +++ b/Shaders/Skybox_PS.hlsl @@ -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; @@ -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); } diff --git a/Yasno/Graphics/Material.hpp b/Yasno/Graphics/Material.hpp index ef22ce0..596b7a1 100644 --- a/Yasno/Graphics/Material.hpp +++ b/Yasno/Graphics/Material.hpp @@ -14,7 +14,5 @@ namespace ysn D3D12_BLEND_DESC blend_desc = {}; D3D12_RASTERIZER_DESC rasterizer_desc = {}; - - SurfaceShaderParameters shader_parameters; }; } \ No newline at end of file diff --git a/Yasno/Graphics/Primitive.cpp b/Yasno/Graphics/Primitive.cpp index 38f6050..514ee94 100644 --- a/Yasno/Graphics/Primitive.cpp +++ b/Yasno/Graphics/Primitive.cpp @@ -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(vertices.size()) * sizeof(VertexPosTexCoord); + const uint32_t index_buffer_size = static_cast(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(indices.size()); + new_box.vertex_count = static_cast(vertices.size()); new_box.input_layout_desc = VertexPosTexCoord::GetVertexLayoutDesc(); const auto renderer = Application::Get().GetRenderer(); diff --git a/Yasno/Graphics/RenderScene.hpp b/Yasno/Graphics/RenderScene.hpp index a5a4675..99f8b06 100644 --- a/Yasno/Graphics/RenderScene.hpp +++ b/Yasno/Graphics/RenderScene.hpp @@ -35,7 +35,9 @@ namespace ysn ModelRenderParameters render_parameters; std::vector meshes; + // Merge this two below maybe? std::vector materials; + std::vector shader_parameters; std::vector transforms; // Not sure about that diff --git a/Yasno/Graphics/ShaderSharedStructs.h b/Yasno/Graphics/ShaderSharedStructs.h new file mode 100644 index 0000000..897182c --- /dev/null +++ b/Yasno/Graphics/ShaderSharedStructs.h @@ -0,0 +1,10 @@ + + + + + +#pragma once + + + + diff --git a/Yasno/Graphics/Techniques/ConvertToCubemap.cpp b/Yasno/Graphics/Techniques/ConvertToCubemap.cpp index bae56f0..9314067 100644 --- a/Yasno/Graphics/Techniques/ConvertToCubemap.cpp +++ b/Yasno/Graphics/Techniques/ConvertToCubemap.cpp @@ -120,8 +120,5 @@ namespace ysn return true; } - void ConvertToCubemap::EquirectangularToCubemap(std::shared_ptr command_queue, const Texture& equirectangular_map, wil::com_ptr target_cubemap) - { - - } + } diff --git a/Yasno/Graphics/Techniques/ConvertToCubemap.hpp b/Yasno/Graphics/Techniques/ConvertToCubemap.hpp index ca5e21d..c4a6b29 100644 --- a/Yasno/Graphics/Techniques/ConvertToCubemap.hpp +++ b/Yasno/Graphics/Techniques/ConvertToCubemap.hpp @@ -18,7 +18,6 @@ namespace ysn }; public: bool Initialize(); - void EquirectangularToCubemap(std::shared_ptr command_queue, const Texture& equirectangular_map, wil::com_ptr target_cubemap); private: diff --git a/Yasno/Graphics/Techniques/ForwardPass.cpp b/Yasno/Graphics/Techniques/ForwardPass.cpp index 17bcf6e..76128e0 100644 --- a/Yasno/Graphics/Techniques/ForwardPass.cpp +++ b/Yasno/Graphics/Techniques/ForwardPass.cpp @@ -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()); diff --git a/Yasno/Graphics/Techniques/ShadowMapPass.cpp b/Yasno/Graphics/Techniques/ShadowMapPass.cpp index 674223c..9c47449 100644 --- a/Yasno/Graphics/Techniques/ShadowMapPass.cpp +++ b/Yasno/Graphics/Techniques/ShadowMapPass.cpp @@ -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()); diff --git a/Yasno/Renderer/GpuTexture.cpp b/Yasno/Renderer/GpuTexture.cpp index fae8790..69ddff6 100644 --- a/Yasno/Renderer/GpuTexture.cpp +++ b/Yasno/Renderer/GpuTexture.cpp @@ -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(num_mips); texture_desc.Width = width; texture_desc.Height = height; texture_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; diff --git a/Yasno/Renderer/Pso.cpp b/Yasno/Renderer/Pso.cpp index 158898b..e874359 100644 --- a/Yasno/Renderer/Pso.cpp +++ b/Yasno/Renderer/Pso.cpp @@ -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) diff --git a/Yasno/Renderer/Pso.hpp b/Yasno/Renderer/Pso.hpp index c433dee..1a9b2b9 100644 --- a/Yasno/Renderer/Pso.hpp +++ b/Yasno/Renderer/Pso.hpp @@ -67,8 +67,8 @@ namespace ysn struct Pso { PsoId pso_id = -1; - wil::com_ptr root_signature = nullptr; - wil::com_ptr pso = nullptr; + wil::com_ptr root_signature; + wil::com_ptr pso; }; struct PsoStorage diff --git a/Yasno/Renderer/ShaderStorage.cpp b/Yasno/Renderer/ShaderStorage.cpp index ac4634f..24102e5 100644 --- a/Yasno/Renderer/ShaderStorage.cpp +++ b/Yasno/Renderer/ShaderStorage.cpp @@ -117,7 +117,7 @@ namespace ysn wil::com_ptr 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(shader_code.size()), CP_UTF8, dxc_text_blob.addressof()); result != S_OK) { LogFatal << "Can't create shader blob\n"; return std::nullopt; @@ -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) @@ -292,7 +293,6 @@ namespace ysn } } -#ifndef YSN_RELEASE std::optional ShaderStorage::GetShaderModificationTime(const std::filesystem::path& shader_path) { struct stat result; diff --git a/Yasno/Renderer/ShaderStorage.hpp b/Yasno/Renderer/ShaderStorage.hpp index 353ae6c..cfc5710 100644 --- a/Yasno/Renderer/ShaderStorage.hpp +++ b/Yasno/Renderer/ShaderStorage.hpp @@ -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 defines; + std::wstring shader_path = L""; + std::wstring entry_point = L"main"; + bool disable_optimizations = false; + ShaderType shader_type = ShaderType::None; + std::vector defines; }; struct ShaderStorage diff --git a/Yasno/System/GltfLoader.cpp b/Yasno/System/GltfLoader.cpp index d38c5ed..5e804a0 100644 --- a/Yasno/System/GltfLoader.cpp +++ b/Yasno/System/GltfLoader.cpp @@ -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) { @@ -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(index_accessor.count); } else { @@ -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(position_accessor.count); } static BuildMeshResult BuildMeshes(ysn::Model& model, const tinygltf::Model& gltf_model) @@ -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; @@ -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(gltf_mesh.primitives.size()); model.meshes.push_back(mesh); } @@ -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(); @@ -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(gltf_model.materials.size()); } namespace ysn @@ -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 diff --git a/Yasno/Yasno.vcxproj b/Yasno/Yasno.vcxproj index 8512a8b..12fa197 100644 --- a/Yasno/Yasno.vcxproj +++ b/Yasno/Yasno.vcxproj @@ -249,7 +249,6 @@ - @@ -320,6 +319,7 @@ + @@ -441,6 +441,11 @@ Document + + + Document + + diff --git a/Yasno/Yasno.vcxproj.filters b/Yasno/Yasno.vcxproj.filters index 2d4b4cf..f2200a6 100644 --- a/Yasno/Yasno.vcxproj.filters +++ b/Yasno/Yasno.vcxproj.filters @@ -188,8 +188,11 @@ Source\Graphics + + Source\Renderer + - Source + Source\Renderer @@ -385,6 +388,12 @@ Source\Graphics + + Source\Graphics + + + Source\Renderer + @@ -445,12 +454,6 @@ Shaders - - Docs - - - Docs - Shaders @@ -463,13 +466,7 @@ Shaders - - Docs - - - Docs - - + Shaders diff --git a/Yasno/Yasno/Yasno.cpp b/Yasno/Yasno/Yasno.cpp index 5324909..3f12d61 100644 --- a/Yasno/Yasno/Yasno.cpp +++ b/Yasno/Yasno/Yasno.cpp @@ -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(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(primitive.indices.size()); // Append indices all_indices_buffer.insert(all_indices_buffer.end(), primitive.indices.begin(), primitive.indices.end()); @@ -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); } }