diff --git a/NESEmulator/CNESEmulator.cpp b/NESEmulator/CNESEmulator.cpp index aa7516dc7..6b5fa16eb 100644 --- a/NESEmulator/CNESEmulator.cpp +++ b/NESEmulator/CNESEmulator.cpp @@ -755,9 +755,10 @@ void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering) { ViewBlock uniform = {zeus::CMatrix4f{}, mulColor}; uniform.m_mv[0][0] = widthFac; +#if !HSH_PROFILE_MODE m_uniBuf.load(uniform); - m_shadBind.draw(0, 4); +#endif } void CNESEmulator::LoadPassword(const u8* state) { diff --git a/Runtime/Graphics/CLineRenderer.cpp b/Runtime/Graphics/CLineRenderer.cpp index 2a30df9f3..08ab726a5 100644 --- a/Runtime/Graphics/CLineRenderer.cpp +++ b/Runtime/Graphics/CLineRenderer.cpp @@ -326,6 +326,7 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) { m_final = true; } +#if !HSH_PROFILE_MODE m_uniformBuf.load(SDrawUniform{moduColor, CGraphics::g_Fog}); if (m_textured) { if (!g_StaticLineVertsTex.empty()) { @@ -338,6 +339,7 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) { m_shaderBind[alphaWrite].draw(0, g_StaticLineVertsNoTex.size()); } } +#endif } } // namespace urde diff --git a/Runtime/Graphics/CMoviePlayer.cpp b/Runtime/Graphics/CMoviePlayer.cpp index 48f7eb978..5482316ab 100644 --- a/Runtime/Graphics/CMoviePlayer.cpp +++ b/Runtime/Graphics/CMoviePlayer.cpp @@ -253,7 +253,9 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo SetFrame({-0.5f, 0.5f, 0.f}, {-0.5f, -0.5f, 0.f}, {0.5f, -0.5f, 0.f}, {0.5f, 0.5f, 0.f}); m_viewVertBlock.m_mv = zeus::CMatrix4f{}; +#if !HSH_PROFILE_MODE m_blockBuf.load(m_viewVertBlock); +#endif } void CMoviePlayer::SetStaticAudioVolume(int vol) { @@ -398,7 +400,9 @@ void CMoviePlayer::SetFrame(const zeus::CVector3f& a, const zeus::CVector3f& b, m_frame[1].m_pos = b; m_frame[2].m_pos = d; m_frame[3].m_pos = c; +#if !HSH_PROFILE_MODE m_vertBuf.load(m_frame); +#endif } void CMoviePlayer::DrawFrame() { @@ -522,6 +526,7 @@ void CMoviePlayer::DecodeFromRead(const void* data) { uintptr_t planeSizeHalf = planeSize / 2; uintptr_t planeSizeQuarter = planeSizeHalf / 2; +#if !HSH_PROFILE_MODE if (m_deinterlace) { /* Deinterlace into 2 discrete 60-fps half-res textures */ u8* mappedData = (u8*)tex.Y[0].map(); @@ -546,6 +551,7 @@ void CMoviePlayer::DecodeFromRead(const void* data) { tex.U.load(m_yuvBuf.get() + planeSize, planeSizeQuarter); tex.V.load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter); } +#endif break; } diff --git a/Runtime/Graphics/Shaders/CAABoxShader.cpp b/Runtime/Graphics/Shaders/CAABoxShader.cpp index c263cec3d..2f059fc39 100644 --- a/Runtime/Graphics/Shaders/CAABoxShader.cpp +++ b/Runtime/Graphics/Shaders/CAABoxShader.cpp @@ -59,7 +59,9 @@ void CAABoxShader::draw(const zeus::CColor& color) { m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_color = color; +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, VertexCount); } diff --git a/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp b/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp index 2e3d9e8cb..5b261fb28 100644 --- a/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp +++ b/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp @@ -56,7 +56,9 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) { {hsh::float2{1.0, -1.0}, {xBias + xFac, yBias + yFac}}, {hsh::float2{1.0, 1.0}, {xBias + xFac, yBias}}, }}; +#if !HSH_PROFILE_MODE m_vbo.load(verts); +#endif // m_uniform.m_uv.size() for (size_t i = 0; i < 6; ++i) { @@ -74,7 +76,9 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) { m_uniform.m_uv[i].y = amtY * yFac; } m_uniform.m_opacity = std::min(amount / 2.f, 1.f); +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp b/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp index 68c58ae99..238edb25a 100644 --- a/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp @@ -39,6 +39,7 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type) { void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) { SCOPED_GRAPHICS_DEBUG_GROUP("CColoredQuadFilter::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_uniform.m_matrix = zeus::CMatrix4f{}; m_uniform.m_matrix[0][0] = rect.size.x() * 2.f; m_uniform.m_matrix[1][1] = rect.size.y() * 2.f; @@ -46,6 +47,7 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f; m_uniform.m_color = color; m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CColoredStripShader.cpp b/Runtime/Graphics/Shaders/CColoredStripShader.cpp index d824adb54..a6adb77b0 100644 --- a/Runtime/Graphics/Shaders/CColoredStripShader.cpp +++ b/Runtime/Graphics/Shaders/CColoredStripShader.cpp @@ -56,7 +56,9 @@ void CColoredStripShader::draw(const zeus::CColor& color, size_t numVerts, const m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_color = color; +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, numVerts); } diff --git a/Runtime/Graphics/Shaders/CDecalShaders.cpp b/Runtime/Graphics/Shaders/CDecalShaders.cpp index d7b5413f4..1a11ec97b 100644 --- a/Runtime/Graphics/Shaders/CDecalShaders.cpp +++ b/Runtime/Graphics/Shaders/CDecalShaders.cpp @@ -40,16 +40,15 @@ struct CDecalShaderNoTexPipeline : pipeline; template struct CDecalShaderNoTexPipeline; -hsh::binding& CDecalShaders::BuildShaderDataBinding(CQuadDecal& decal, hsh::texture2d tex) { +void CDecalShaders::BuildShaderDataBinding(hsh::binding& binding, CQuadDecal& decal, hsh::texture2d tex) { bool additive = decal.m_desc->x18_ADD; if (decal.m_desc->x14_TEX) { bool redToAlpha = additive && CDecal::GetMoveRedToAlphaBuffer(); - m_dataBind.hsh_tex_bind( + binding.hsh_tex_bind( CDecalShaderTexPipeline(decal.m_instBuf.get(), decal.m_uniformBuf.get(), tex)); } else { - m_dataBind.hsh_notex_bind(CDecalShaderNoTexPipeline(decal.m_instBuf.get(), decal.m_uniformBuf.get())); + binding.hsh_notex_bind(CDecalShaderNoTexPipeline(decal.m_instBuf.get(), decal.m_uniformBuf.get())); } - return m_dataBind; } } // namespace urde diff --git a/Runtime/Graphics/Shaders/CDecalShaders.hpp b/Runtime/Graphics/Shaders/CDecalShaders.hpp index cfe5568c3..9e350d970 100644 --- a/Runtime/Graphics/Shaders/CDecalShaders.hpp +++ b/Runtime/Graphics/Shaders/CDecalShaders.hpp @@ -6,10 +6,8 @@ namespace urde { struct CQuadDecal; class CDecalShaders { - hsh::binding m_dataBind; - public: - hsh::binding& BuildShaderDataBinding(CQuadDecal& decal, hsh::texture2d tex); + static void BuildShaderDataBinding(hsh::binding& binding, CQuadDecal& decal, hsh::texture2d tex); }; } // namespace urde diff --git a/Runtime/Graphics/Shaders/CElementGenShaders.cpp b/Runtime/Graphics/Shaders/CElementGenShaders.cpp index 994a96110..bcc85cd15 100644 --- a/Runtime/Graphics/Shaders/CElementGenShaders.cpp +++ b/Runtime/Graphics/Shaders/CElementGenShaders.cpp @@ -77,6 +77,7 @@ struct CElementGenShadersNoTexPipeline } }; template struct CElementGenShadersNoTexPipeline; +template struct CElementGenShadersNoTexPipeline; CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) { const auto* desc = gen.x1c_genDesc.GetObj(); @@ -89,41 +90,61 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& return EShaderClass::NoTex; } -hsh::binding& CElementGenShaders::BuildShaderDataBinding(CElementGen& gen, bool pmus) { +void CElementGenShaders::BuildShaderDataBinding(CElementGen& gen) { const auto& desc = gen.x1c_genDesc; BlendMode mode = BlendMode::Regular; + BlendMode pmusMode = BlendMode::Regular; if (CElementGen::g_subtractBlend) { mode = BlendMode::Subtract; - } else if (gen.x26c_26_AAPH) { - mode = BlendMode::Additive; + pmusMode = BlendMode::Subtract; + } else { + if (gen.x26c_26_AAPH) { + mode = BlendMode::Additive; + } + if (desc->x44_31_x31_25_PMAB) { + pmusMode = BlendMode::Additive; + } } - hsh::vertex_buffer_typeless instBuf = pmus ? gen.m_instBufPmus.get() : gen.m_instBuf.get(); - hsh::uniform_buffer_typeless uniBuf = pmus ? gen.m_uniformBufPmus.get() : gen.m_uniformBuf.get(); switch (GetShaderClass(gen)) { case EShaderClass::Tex: { hsh::texture2d tex = desc->x54_x40_TEXR->GetValueTexture(0)->GetBooTexture(); - m_shaderBind.hsh_tex_bind( + gen.m_binding.hsh_tex_bind( CElementGenShadersTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF, - CElementGen::sMoveRedToAlphaBuffer>(instBuf, uniBuf, tex)); + CElementGen::sMoveRedToAlphaBuffer>(gen.m_instBuf.get(), gen.m_uniformBuf.get(), + tex)); + if (gen.x1c_genDesc->x45_24_x31_26_PMUS) + gen.m_bindingPmus.hsh_tex_pmus_bind( + CElementGenShadersTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF, + CElementGen::sMoveRedToAlphaBuffer>(gen.m_instBufPmus.get(), + gen.m_uniformBufPmus.get(), tex)); break; } case EShaderClass::IndTex: { hsh::texture2d texrTex = desc->x54_x40_TEXR->GetValueTexture(0)->GetBooTexture(); hsh::texture2d tindTex = desc->x58_x44_TIND->GetValueTexture(0)->GetBooTexture(); hsh::render_texture2d sceneTex = CGraphics::g_SpareTexture.get_color(0); - m_shaderBind.hsh_indtex_bind( + gen.m_binding.hsh_indtex_bind( CElementGenShadersIndTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF, - desc->x45_30_x32_24_CIND>(instBuf, uniBuf, texrTex, tindTex, sceneTex)); + desc->x45_30_x32_24_CIND>(gen.m_instBuf.get(), gen.m_uniformBuf.get(), texrTex, + tindTex, sceneTex)); + if (gen.x1c_genDesc->x45_24_x31_26_PMUS) + gen.m_bindingPmus.hsh_indtex_pmus_bind( + CElementGenShadersIndTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, + gen.x26c_27_ZBUF, desc->x45_30_x32_24_CIND>( + gen.m_instBufPmus.get(), gen.m_uniformBufPmus.get(), texrTex, tindTex, sceneTex)); break; } case EShaderClass::NoTex: { - m_shaderBind.hsh_notex_bind( + gen.m_binding.hsh_notex_bind( CElementGenShadersNoTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF>( - instBuf, uniBuf)); + gen.m_instBuf.get(), gen.m_uniformBuf.get())); + if (gen.x1c_genDesc->x45_24_x31_26_PMUS) + gen.m_bindingPmus.hsh_notex_pmus_bind( + CElementGenShadersNoTexPipelineIsThermalVisorHotPass(), gen.x26c_28_zTest, + gen.x26c_27_ZBUF>(gen.m_instBufPmus.get(), gen.m_uniformBufPmus.get())); break; } } - return m_shaderBind; } } // namespace urde diff --git a/Runtime/Graphics/Shaders/CElementGenShaders.hpp b/Runtime/Graphics/Shaders/CElementGenShaders.hpp index 629098fab..830b4b524 100644 --- a/Runtime/Graphics/Shaders/CElementGenShaders.hpp +++ b/Runtime/Graphics/Shaders/CElementGenShaders.hpp @@ -7,13 +7,10 @@ namespace urde { class CElementGen; class CElementGenShaders { - hsh::binding m_shaderBind; - public: enum class EShaderClass { Tex, IndTex, NoTex }; - static EShaderClass GetShaderClass(CElementGen& gen); - hsh::binding& BuildShaderDataBinding(CElementGen& gen, bool pmus); + static void BuildShaderDataBinding(CElementGen& gen); }; } // namespace urde diff --git a/Runtime/Graphics/Shaders/CEnergyBarShader.cpp b/Runtime/Graphics/Shaders/CEnergyBarShader.cpp index cc376722a..b6a465377 100644 --- a/Runtime/Graphics/Shaders/CEnergyBarShader.cpp +++ b/Runtime/Graphics/Shaders/CEnergyBarShader.cpp @@ -42,6 +42,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector vbo, hsh::index_bu void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) { SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_uniBuf.load({CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color}); +#endif m_dataBind.draw_indexed(start, count); } diff --git a/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp b/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp index 5d9aeff2d..8aa78c796 100644 --- a/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp +++ b/Runtime/Graphics/Shaders/CPhazonSuitFilter.cpp @@ -129,6 +129,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) { constexpr float blurScale = 1.0f / 128.0f; +#if !HSH_PROFILE_MODE /* X Pass */ m_uniBufBlurX.load( {zeus::CVector4f{g_Viewport.xc_height / float(g_Viewport.x8_width) * radius * blurScale, 0.f, 0.f, 0.f}}); @@ -139,11 +140,14 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) { m_uniBufBlurY.load({zeus::CVector4f{0.f, radius * blurScale, 0.f, 0.f}}); m_dataBindBlurY.draw(0, 4); CGraphics::ResolveSpareTexture(rect, 2); +#endif } void CPhazonSuitFilter::draw(const zeus::CColor& color, float indScale, float indOffX, float indOffY) { SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_uniBuf.load({color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)}); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CRadarPaintShader.cpp b/Runtime/Graphics/Shaders/CRadarPaintShader.cpp index 328c0368d..e9c20e570 100644 --- a/Runtime/Graphics/Shaders/CRadarPaintShader.cpp +++ b/Runtime/Graphics/Shaders/CRadarPaintShader.cpp @@ -32,8 +32,10 @@ void CRadarPaintShader::draw(const std::vector& instances, const CText m_dataBind.hsh_bind(CRadarPaintShaderPipeline(m_vbo.get(), m_uniBuf.get(), tex2d)); } +#if !HSH_PROFILE_MODE m_uniBuf.load({CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f()}); m_vbo.load(instances); +#endif m_dataBind.draw_instanced(0, 4, instances.size()); } diff --git a/Runtime/Graphics/Shaders/CRandomStaticFilter.cpp b/Runtime/Graphics/Shaders/CRandomStaticFilter.cpp index 97379a331..b60b76bf5 100644 --- a/Runtime/Graphics/Shaders/CRandomStaticFilter.cpp +++ b/Runtime/Graphics/Shaders/CRandomStaticFilter.cpp @@ -86,7 +86,9 @@ void CRandomStaticFilter::draw(const zeus::CColor& color, float t) { m_uniform.color = color; m_uniform.randOff = ROUND_UP_32(int64_t(rand()) * 32767 / RAND_MAX); m_uniform.discardThres = 1.f - t; +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CScanLinesFilter.cpp b/Runtime/Graphics/Shaders/CScanLinesFilter.cpp index 12ce0e6e2..bdc1713f5 100644 --- a/Runtime/Graphics/Shaders/CScanLinesFilter.cpp +++ b/Runtime/Graphics/Shaders/CScanLinesFilter.cpp @@ -34,7 +34,9 @@ void CScanLinesFilter::draw(const zeus::CColor& color) { SCOPED_GRAPHICS_DEBUG_GROUP("CScanLinesFilter::draw", zeus::skMagenta); m_uniform.color = color; +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 670); } diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp index 3712ed983..e9481fb90 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp @@ -161,7 +161,9 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) { m_uniform.m_strength.x = m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width)); m_uniform.m_strength.y = m_uniform.m_matrix[1][1] * m_strength * 0.5f; +#if !HSH_PROFILE_MODE m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp index 715681ac4..ba3b701d8 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp @@ -65,6 +65,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, TLockedToken verts{{ {{0.f, 0.f, z}, {0.f, 0.f}}, {{0.f, 1.f, z}, {0.f, uvScale}}, @@ -81,6 +82,7 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z m_uniform.m_matrix[3][3] = 1.f; m_uniform.m_color = color; m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } @@ -99,10 +101,12 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) {{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}}, {{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}}, }}; +#if !HSH_PROFILE_MODE m_vbo.load(verts); m_uniform.m_color = color; m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } @@ -110,12 +114,14 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const std::array& verts, float lod) { SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawVerts", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_vbo.load(verts); m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_color = color; m_uniform.m_lod = lod; m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } @@ -123,6 +129,7 @@ void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const std::array< void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) { SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::DrawFilter", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_uniform.m_matrix = zeus::CMatrix4f(); m_uniform.m_lod = 0.f; m_uniform.m_color = color; @@ -166,6 +173,7 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col m_vbo.load(FullscreenVerts); m_dataBind.draw(0, FullscreenVerts.size()); } +#endif } CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, hsh::texture2d tex) { diff --git a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp index 3dc7de6a9..9692f3cd2 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp @@ -61,8 +61,10 @@ CThermalColdFilter::CThermalColdFilter() { void CThermalColdFilter::draw() { SCOPED_GRAPHICS_DEBUG_GROUP("CThermalColdFilter::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport); m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CThermalHotFilter.cpp b/Runtime/Graphics/Shaders/CThermalHotFilter.cpp index 7ebb397e8..b161f47e7 100644 --- a/Runtime/Graphics/Shaders/CThermalHotFilter.cpp +++ b/Runtime/Graphics/Shaders/CThermalHotFilter.cpp @@ -44,8 +44,10 @@ CThermalHotFilter::CThermalHotFilter() { void CThermalHotFilter::draw() { SCOPED_GRAPHICS_DEBUG_GROUP("CThermalHotFilter::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport); m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CWorldShadowShader.cpp b/Runtime/Graphics/Shaders/CWorldShadowShader.cpp index 42e4dab4c..04829ae2e 100644 --- a/Runtime/Graphics/Shaders/CWorldShadowShader.cpp +++ b/Runtime/Graphics/Shaders/CWorldShadowShader.cpp @@ -39,6 +39,7 @@ void CWorldShadowShader::bindRenderTarget() { m_tex.attach(); } void CWorldShadowShader::drawBase(float extent) { SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::drawBase", zeus::skMagenta); +#if !HSH_PROFILE_MODE const std::array verts{{ {{-extent, 0.f, extent}}, {{extent, 0.f, extent}}, @@ -50,6 +51,7 @@ void CWorldShadowShader::drawBase(float extent) { m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniform.m_color = zeus::skWhite; m_uniBuf.load(m_uniform); +#endif m_zDataBind.draw(0, 4); } @@ -57,8 +59,10 @@ void CWorldShadowShader::drawBase(float extent) { void CWorldShadowShader::lightenShadow() { SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::lightenShadow", zeus::skMagenta); +#if !HSH_PROFILE_MODE m_uniform.m_color = zeus::CColor(1.f, 0.25f); m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp index 5804be126..96fceec19 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp @@ -65,6 +65,7 @@ CXRayBlurFilter::CXRayBlurFilter(TLockedToken& tex) : m_paletteTex(tex void CXRayBlurFilter::draw(float amount) { SCOPED_GRAPHICS_DEBUG_GROUP("CXRayBlurFilter::draw", zeus::skMagenta); +#if !HSH_PROFILE_MODE CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport); const float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f; @@ -81,6 +82,7 @@ void CXRayBlurFilter::draw(float amount) { } m_uniBuf.load(m_uniform); +#endif m_dataBind.draw(0, 4); } diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index 2973df8ad..4dd3e46db 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -90,6 +90,7 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) { const zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true); const zeus::CMatrix4f mat = proj * mv; +#if !HSH_PROFILE_MODE m_uniBuf.load({mat, col}); if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) { zeus::CColor colPremul = col * col.a(); @@ -121,6 +122,7 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) { img.m_dataBindingOverdraw[idx].draw_instanced(0, 4, 1); } } +#endif } void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImageDef& image) { diff --git a/Runtime/MP1/World/CFlaahgra.cpp b/Runtime/MP1/World/CFlaahgra.cpp index 3bf2dc186..36af39252 100644 --- a/Runtime/MP1/World/CFlaahgra.cpp +++ b/Runtime/MP1/World/CFlaahgra.cpp @@ -130,6 +130,9 @@ void CFlaahgra::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM } GetMirrorWaypoints(mgr); +#if HSH_PROFILE_MODE + GatherAssets(mgr); +#endif break; } case EScriptObjectMessage::Activate: { diff --git a/Runtime/Particle/CDecal.cpp b/Runtime/Particle/CDecal.cpp index 9b72eac57..e47af6f31 100644 --- a/Runtime/Particle/CDecal.cpp +++ b/Runtime/Particle/CDecal.cpp @@ -29,6 +29,14 @@ CDecal::CDecal(const TToken& desc, const zeus::CTransform& xf } else { x5c_29_modelInvalid = true; } + + for (auto& decal : x3c_decalQuads) { + hsh::texture2d tex{}; + if (CUVElement* texDesc = decal.m_desc->x14_TEX.get()) { + tex = texDesc->GetValueTexture(x58_frameIdx)->GetBooTexture(); + } + CDecalShaders::BuildShaderDataBinding(decal.m_binding, decal, tex); + } } bool CDecal::InitQuad(CQuadDecal& quad, const SQuadDescr& desc) { @@ -97,18 +105,16 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) { modXf.origin += offset; CGraphics::SetModelMatrix(modXf); +#if !HSH_PROFILE_MODE SParticleUniforms uniformData = { CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), {1.f, 1.f, 1.f, 1.f}, }; decal.m_uniformBuf.load(uniformData); +#endif SUVElementSet uvSet = {0.f, 1.f, 0.f, 1.f}; if (CUVElement* tex = desc.x14_TEX.get()) { - TLockedToken texObj = tex->GetValueTexture(x58_frameIdx); - if (!texObj.IsLoaded()) { - return; - } tex->GetValueUV(x58_frameIdx, uvSet); g_instTexData.clear(); @@ -135,9 +141,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) { inst.uvs[2] = hsh::float2(uvSet.xMin, uvSet.yMax); inst.uvs[3] = hsh::float2(uvSet.xMax, uvSet.yMax); +#if !HSH_PROFILE_MODE decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instTexData.data(), g_instTexData.size()}); - m_shaderBuilder.BuildShaderDataBinding(decal, texObj->GetBooTexture()) - .draw_instanced(0, 4, g_instIndTexData.size()); +#endif + decal.m_binding.draw_instanced(0, 4, g_instTexData.size()); } else { g_instNoTexData.clear(); g_instNoTexData.reserve(1); @@ -159,8 +166,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) { } inst.color = color; +#if !HSH_PROFILE_MODE decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instNoTexData.data(), g_instNoTexData.size()}); - m_shaderBuilder.BuildShaderDataBinding(decal, hsh::texture2d{}).draw_instanced(0, 4, g_instNoTexData.size()); +#endif + decal.m_binding.draw_instanced(0, 4, g_instNoTexData.size()); } } diff --git a/Runtime/Particle/CDecal.hpp b/Runtime/Particle/CDecal.hpp index 0b7e92b11..f2af7892a 100644 --- a/Runtime/Particle/CDecal.hpp +++ b/Runtime/Particle/CDecal.hpp @@ -22,6 +22,7 @@ struct CQuadDecal { CQuadDecal() = default; CQuadDecal(s32 i, float f) : x4_lifetime(i), x8_rotation(f) {} + hsh::binding m_binding; hsh::dynamic_owner m_instBuf; hsh::dynamic_owner> m_uniformBuf; }; @@ -41,8 +42,6 @@ class CDecal { bool x5c_29_modelInvalid : 1 = false; zeus::CVector3f x60_rotation; - CDecalShaders m_shaderBuilder{}; - bool InitQuad(CQuadDecal& quad, const SQuadDescr& desc); public: diff --git a/Runtime/Particle/CElementGen.cpp b/Runtime/Particle/CElementGen.cpp index c471c883a..991c2dd4d 100644 --- a/Runtime/Particle/CElementGen.cpp +++ b/Runtime/Particle/CElementGen.cpp @@ -238,6 +238,8 @@ CElementGen::CElementGen(TToken gen, EModelOrientationType orie } m_uniformBufPmus = hsh::create_dynamic_uniform_buffer(); } + if (!x26c_31_LINE) + CElementGenShaders::BuildShaderDataBinding(*this); } CElementGen::~CElementGen() { @@ -912,7 +914,9 @@ void CElementGen::RenderModels(const CActorLights* actorLights) { break; } +#if !HSH_PROFILE_MODE m_uniformBufPmus.load({CGraphics::GetPerspectiveProjectionMatrix(true), {1.f, 1.f, 1.f, 1.f}}); +#endif } zeus::CTransform orient = zeus::CTransform(); @@ -1044,9 +1048,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) { if (g_subtractBlend) { model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)}); } else if (desc->x44_31_x31_25_PMAB) { - CModelFlags flags{7, 0, 1, col}; - flags.m_extendedShader = EExtendedShader::ForcedAdditiveNoZWrite; - model->Draw(flags); + model->Draw({7, 0, 1, col}); } else if (1.f == col.a()) { model->Draw({0, 0, 3, zeus::skWhite}); } else { @@ -1061,12 +1063,16 @@ void CElementGen::RenderModels(const CActorLights* actorLights) { if (desc->x45_24_x31_26_PMUS) { switch (m_shaderClass) { case CElementGenShaders::EShaderClass::Tex: +#if !HSH_PROFILE_MODE m_instBufPmus.load(g_instTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instTexData.size()); +#endif + m_bindingPmus.draw_instanced(0, 4, g_instTexData.size()); break; case CElementGenShaders::EShaderClass::NoTex: +#if !HSH_PROFILE_MODE m_instBufPmus.load(g_instNoTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instNoTexData.size()); +#endif + m_bindingPmus.draw_instanced(0, 4, g_instNoTexData.size()); break; default: break; @@ -1076,7 +1082,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) { if (x26d_26_modelsUseLights) CGraphics::DisableAllLights(); - CGraphics::SetCullMode(ERglCullMode::Front); + CGraphics::SetCullMode(ERglCullMode::Back); if (moveRedToAlphaBuffer) { /* Restore passthrough */ } @@ -1238,7 +1244,9 @@ void CElementGen::RenderParticles() { constUVs = texr->HasConstantUV(); } +#if !HSH_PROFILE_MODE m_uniformBuf.load(uniformData); +#endif std::vector sortItems; if (desc->x44_28_x30_28_SORT) { @@ -1257,9 +1265,9 @@ void CElementGen::RenderParticles() { }); } - bool moveRedToAlphaBuffer = false; - if (sMoveRedToAlphaBuffer && x26c_26_AAPH) - moveRedToAlphaBuffer = true; +// bool moveRedToAlphaBuffer = false; +// if (sMoveRedToAlphaBuffer && x26c_26_AAPH) +// moveRedToAlphaBuffer = true; int mbspVal = std::max(1, x270_MBSP); @@ -1471,12 +1479,16 @@ void CElementGen::RenderParticles() { switch (m_shaderClass) { case CElementGenShaders::EShaderClass::Tex: +#if !HSH_PROFILE_MODE m_instBuf.load(g_instTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size()); +#endif + m_binding.draw_instanced(0, 4, g_instTexData.size()); break; case CElementGenShaders::EShaderClass::NoTex: +#if !HSH_PROFILE_MODE m_instBuf.load(g_instNoTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size()); +#endif + m_binding.draw_instanced(0, 4, g_instNoTexData.size()); break; default: break; @@ -1585,12 +1597,16 @@ void CElementGen::RenderParticles() { } switch (m_shaderClass) { case CElementGenShaders::EShaderClass::Tex: +#if !HSH_PROFILE_MODE m_instBuf.load(g_instTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size()); +#endif + m_binding.draw_instanced(0, 4, g_instTexData.size()); break; case CElementGenShaders::EShaderClass::NoTex: +#if !HSH_PROFILE_MODE m_instBuf.load(g_instNoTexData); - m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size()); +#endif + m_binding.draw_instanced(0, 4, g_instNoTexData.size()); break; default: break; @@ -1609,8 +1625,10 @@ void CElementGen::RenderParticlesIndirectTexture() { x178_localScaleTransform; CGraphics::SetModelMatrix(systemViewPointMatrix); +#if !HSH_PROFILE_MODE m_uniformBuf.load( {CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), {1.f, 1.f, 1.f, 1.f}}); +#endif CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0); @@ -1721,13 +1739,14 @@ void CElementGen::RenderParticlesIndirectTexture() { inst.texrTindUVs[3] = zeus::CVector4f{uvs.xMin, uvs.yMin, uvsInd.xMin, uvsInd.yMin}; inst.sceneUVs = zeus::CVector4f{clipRect.x18_uvXMin, 1.f - clipRect.x24_uvYMax, clipRect.x1c_uvXMax, 1.f - clipRect.x20_uvYMin}; - m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instIndTexData.size() - 1); + m_binding.draw_instanced(0, 4, g_instIndTexData.size() - 1); } if (!g_instIndTexData.empty()) { +#if !HSH_PROFILE_MODE m_instBuf.load(g_instIndTexData); - // CGraphics::SetShaderDataBinding(m_normalDataBind); - // CGraphics::DrawInstances(0, 4, g_instIndTexData.size()); +#endif + m_binding.draw_instanced(0, 4, g_instIndTexData.size()); } } diff --git a/Runtime/Particle/CElementGen.hpp b/Runtime/Particle/CElementGen.hpp index a46a89de0..3e7055c90 100644 --- a/Runtime/Particle/CElementGen.hpp +++ b/Runtime/Particle/CElementGen.hpp @@ -134,6 +134,8 @@ private: std::unique_ptr m_lineRenderer; CElementGenShaders::EShaderClass m_shaderClass; + hsh::binding m_binding; + hsh::binding m_bindingPmus; void AccumulateBounds(const zeus::CVector3f& pos, float size); diff --git a/Runtime/Particle/CParticleSwoosh.cpp b/Runtime/Particle/CParticleSwoosh.cpp index 7bcc838f7..22e88613b 100644 --- a/Runtime/Particle/CParticleSwoosh.cpp +++ b/Runtime/Particle/CParticleSwoosh.cpp @@ -1002,11 +1002,13 @@ void CParticleSwoosh::Render(const CActorLights*) { } } +#if !HSH_PROFILE_MODE zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(); m_uniformBuf.load({mvp}); if (!m_cachedVerts.empty()) { m_vertBuf.load(m_cachedVerts); } +#endif } void CParticleSwoosh::SetOrientation(const zeus::CTransform& xf) {