From 7f161a062d7d59d4c210a663bac584e5cba47d68 Mon Sep 17 00:00:00 2001 From: Michael Pollind Date: Thu, 4 Jan 2024 20:14:42 -0800 Subject: [PATCH] feat: fix crash Signed-off-by: Michael Pollind --- HPL2/include/graphics/RendererDeferred2.h | 6 ------ HPL2/include/graphics/SceneResource.h | 3 +++ HPL2/resource/decal_shade.vert.fsl | 2 +- HPL2/sources/graphics/RendererDeferred2.cpp | 4 +--- HPL2/sources/graphics/SceneResource.cpp | 15 +++++++++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/HPL2/include/graphics/RendererDeferred2.h b/HPL2/include/graphics/RendererDeferred2.h index a4cfeb708..1bf62ee0c 100644 --- a/HPL2/include/graphics/RendererDeferred2.h +++ b/HPL2/include/graphics/RendererDeferred2.h @@ -181,7 +181,6 @@ namespace hpl { MaterialSet& resolveSet(MaterialSetType set); }; ResourceMaterial& resolveResourceMaterial(cMaterial* material); - uint32_t resolveObjectSlot(uint32_t uid, std::function initializeHandler); UniqueViewportData m_boundViewportData; @@ -219,16 +218,11 @@ namespace hpl { std::array m_indirectDrawArgsBuffer; std::array m_materialSampler; - folly::F14ValueMap m_objectDescriptorLookup; SharedTexture m_emptyTexture2D; SharedTexture m_emptyTextureCube; Image* m_dissolveImage; - uint32_t m_activeFrame = 0; - uint32_t m_objectIndex = 0; - uint32_t m_indirectDrawIndex = 0; - cRenderList m_rendererList; SharedRootSignature m_lightClusterRootSignature; diff --git a/HPL2/include/graphics/SceneResource.h b/HPL2/include/graphics/SceneResource.h index e65162c69..7590b20a1 100644 --- a/HPL2/include/graphics/SceneResource.h +++ b/HPL2/include/graphics/SceneResource.h @@ -5,6 +5,7 @@ #include "graphics/Material.h" #include "Common_3/Utilities/Math/MathTypes.h" +#include "math/cFrustum.h" #include #include @@ -53,6 +54,8 @@ namespace hpl::resource { struct ViewportInfo { static constexpr uint32_t PrmaryViewportIndex = 0; + static ViewportInfo create(cFrustum* frustum, float4 rect); + mat4 m_invViewMat; mat4 m_invProjMat; mat4 m_invViewProj; diff --git a/HPL2/resource/decal_shade.vert.fsl b/HPL2/resource/decal_shade.vert.fsl index db1cac146..44bbb4abe 100644 --- a/HPL2/resource/decal_shade.vert.fsl +++ b/HPL2/resource/decal_shade.vert.fsl @@ -1,4 +1,4 @@ -/// Copyright © 2009-2020 Frictional Games +/// Copyright � 2009-2020 Frictional Games /// Copyright 2023 Michael Pollind /// SPDX-License-Identifier: GPL-3.0 #include "scene_resource.h.fsl" diff --git a/HPL2/sources/graphics/RendererDeferred2.cpp b/HPL2/sources/graphics/RendererDeferred2.cpp index e49f468fb..0fa88da03 100644 --- a/HPL2/sources/graphics/RendererDeferred2.cpp +++ b/HPL2/sources/graphics/RendererDeferred2.cpp @@ -1323,12 +1323,10 @@ namespace hpl { auto& opaqueSet = graphicsAllocator->resolveSet(GraphicsAllocator::AllocationSet::OpaqueSet); std::array params = { - DescriptorData{ .pName = "dissolveTexture", .ppTextures = &m_dissolveImage->GetTexture().m_handle }, DescriptorData{ .pName = "sceneDiffuseMat", .ppBuffers = &m_diffuseMatUniformBuffer.m_handle }, DescriptorData{ .pName = "sceneTranslucentMat", .ppBuffers = &m_translucencyMatBuffer.m_handle }, DescriptorData{ .pName = "sceneWaterMat", .ppBuffers = &m_waterMatBuffer.m_handle }, - // DescriptorData{ .pName = "sceneFilters", .mCount = samplers.size(), .ppSamplers = samplers.data() }, DescriptorData{ .pName = "vtxOpaqueIndex", .ppBuffers = &opaqueSet.indexBuffer().m_handle }, DescriptorData{ .pName = "vtxOpaquePosition", .ppBuffers = &opaqueSet.getStreamBySemantic(ShaderSemantic::SEMANTIC_POSITION)->buffer().m_handle }, @@ -1742,7 +1740,7 @@ namespace hpl { translucenctArgs.push_back({ TranslucentDrawType::Particle, renderable, - material->GetDepthTest() ? + material->GetDepthTest()? m_particlePipeline.getPipelineByBlendMode(material->GetBlendMode()).m_handle: m_particlePipelineNoDepth.getPipelineByBlendMode(material->GetBlendMode()).m_handle, nullptr, diff --git a/HPL2/sources/graphics/SceneResource.cpp b/HPL2/sources/graphics/SceneResource.cpp index 46b020da4..d123ff1cc 100644 --- a/HPL2/sources/graphics/SceneResource.cpp +++ b/HPL2/sources/graphics/SceneResource.cpp @@ -1,10 +1,25 @@ #include "graphics/SceneResource.h" #include "graphics/Material.h" +#include "math/cFrustum.h" #include "tinyimageformat_query.h" #include namespace hpl::resource { + ViewportInfo ViewportInfo::create(cFrustum* apFrustum, float4 rect) { + ViewportInfo info; + info.m_viewMat = apFrustum->GetViewMat(); + info.m_projMat = apFrustum->GetProjectionMat(); + info.m_invProjMat = inverse(apFrustum->GetProjectionMat()); + info.m_invViewMat = inverse(apFrustum->GetViewMat()); + info.m_invViewProj = inverse(info.m_projMat * info.m_viewMat); + info.m_zFar = apFrustum->GetFarPlane(); + info.m_zNear = apFrustum->GetNearPlane(); + info.m_rect = rect;//float4(0.0f, 0.0f, static_cast(viewportDatum->m_size.x), static_cast(viewportDatum->m_size.y)); + info.m_cameraPosition = v3ToF3(cMath::ToForgeVec3(apFrustum->GetOrigin())); + return info; + } + uint32_t textureFilterIdx(TextureAntistropy anisotropy, eTextureWrap wrap, eTextureFilter filter) { const uint32_t anisotropyGroup = (static_cast(eTextureFilter_LastEnum) * static_cast(eTextureWrap_LastEnum)) *