Skip to content

Commit

Permalink
feat: fix crash
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend committed Jan 5, 2024
1 parent 43c0d36 commit 7f161a0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
6 changes: 0 additions & 6 deletions HPL2/include/graphics/RendererDeferred2.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ namespace hpl {
MaterialSet& resolveSet(MaterialSetType set);
};
ResourceMaterial& resolveResourceMaterial(cMaterial* material);
uint32_t resolveObjectSlot(uint32_t uid, std::function<void(uint32_t)> initializeHandler);

UniqueViewportData<ViewportData> m_boundViewportData;

Expand Down Expand Up @@ -219,16 +218,11 @@ namespace hpl {
std::array<SharedBuffer, ForgeRenderer::SwapChainLength> m_indirectDrawArgsBuffer;

std::array<SharedSampler, resource::MaterialSceneSamplersCount> m_materialSampler;
folly::F14ValueMap<uint32_t, uint32_t> 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;
Expand Down
3 changes: 3 additions & 0 deletions HPL2/include/graphics/SceneResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "graphics/Material.h"

#include "Common_3/Utilities/Math/MathTypes.h"
#include "math/cFrustum.h"
#include <FixPreprocessor.h>

#include <functional>
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion HPL2/resource/decal_shade.vert.fsl
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 1 addition & 3 deletions HPL2/sources/graphics/RendererDeferred2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions HPL2/sources/graphics/SceneResource.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
#include "graphics/SceneResource.h"
#include "graphics/Material.h"
#include "math/cFrustum.h"
#include "tinyimageformat_query.h"
#include <cstdint>

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<float>(viewportDatum->m_size.x), static_cast<float>(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<uint32_t>(eTextureFilter_LastEnum) * static_cast<uint32_t>(eTextureWrap_LastEnum)) *
Expand Down

0 comments on commit 7f161a0

Please sign in to comment.