From d5c7efce58a2dc9e644ca6d9d31b58339f803411 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 28 Jan 2017 17:58:16 -1000 Subject: [PATCH] Tons of refactors and bug fixes --- DataSpec/DNAMP1/FRME.cpp | 2 +- DataSpec/DNAMP1/STRG.cpp | 12 +- Runtime/CGameOptions.cpp | 2 +- Runtime/CToken.cpp | 4 + Runtime/Graphics/CGraphics.cpp | 132 ++++++++++---- Runtime/Graphics/CMakeLists.txt | 8 +- Runtime/Graphics/CTexture.hpp | 16 ++ Runtime/Graphics/CTextureBoo.cpp | 116 +++++++++++- .../Graphics/Shaders/CCameraBlurFilter.cpp | 2 + .../Shaders/CCameraBlurFilterGLSL.cpp | 25 ++- .../Shaders/CCameraBlurFilterMetal.cpp | 17 +- .../Graphics/Shaders/CColoredQuadFilter.cpp | 2 + .../Shaders/CColoredQuadFilterGLSL.cpp | 63 ++++--- .../Shaders/CColoredQuadFilterMetal.cpp | 45 +++-- Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp | 2 + .../Graphics/Shaders/CSpaceWarpFilterGLSL.cpp | 23 +-- .../Shaders/CSpaceWarpFilterMetal.cpp | 17 +- .../Graphics/Shaders/CTextSupportShader.cpp | 62 +++++++ .../Graphics/Shaders/CTextSupportShader.hpp | 103 +++++++++++ .../Shaders/CTextSupportShaderGLSL.cpp | 169 ++++++++++++++++++ ...eFilter.cpp => CTextSupportShaderHLSL.cpp} | 0 .../Shaders/CTextSupportShaderMetal.cpp | 162 +++++++++++++++++ .../Graphics/Shaders/CTexturedQuadFilter.cpp | 4 + .../Shaders/CTexturedQuadFilterGLSL.cpp | 128 +++++++------ .../Shaders/CTexturedQuadFilterMetal.cpp | 70 ++++---- .../Graphics/Shaders/CThermalColdFilter.cpp | 2 + .../Shaders/CThermalColdFilterGLSL.cpp | 25 ++- .../Shaders/CThermalColdFilterMetal.cpp | 17 +- .../Graphics/Shaders/CThermalHotFilter.cpp | 2 + .../Shaders/CThermalHotFilterGLSL.cpp | 28 ++- .../Shaders/CThermalHotFilterMetal.cpp | 19 +- Runtime/Graphics/Shaders/CXRayBlurFilter.cpp | 2 + .../Graphics/Shaders/CXRayBlurFilterGLSL.cpp | 26 ++- .../Graphics/Shaders/CXRayBlurFilterMetal.cpp | 17 +- .../Graphics/Shaders/CXrayOutlineFilter.hpp | 0 .../Shaders/CXrayOutlineFilterGLSL.cpp | 0 .../Shaders/CXrayOutlineFilterHLSL.cpp | 0 .../Shaders/CXrayOutlineFilterMetal.cpp | 0 .../Graphics/Shaders/TMultiBlendShader.hpp | 55 ++---- .../Shaders/TMultiBlendShaderDecl.hpp | 24 +-- Runtime/Graphics/Shaders/TShader.hpp | 36 +--- Runtime/Graphics/Shaders/TShaderDecl.hpp | 16 +- Runtime/GuiSys/CAuiEnergyBarT01.hpp | 1 + Runtime/GuiSys/CAuiImagePane.hpp | 1 + Runtime/GuiSys/CAuiMeter.hpp | 2 +- Runtime/GuiSys/CFontImageDef.cpp | 15 +- Runtime/GuiSys/CFontImageDef.hpp | 6 +- Runtime/GuiSys/CGuiCamera.cpp | 4 +- Runtime/GuiSys/CGuiCamera.hpp | 2 + Runtime/GuiSys/CGuiCompoundWidget.cpp | 4 +- Runtime/GuiSys/CGuiFrame.cpp | 26 ++- Runtime/GuiSys/CGuiFrame.hpp | 3 +- Runtime/GuiSys/CGuiGroup.hpp | 2 +- Runtime/GuiSys/CGuiHeadWidget.hpp | 2 +- Runtime/GuiSys/CGuiLight.hpp | 2 +- Runtime/GuiSys/CGuiModel.hpp | 2 +- Runtime/GuiSys/CGuiPane.hpp | 2 +- Runtime/GuiSys/CGuiSliderGroup.hpp | 2 +- Runtime/GuiSys/CGuiTableGroup.hpp | 2 +- Runtime/GuiSys/CGuiTextPane.cpp | 6 +- Runtime/GuiSys/CGuiTextPane.hpp | 8 +- Runtime/GuiSys/CGuiTextSupport.cpp | 13 +- Runtime/GuiSys/CGuiTextSupport.hpp | 5 +- Runtime/GuiSys/CGuiWidget.hpp | 2 +- Runtime/GuiSys/CInstruction.cpp | 2 +- Runtime/GuiSys/CRasterFont.cpp | 14 +- Runtime/GuiSys/CRasterFont.hpp | 34 ++-- Runtime/GuiSys/CTextExecuteBuffer.cpp | 16 +- Runtime/GuiSys/CTextExecuteBuffer.hpp | 10 +- Runtime/GuiSys/CTextParser.cpp | 14 +- Runtime/GuiSys/CTextRenderBuffer.cpp | 165 +++++++++-------- Runtime/GuiSys/CTextRenderBuffer.hpp | 47 ++--- Runtime/MP1/CFrontEndUI.cpp | 5 +- Runtime/MP1/CSlideShow.cpp | 6 +- Runtime/MP1/MP1.cpp | 8 +- Runtime/World/CWorldTransManager.cpp | 2 +- hecl | 2 +- specter | 2 +- 78 files changed, 1276 insertions(+), 618 deletions(-) create mode 100644 Runtime/Graphics/Shaders/CTextSupportShader.cpp create mode 100644 Runtime/Graphics/Shaders/CTextSupportShader.hpp create mode 100644 Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp rename Runtime/Graphics/Shaders/{CXrayOutlineFilter.cpp => CTextSupportShaderHLSL.cpp} (100%) create mode 100644 Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp delete mode 100644 Runtime/Graphics/Shaders/CXrayOutlineFilter.hpp delete mode 100644 Runtime/Graphics/Shaders/CXrayOutlineFilterGLSL.cpp delete mode 100644 Runtime/Graphics/Shaders/CXrayOutlineFilterHLSL.cpp delete mode 100644 Runtime/Graphics/Shaders/CXrayOutlineFilterMetal.cpp diff --git a/DataSpec/DNAMP1/FRME.cpp b/DataSpec/DNAMP1/FRME.cpp index 4673370ed..492cbb675 100644 --- a/DataSpec/DNAMP1/FRME.cpp +++ b/DataSpec/DNAMP1/FRME.cpp @@ -368,7 +368,7 @@ bool FRME::Extract(const SpecBase &dataSpec, for (const FRME::Widget& w : frme.widgets) { os << "binding = None\n" - "angle = Quaternion((0.0, 0.0, 0.0), 0)\n"; + "angle = Quaternion((1.0, 0.0, 0.0), 0)\n"; if (w.type == SBIG('CAMR')) { using CAMRInfo = Widget::CAMRInfo; diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index d5aa5789c..4f20480c1 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -93,15 +93,11 @@ static std::u16string::const_iterator CookTextureList(std::u16string& ret, { while (true) { - auto end = str.find(u',', it - str.begin()); + auto end = str.find_first_of(u",;", it - str.begin()); if (end == std::u16string::npos) - { - end = str.find(u';', it - str.begin()); - if (end == std::u16string::npos) - Log.report(logvisor::Fatal, - "Missing comma/semicolon token while pasing font tag"); - } - auto endIt = str.begin() + end + 1; + Log.report(logvisor::Fatal, + "Missing comma/semicolon token while pasing font tag"); + auto endIt = str.begin() + end; hecl::ProjectPath path = UniqueIDBridge::MakePathFromString( hecl::Char16ToUTF8(std::u16string(it, endIt))); diff --git a/Runtime/CGameOptions.cpp b/Runtime/CGameOptions.cpp index 8edeead01..bf3aa97e4 100644 --- a/Runtime/CGameOptions.cpp +++ b/Runtime/CGameOptions.cpp @@ -125,7 +125,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const for (const auto& world : memWorlds) { TLockedToken saveWorld = - g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.first}); + g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()}); for (TEditorId cineId : saveWorld->GetCinematics()) w.WriteEncoded(GetCinematicState(world.first, cineId), 1); diff --git a/Runtime/CToken.cpp b/Runtime/CToken.cpp index 732e24f6b..f32696fbf 100644 --- a/Runtime/CToken.cpp +++ b/Runtime/CToken.cpp @@ -152,7 +152,11 @@ CToken::CToken(const CToken& other) : x0_objRef(other.x0_objRef) { if (x0_objRef) + { ++x0_objRef->x0_refCount; + if (other.x4_lockHeld) + Lock(); + } } CToken::CToken(CToken&& other) : x0_objRef(other.x0_objRef), x4_lockHeld(other.x4_lockHeld) diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index fe8e7caeb..a812f9a4d 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -2,6 +2,7 @@ #include "Graphics/CLight.hpp" #include "zeus/Math.hpp" #include "CTimeProvider.hpp" +#include "Shaders/CTextSupportShader.hpp" namespace urde { @@ -114,6 +115,9 @@ void CGraphics::EndScene() * so simulate field-flipping with XOR instead */ g_InterruptLastFrameUsedAbove ^= 1; g_LastFrameUsedAbove = g_InterruptLastFrameUsedAbove; + + /* Flush text instance buffers just before GPU command list submission */ + CTextSupportShader::UpdateBuffers(); } void CGraphics::SetAlphaCompare(ERglAlphaFunc comp0, u8 ref0, ERglAlphaOp op, ERglAlphaFunc comp1, u8 ref1) @@ -222,49 +226,99 @@ zeus::CMatrix4f CGraphics::CalculatePerspectiveMatrix(float fovy, float aspect, zeus::CMatrix4f CGraphics::GetPerspectiveProjectionMatrix(bool forRenderer) { - float rml = g_Proj.x8_right - g_Proj.x4_left; - float rpl = g_Proj.x8_right + g_Proj.x4_left; - float tmb = g_Proj.xc_top - g_Proj.x10_bottom; - float tpb = g_Proj.xc_top + g_Proj.x10_bottom; - float fpn = g_Proj.x18_far + g_Proj.x14_near; - float fmn = g_Proj.x18_far - g_Proj.x14_near; + if (g_Proj.x0_persp) + { + float rml = g_Proj.x8_right - g_Proj.x4_left; + float rpl = g_Proj.x8_right + g_Proj.x4_left; + float tmb = g_Proj.xc_top - g_Proj.x10_bottom; + float tpb = g_Proj.xc_top + g_Proj.x10_bottom; + float fpn = g_Proj.x18_far + g_Proj.x14_near; + float fmn = g_Proj.x18_far - g_Proj.x14_near; - if (!forRenderer) - { - return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, - 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, - 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, - 0.f, 0.f, -1.f, 0.f); - } + if (!forRenderer) + { + return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, + 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, + 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, + 0.f, 0.f, -1.f, 0.f); + } - switch (g_BooPlatform) - { - case boo::IGraphicsDataFactory::Platform::OpenGL: - default: - { - return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, - 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, - 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, - 0.f, 0.f, -1.f, 0.f); + switch (g_BooPlatform) + { + case boo::IGraphicsDataFactory::Platform::OpenGL: + default: + { + return zeus::CMatrix4f(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, + 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, + 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, + 0.f, 0.f, -1.f, 0.f); + } + case boo::IGraphicsDataFactory::Platform::D3D11: + case boo::IGraphicsDataFactory::Platform::D3D12: + case boo::IGraphicsDataFactory::Platform::Metal: + { + zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, + 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, + 0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn, + 0.f, 0.f, -1.f, 0.f); + return PlusOneZ * mat2; + } + case boo::IGraphicsDataFactory::Platform::Vulkan: + { + zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, + 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, + 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, + 0.f, 0.f, -1.f, 0.f); + return PlusOneZFlip * mat2; + } + } } - case boo::IGraphicsDataFactory::Platform::D3D11: - case boo::IGraphicsDataFactory::Platform::D3D12: - case boo::IGraphicsDataFactory::Platform::Metal: + else { - zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, - 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, - 0.f, 0.f, g_Proj.x18_far / fmn, g_Proj.x14_near * g_Proj.x18_far / fmn, - 0.f, 0.f, -1.f, 0.f); - return PlusOneZ * mat2; - } - case boo::IGraphicsDataFactory::Platform::Vulkan: - { - zeus::CMatrix4f mat2(2.f * g_Proj.x14_near / rml, 0.f, rpl / rml, 0.f, - 0.f, 2.f * g_Proj.x14_near / tmb, tpb / tmb, 0.f, - 0.f, 0.f, -fpn / fmn, -2.f * g_Proj.x18_far * g_Proj.x14_near / fmn, - 0.f, 0.f, -1.f, 0.f); - return PlusOneZFlip * mat2; - } + float rml = g_Proj.x8_right - g_Proj.x4_left; + float rpl = g_Proj.x8_right + g_Proj.x4_left; + float tmb = g_Proj.xc_top - g_Proj.x10_bottom; + float tpb = g_Proj.xc_top + g_Proj.x10_bottom; + float fpn = g_Proj.x18_far + g_Proj.x14_near; + float fmn = g_Proj.x18_far - g_Proj.x14_near; + + if (!forRenderer) + { + return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml, + 0.f, 2.f / tmb, 0.f, -tpb / tmb, + 0.f, 0.f, -2.f / fmn, -fpn / fmn, + 0.f, 0.f, 0.f, 1.f); + } + + switch (g_BooPlatform) + { + case boo::IGraphicsDataFactory::Platform::OpenGL: + default: + { + return zeus::CMatrix4f(2.f / rml, 0.f, 0.f, -rpl / rml, + 0.f, 2.f / tmb, 0.f, -tpb / tmb, + 0.f, 0.f, -2.f / fmn, -fpn / fmn, + 0.f, 0.f, 0.f, 1.f); + } + case boo::IGraphicsDataFactory::Platform::D3D11: + case boo::IGraphicsDataFactory::Platform::D3D12: + case boo::IGraphicsDataFactory::Platform::Metal: + { + zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, + 0.f, 2.f / tmb, 0.f, -tpb / tmb, + 0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn, + 0.f, 0.f, 0.f, 1.f); + return PlusOneZ * mat2; + } + case boo::IGraphicsDataFactory::Platform::Vulkan: + { + zeus::CMatrix4f mat2(2.f / rml, 0.f, 0.f, -rpl / rml, + 0.f, 2.f / tmb, 0.f, -tpb / tmb, + 0.f, 0.f, 1.f / fmn, -g_Proj.x14_near / fmn, + 0.f, 0.f, 0.f, 1.f); + return PlusOneZFlip * mat2; + } + } } } diff --git a/Runtime/Graphics/CMakeLists.txt b/Runtime/Graphics/CMakeLists.txt index edb6d6507..4212cadc9 100644 --- a/Runtime/Graphics/CMakeLists.txt +++ b/Runtime/Graphics/CMakeLists.txt @@ -8,7 +8,8 @@ if(WIN32) Shaders/CThermalHotFilterHLSL.cpp Shaders/CSpaceWarpFilterHLSL.cpp Shaders/CCameraBlurFilterHLSL.cpp - Shaders/CXRayBlurFilterHLSL.cpp) + Shaders/CXRayBlurFilterHLSL.cpp + Shaders/CTextSupportShaderHLSL.cpp) elseif(BOO_HAS_METAL) set(PLAT_SRCS Shaders/CLineRendererShadersMetal.cpp @@ -19,7 +20,8 @@ elseif(BOO_HAS_METAL) Shaders/CThermalHotFilterMetal.cpp Shaders/CSpaceWarpFilterMetal.cpp Shaders/CCameraBlurFilterMetal.cpp - Shaders/CXRayBlurFilterMetal.cpp) + Shaders/CXRayBlurFilterMetal.cpp + Shaders/CTextSupportShaderMetal.cpp) endif() set(GRAPHICS_SOURCES @@ -48,12 +50,12 @@ set(GRAPHICS_SOURCES Shaders/CTexturedQuadFilter.hpp Shaders/CTexturedQuadFilter.cpp Shaders/CTexturedQuadFilterGLSL.cpp Shaders/CColoredQuadFilter.hpp Shaders/CColoredQuadFilter.cpp Shaders/CColoredQuadFilterGLSL.cpp Shaders/CModelShaders.hpp Shaders/CModelShaders.cpp Shaders/CModelShadersGLSL.cpp - Shaders/CXrayOutlineFilter.hpp Shaders/CXrayOutlineFilter.cpp Shaders/CXrayOutlineFilterGLSL.cpp Shaders/CThermalColdFilter.hpp Shaders/CThermalColdFilter.cpp Shaders/CThermalColdFilterGLSL.cpp Shaders/CThermalHotFilter.hpp Shaders/CThermalHotFilter.cpp Shaders/CThermalHotFilterGLSL.cpp Shaders/CSpaceWarpFilter.hpp Shaders/CSpaceWarpFilter.cpp Shaders/CSpaceWarpFilterGLSL.cpp Shaders/CCameraBlurFilter.hpp Shaders/CCameraBlurFilter.cpp Shaders/CCameraBlurFilterGLSL.cpp Shaders/CXRayBlurFilter.hpp Shaders/CXRayBlurFilter.cpp Shaders/CXRayBlurFilterGLSL.cpp + Shaders/CTextSupportShader.hpp Shaders/CTextSupportShader.cpp Shaders/CTextSupportShaderGLSL.cpp ${PLAT_SRCS}) runtime_add_list(Graphics GRAPHICS_SOURCES) diff --git a/Runtime/Graphics/CTexture.hpp b/Runtime/Graphics/CTexture.hpp index f3f8bc35f..7bf921784 100644 --- a/Runtime/Graphics/CTexture.hpp +++ b/Runtime/Graphics/CTexture.hpp @@ -14,6 +14,19 @@ class CVParamTransfer; class CTexture { +public: + enum class EFontType + { + None = -1, + OneLayer = 0, /* Fill bit0 */ + OneLayerOutline = 1, /* Fill bit0, Outline bit1 */ + FourLayers = 2, + TwoLayersOutlines = 3, /* Fill bit0/2, Outline bit1/3 */ + TwoLayers = 4, /* Fill bit0/1 and copied to bit2/3 */ + TwoLayersOutlines2 = 8 /* Fill bit2/3, Outline bit0/1 */ + }; + +private: ETexelFormat x0_fmt; u16 x4_w; u16 x6_h; @@ -22,6 +35,7 @@ class CTexture boo::ITexture* m_booTex; boo::ITexture* m_paletteTex; std::unique_ptr m_otex; + EFontType m_ftype = EFontType::None; size_t ComputeMippedTexelCount(); size_t ComputeMippedBlockCountDXT1(); @@ -38,6 +52,7 @@ class CTexture void BuildDXT1FromGCN(CInputStream& in); void BuildRGBA8(const void* data, size_t length); void BuildC8(const void* data, size_t length); + void BuildC8Font(const void* data, EFontType ftype); public: CTexture(ETexelFormat, s16, s16, s32); @@ -57,6 +72,7 @@ public: boo::ITexture* GetPaletteTexture() {return m_paletteTex;} std::unique_ptr BuildMemoryCardTex(u32& sizeOut, ETexelFormat& fmtOut, std::unique_ptr& paletteOut) const; + boo::ITexture* GetFontTexture(EFontType tp); }; CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, diff --git a/Runtime/Graphics/CTextureBoo.cpp b/Runtime/Graphics/CTextureBoo.cpp index 610534c8e..b1fdc3dab 100644 --- a/Runtime/Graphics/CTextureBoo.cpp +++ b/Runtime/Graphics/CTextureBoo.cpp @@ -684,6 +684,108 @@ void CTexture::BuildC8(const void* data, size_t length) }); } +void CTexture::BuildC8Font(const void* data, EFontType ftype) +{ + size_t texelCount = ComputeMippedTexelCount(); + + size_t layerCount; + switch (ftype) + { + case EFontType::OneLayer: + case EFontType::OneLayerOutline: + layerCount = 1; + break; + case EFontType::FourLayers: + layerCount = 4; + break; + case EFontType::TwoLayersOutlines: + case EFontType::TwoLayers: + case EFontType::TwoLayersOutlines2: + layerCount = 2; + break; + default: break; + } + + uint32_t nentries = hecl::SBig(*reinterpret_cast(data)); + const u8* texels = reinterpret_cast(data) + 4 + nentries * 4; + std::unique_ptr buf(new RGBA8[texelCount * layerCount]); + memset(buf.get(), 0, texelCount * layerCount * 4); + + size_t w = x4_w; + size_t h = x6_h; + RGBA8* bufCur = buf.get(); + for (size_t i=0 ; i 1) + w /= 2; + if (h > 1) + h /= 2; + } + + m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + { + m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8, + buf.get(), texelCount * layerCount * 4); + return true; + }); +} + CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt) , x4_w(w) @@ -746,6 +848,7 @@ CTexture::CTexture(std::unique_ptr&& in, u32 length, bool otex) break; case ETexelFormat::C8PC: BuildC8(owned.get() + 12, length - 12); + otex = true; break; default: Log.report(logvisor::Fatal, "invalid texture type %d for boo", int(x0_fmt)); @@ -872,13 +975,24 @@ std::unique_ptr CTexture::BuildMemoryCardTex(u32& sizeOut, ETexelFormat& f return ret; } +boo::ITexture* CTexture::GetFontTexture(EFontType tp) +{ + if (m_ftype != tp && x0_fmt == ETexelFormat::C8PC) + { + m_ftype = tp; + BuildC8Font(m_otex.get() + 12, m_ftype); + } + return m_booTex; +} + CFactoryFnReturn FTextureFactory(const urde::SObjectTag& tag, std::unique_ptr&& in, u32 len, const urde::CVParamTransfer& vparms, CObjectReference* selfRef) { + u32 u32Owned = vparms.GetOwnedObj(); return TToken::GetIObjObjectFor(std::make_unique(std::move(in), len, - vparms.GetOwnedObj() == SBIG('OTEX'))); + u32Owned == SBIG('OTEX'))); } } diff --git a/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp b/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp index 470d03786..86c799dd0 100644 --- a/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp +++ b/Runtime/Graphics/Shaders/CCameraBlurFilter.cpp @@ -62,6 +62,8 @@ void CCameraBlurFilter::draw(float amount) CGraphics::g_BooMainCommandQueue->draw(0, 4); } +void CCameraBlurFilter::Shutdown() {} + URDE_SPECIALIZE_SHADER(CCameraBlurFilter) } diff --git a/Runtime/Graphics/Shaders/CCameraBlurFilterGLSL.cpp b/Runtime/Graphics/Shaders/CCameraBlurFilterGLSL.cpp index a632444a7..95513dec2 100644 --- a/Runtime/Graphics/Shaders/CCameraBlurFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CCameraBlurFilterGLSL.cpp @@ -80,11 +80,11 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CCameraBlurFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, CCameraBlurFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -97,7 +97,7 @@ struct CCameraBlurFilterGLDataBindingFactory : TShader::IData boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; - return cctx.newShaderDataBinding(pipeline, + return cctx.newShaderDataBinding(s_Pipeline, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 1, texs); } @@ -107,35 +107,30 @@ struct CCameraBlurFilterGLDataBindingFactory : TShader::IData struct CCameraBlurFilterVulkanDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CCameraBlurFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } }; #endif -TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"sceneTex"}; const char* uniNames[] = {"CameraBlurUniform"}; - pipeOut = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); return new CCameraBlurFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -143,8 +138,8 @@ TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(b {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); return new CCameraBlurFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CCameraBlurFilterMetal.cpp b/Runtime/Graphics/Shaders/CCameraBlurFilterMetal.cpp index 8928174ba..f2b7feafb 100644 --- a/Runtime/Graphics/Shaders/CCameraBlurFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CCameraBlurFilterMetal.cpp @@ -91,35 +91,34 @@ static const char* FS = URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CCameraBlurFilterMetalDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CCameraBlurFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } }; -TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CCameraBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); return new CCameraBlurFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp b/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp index 3edd64d49..266fdfe4d 100644 --- a/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CColoredQuadFilter.cpp @@ -83,6 +83,8 @@ void CWideScreenFilter::SetViewportToFull() CGraphics::g_BooMainCommandQueue->setViewport(rect); } +void CColoredQuadFilter::Shutdown() {} + const zeus::CRectangle CColoredQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f}; URDE_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) diff --git a/Runtime/Graphics/Shaders/CColoredQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CColoredQuadFilterGLSL.cpp index f6b49ab77..8ed0499a8 100644 --- a/Runtime/Graphics/Shaders/CColoredQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CColoredQuadFilterGLSL.cpp @@ -45,11 +45,29 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) +static boo::IShaderPipeline* s_AlphaPipeline = nullptr; +static boo::IShaderPipeline* s_AddPipeline = nullptr; +static boo::IShaderPipeline* s_MultPipeline = nullptr; + +static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type) +{ + switch (type) + { + case CCameraFilterPass::EFilterType::Blend: + return s_AlphaPipeline; + case CCameraFilterPass::EFilterType::Add: + return s_AddPipeline; + case CCameraFilterPass::EFilterType::Multiply: + return s_MultPipeline; + default: + return nullptr; + } +} + struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, + CCameraFilterPass::EFilterType type, CColoredQuadFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -60,7 +78,7 @@ struct CColoredQuadFilterGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CColoredQuadFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectPipeline(type), vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 0, nullptr); } @@ -85,40 +101,33 @@ struct CColoredQuadFilterVulkanDataBindingFactory : TMultiBlendShader::IDataBindingFactory* -CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut) +CColoredQuadFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* uniNames[] = {"ColoredQuadUniform"}; - alphaPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CColoredQuadFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN TMultiBlendShader::IDataBindingFactory* -CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CColoredQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4} }; vtxFmtOut = ctx.newVertexFormat(1, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CColoredQuadFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CColoredQuadFilterMetal.cpp b/Runtime/Graphics/Shaders/CColoredQuadFilterMetal.cpp index 493081172..66fbfd6c2 100644 --- a/Runtime/Graphics/Shaders/CColoredQuadFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CColoredQuadFilterMetal.cpp @@ -49,40 +49,55 @@ static const char* FS = URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_AlphaPipeline = nullptr; +static boo::IShaderPipeline* s_AddPipeline = nullptr; +static boo::IShaderPipeline* s_MultPipeline = nullptr; + +static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type) +{ + switch (type) + { + case CCameraFilterPass::EFilterType::Blend: + return s_AlphaPipeline; + case CCameraFilterPass::EFilterType::Add: + return s_AddPipeline; + case CCameraFilterPass::EFilterType::Multiply: + return s_MultPipeline; + default: + return nullptr; + } +} + struct CColoredQuadFilterMetalDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, + CCameraFilterPass::EFilterType type, CColoredQuadFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 0, nullptr); } }; TMultiBlendShader::IDataBindingFactory* -CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CColoredQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4} }; - vtxFmtOut = ctx.newVertexFormat(1, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(1, VtxVmt); + s_AlphaPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CColoredQuadFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp index 8b6e6259a..e865ed9a9 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilter.cpp @@ -152,6 +152,8 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) CGraphics::g_BooMainCommandQueue->draw(0, 4); } +void CSpaceWarpFilter::Shutdown() {} + URDE_SPECIALIZE_SHADER(CSpaceWarpFilter) } diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilterGLSL.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilterGLSL.cpp index 1b9f64d52..2267f27db 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilterGLSL.cpp @@ -53,11 +53,11 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CSpaceWarpFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, CSpaceWarpFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -70,7 +70,7 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader::IDataBi boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex}; - return cctx.newShaderDataBinding(pipeline, + return cctx.newShaderDataBinding(s_Pipeline, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 2, texs); } @@ -80,8 +80,6 @@ struct CSpaceWarpFilterGLDataBindingFactory : TShader::IDataBi struct CSpaceWarpFilterVulkanDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CSpaceWarpFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); @@ -95,20 +93,17 @@ struct CSpaceWarpFilterVulkanDataBindingFactory : TShader::IDa }; #endif -TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"sceneTex", "indTex"}; const char* uniNames[] = {"SpaceWarpUniform"}; - pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CSpaceWarpFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -116,8 +111,8 @@ TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CSpaceWarpFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CSpaceWarpFilterMetal.cpp b/Runtime/Graphics/Shaders/CSpaceWarpFilterMetal.cpp index e2045758b..55a0fc1c0 100644 --- a/Runtime/Graphics/Shaders/CSpaceWarpFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CSpaceWarpFilterMetal.cpp @@ -57,35 +57,34 @@ static const char* FS = URDE_DECL_SPECIALIZE_SHADER(CSpaceWarpFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CSpaceWarpFilterMetalDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CSpaceWarpFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_warpTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; -TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CSpaceWarpFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CSpaceWarpFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CTextSupportShader.cpp b/Runtime/Graphics/Shaders/CTextSupportShader.cpp new file mode 100644 index 000000000..f0f1eccce --- /dev/null +++ b/Runtime/Graphics/Shaders/CTextSupportShader.cpp @@ -0,0 +1,62 @@ +#include "CTextSupportShader.hpp" +#include "GuiSys/CRasterFont.hpp" + +namespace urde +{ + +boo::IVertexFormat* CTextSupportShader::s_TextVtxFmt = nullptr; +boo::IShaderPipeline* CTextSupportShader::s_TextAlphaPipeline = nullptr; +boo::IShaderPipeline* CTextSupportShader::s_TextAddPipeline = nullptr; + +boo::IVertexFormat* CTextSupportShader::s_ImageVtxFmt = nullptr; +boo::IShaderPipeline* CTextSupportShader::s_ImageAlphaPipeline = nullptr; +boo::IShaderPipeline* CTextSupportShader::s_ImageAddPipeline = nullptr; + +hecl::VertexBufferPool CTextSupportShader::s_CharInsts; +hecl::VertexBufferPool CTextSupportShader::s_ImgInsts; +hecl::UniformBufferPool CTextSupportShader::s_Uniforms; + +void CTextSupportShader::CharacterInstance::SetMetrics(const CGlyph& glyph, + const zeus::CVector2i& offset) +{ + float layer = glyph.GetLayer(); + + m_pos[0].assign(offset.x, 0.f, offset.y); + m_uv[0].assign(glyph.GetStartU(), 1.f - glyph.GetStartV(), layer); + + m_pos[1].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y); + m_uv[1].assign(glyph.GetEndU(), 1.f - glyph.GetStartV(), layer); + + m_pos[2].assign(offset.x, 0.f, offset.y + glyph.GetCellHeight()); + m_uv[2].assign(glyph.GetStartU(), 1.f - glyph.GetEndV(), layer); + + m_pos[3].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y + glyph.GetCellHeight()); + m_uv[3].assign(glyph.GetEndU(), 1.f - glyph.GetEndV(), layer); +} + +void CTextSupportShader::ImageInstance::SetMetrics(const zeus::CVector2f& imgSize, + const zeus::CVector2i& offset) +{ + m_pos[0].assign(offset.x, 0.f, offset.y); + m_uv[0].assign(0.f, 1.f); + + m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y); + m_uv[1].assign(1.f, 1.f); + + m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y); + m_uv[2].assign(0.f, 0.f); + + m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y); + m_uv[3].assign(1.f, 0.f); +} + +void CTextSupportShader::Shutdown() +{ + s_CharInsts.doDestroy(); + s_ImgInsts.doDestroy(); + s_Uniforms.doDestroy(); +} + +URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTextSupportShader) + +} diff --git a/Runtime/Graphics/Shaders/CTextSupportShader.hpp b/Runtime/Graphics/Shaders/CTextSupportShader.hpp new file mode 100644 index 000000000..26a612f41 --- /dev/null +++ b/Runtime/Graphics/Shaders/CTextSupportShader.hpp @@ -0,0 +1,103 @@ +#ifndef __URDE_CTEXTSUPPORTSHADER_HPP__ +#define __URDE_CTEXTSUPPORTSHADER_HPP__ + +#include "TMultiBlendShader.hpp" +#include "GuiSys/CGuiWidget.hpp" +#include "hecl/VertexBufferPool.hpp" +#include "hecl/UniformBufferPool.hpp" + +namespace urde +{ +class CGlyph; +class CTextRenderBuffer; + +class CTextSupportShader +{ + friend struct CTextSupportShaderGLDataBindingFactory; + friend struct CTextSupportShaderVulkanDataBindingFactory; + friend struct CTextSupportShaderMetalDataBindingFactory; + friend struct CTextSupportShaderD3DDataBindingFactory; + friend class CTextRenderBuffer; + + static boo::IVertexFormat* s_TextVtxFmt; + static boo::IShaderPipeline* s_TextAlphaPipeline; + static boo::IShaderPipeline* s_TextAddPipeline; + + static boo::IVertexFormat* s_ImageVtxFmt; + static boo::IShaderPipeline* s_ImageAlphaPipeline; + static boo::IShaderPipeline* s_ImageAddPipeline; + + struct Uniform + { + zeus::CMatrix4f m_mvp; + zeus::CColor m_uniformColor; + }; + + struct CharacterInstance + { + zeus::CVector3f m_pos[4]; + zeus::CVector3f m_uv[4]; + zeus::CColor m_fontColor; + zeus::CColor m_outlineColor; + void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset); + }; + + struct ImageInstance + { + zeus::CVector3f m_pos[4]; + zeus::CVector2f m_uv[4]; + zeus::CColor m_color; + void SetMetrics(const zeus::CVector2f& imgSize, const zeus::CVector2i& offset); + }; + + static hecl::VertexBufferPool s_CharInsts; + static hecl::VertexBufferPool s_ImgInsts; + static hecl::UniformBufferPool s_Uniforms; + +public: + using _CLS = CTextSupportShader; +#include "TMultiBlendShaderDecl.hpp" + + static boo::IShaderPipeline* SelectTextPipeline(CGuiWidget::EGuiModelDrawFlags df) + { + switch (df) + { + case CGuiWidget::EGuiModelDrawFlags::Shadeless: + case CGuiWidget::EGuiModelDrawFlags::Opaque: + case CGuiWidget::EGuiModelDrawFlags::Alpha: + return s_TextAlphaPipeline; + case CGuiWidget::EGuiModelDrawFlags::Additive: + case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw: + return s_TextAddPipeline; + default: + return nullptr; + } + } + + static boo::IShaderPipeline* SelectImagePipeline(CGuiWidget::EGuiModelDrawFlags df) + { + switch (df) + { + case CGuiWidget::EGuiModelDrawFlags::Shadeless: + case CGuiWidget::EGuiModelDrawFlags::Opaque: + case CGuiWidget::EGuiModelDrawFlags::Alpha: + return s_ImageAlphaPipeline; + case CGuiWidget::EGuiModelDrawFlags::Additive: + case CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw: + return s_ImageAddPipeline; + default: + return nullptr; + } + } + + static void UpdateBuffers() + { + s_CharInsts.updateBuffers(); + s_ImgInsts.updateBuffers(); + s_Uniforms.updateBuffers(); + } +}; + +} + +#endif // __URDE_CTEXTSUPPORTSHADER_HPP__ diff --git a/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp new file mode 100644 index 000000000..84bc22c53 --- /dev/null +++ b/Runtime/Graphics/Shaders/CTextSupportShaderGLSL.cpp @@ -0,0 +1,169 @@ +#include "CTextSupportShader.hpp" +#include "GuiSys/CTextRenderBuffer.hpp" +#include "TMultiBlendShader.hpp" +#include "Graphics/CTexture.hpp" + +namespace urde +{ + +static const char* TextVS = +"#version 330\n" +BOO_GLSL_BINDING_HEAD +"layout(location=0) in vec4 posIn[4];\n" +"layout(location=4) in vec4 uvIn[4];\n" +"layout(location=8) in vec4 fontColorIn;\n" +"layout(location=9) in vec4 outlineColorIn;\n" +"\n" +"UBINDING0 uniform TextSupportUniform\n" +"{\n" +" mat4 mtx;\n" +" vec4 color;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" vec4 fontColor;\n" +" vec4 outlineColor;\n" +" vec3 uv;\n" +"};\n" +"\n" +"SBINDING(0) out VertToFrag vtf;\n" +"void main()\n" +"{\n" +" vtf.fontColor = color * fontColorIn;\n" +" vtf.outlineColor = color * outlineColorIn;\n" +" vtf.uv = uvIn[gl_VertexID].xyz;\n" +" gl_Position = mtx * vec4(posIn[gl_VertexID].xyz, 1.0);\n" +" gl_Position = FLIPFROMGL(gl_Position);\n" +"}\n"; + +static const char* TextFS = +"#version 330\n" +BOO_GLSL_BINDING_HEAD +"struct VertToFrag\n" +"{\n" +" vec4 fontColor;\n" +" vec4 outlineColor;\n" +" vec3 uv;\n" +"};\n" +"\n" +"SBINDING(0) in VertToFrag vtf;\n" +"layout(location=0) out vec4 colorOut;\n" +"TBINDING0 uniform sampler2DArray tex;\n" +"void main()\n" +"{\n" +" vec4 texel = texture(tex, vtf.uv);\n" +" colorOut = vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n" +"}\n"; + +static const char* ImgVS = +"#version 330\n" +BOO_GLSL_BINDING_HEAD +"layout(location=0) in vec3 posIn[4];\n" +"layout(location=4) in vec2 uvIn[4];\n" +"layout(location=8) in vec4 colorIn;\n" +"\n" +"UBINDING0 uniform TextSupportUniform\n" +"{\n" +" mat4 mtx;\n" +" vec4 color;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" vec4 color;\n" +" vec2 uv;\n" +"};\n" +"\n" +"SBINDING(0) out VertToFrag vtf;\n" +"void main()\n" +"{\n" +" vtf.color = color * colorIn;\n" +" vtf.uv = uvIn[gl_VertexID];\n" +" gl_Position = mtx * vec4(posIn[gl_VertexID].xyz, 1.0);\n" +" gl_Position = FLIPFROMGL(gl_Position);\n" +"}\n"; + +static const char* ImgFS = +"#version 330\n" +BOO_GLSL_BINDING_HEAD +"struct VertToFrag\n" +"{\n" +" vec4 color;\n" +" vec2 uv;\n" +"};\n" +"\n" +"SBINDING(0) in VertToFrag vtf;\n" +"layout(location=0) out vec4 colorOut;\n" +"TBINDING0 uniform sampler2D tex;\n" +"void main()\n" +"{\n" +" vec4 texel = texture(tex, vtf.uv);\n" +" colorOut = vtf.color * texel;\n" +"}\n"; + +TMultiBlendShader::IDataBindingFactory* +CTextSupportShader::Initialize(boo::GLDataFactory::Context& ctx) +{ + const char* texNames[] = {"tex"}; + const char* uniNames[] = {"TextSupportUniform"}; + + s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + return nullptr; +} + +#if BOO_HAS_VULKAN +TMultiBlendShader::IDataBindingFactory* +CTextSupportShader::Initialize(boo::VulkanDataFactory::Context& ctx) +{ + boo::VertexElementDescriptor TextVtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + }; + s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt); + s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + boo::VertexElementDescriptor ImageVtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + }; + s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt); + s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + return nullptr; +} +#endif + +} diff --git a/Runtime/Graphics/Shaders/CXrayOutlineFilter.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp similarity index 100% rename from Runtime/Graphics/Shaders/CXrayOutlineFilter.cpp rename to Runtime/Graphics/Shaders/CTextSupportShaderHLSL.cpp diff --git a/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp b/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp new file mode 100644 index 000000000..34ea0d032 --- /dev/null +++ b/Runtime/Graphics/Shaders/CTextSupportShaderMetal.cpp @@ -0,0 +1,162 @@ +#include "CTextSupportShader.hpp" +#include "GuiSys/CTextRenderBuffer.hpp" +#include "TMultiBlendShader.hpp" +#include "Graphics/CTexture.hpp" + +namespace urde +{ + +static const char* TextVS = +"#include \n" +"using namespace metal;\n" +"struct InstData\n" +"{\n" +" float4 posIn[4];\n" +" float4 uvIn[4];\n" +" float4 fontColorIn;\n" +" float4 outlineColorIn;\n" +"};\n" +"\n" +"struct TextSupportUniform\n" +"{\n" +" float4x4 mtx;\n" +" float4 color;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" float4 pos [[ position ]];\n" +" float4 fontColor;\n" +" float4 outlineColor;\n" +" float3 uv;\n" +"};\n" +"\n" +"vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],\n" +" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n" +" constant TextSupportUniform& uData [[ buffer(2) ]])\n" +"{\n" +" VertToFrag vtf;\n" +" constant InstData& inst = instArr[instId];\n" +" vtf.fontColor = uData.color * inst.fontColorIn;\n" +" vtf.outlineColor = uData.color * inst.outlineColorIn;\n" +" vtf.uv = inst.uvIn[vertId].xyz;\n" +" vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);\n" +" return vtf;\n" +"}\n"; + +static const char* TextFS = +"#include \n" +"using namespace metal;\n" +"constexpr sampler samp(address::repeat);\n" +"struct VertToFrag\n" +"{\n" +" float4 pos [[ position ]];\n" +" float4 fontColor;\n" +" float4 outlineColor;\n" +" float3 uv;\n" +"};\n" +"\n" +"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n" +" texture2d_array tex [[ texture(0) ]])\n" +"{\n" +" float4 texel = tex.sample(samp, vtf.uv.xy, vtf.uv.z);\n" +" return vtf.fontColor * texel.r + vtf.outlineColor * texel.g;\n" +"}\n"; + +static const char* ImgVS = +"#include \n" +"using namespace metal;\n" +"struct InstData\n" +"{\n" +" float4 posIn[4];\n" +" float4 uvIn[4];\n" +" float4 colorIn;\n" +"};\n" +"\n" +"struct TextSupportUniform\n" +"{\n" +" float4x4 mtx;\n" +" float4 color;\n" +"};\n" +"\n" +"struct VertToFrag\n" +"{\n" +" float4 pos [[ position ]];\n" +" float4 color;\n" +" float2 uv;\n" +"};\n" +"\n" +"vertex VertToFrag vmain(constant InstData* instArr [[ buffer(1) ]],\n" +" uint vertId [[ vertex_id ]], uint instId [[ instance_id ]],\n" +" constant TextSupportUniform& uData [[ buffer(2) ]])\n" +"{\n" +" VertToFrag vtf;\n" +" constant InstData& inst = instArr[instId];\n" +" vtf.color = uData.color * inst.colorIn;\n" +" vtf.uv = inst.uvIn[vertId].xy;\n" +" vtf.pos = uData.mtx * float4(inst.posIn[vertId].xyz, 1.0);\n" +" return vtf;\n" +"}\n"; + +static const char* ImgFS = +"#include \n" +"using namespace metal;\n" +"constexpr sampler samp(address::repeat);\n" +"struct VertToFrag\n" +"{\n" +" float4 pos [[ position ]];\n" +" float4 color;\n" +" float2 uv;\n" +"};\n" +"\n" +"fragment float4 fmain(VertToFrag vtf [[ stage_in ]],\n" +" texture2d tex [[ texture(0) ]])\n" +"{\n" +" float4 texel = tex.sample(samp, vtf.uv);\n" +" return vtf.color * texel;\n" +"}\n"; + +TMultiBlendShader::IDataBindingFactory* +CTextSupportShader::Initialize(boo::MetalDataFactory::Context& ctx) +{ + boo::VertexElementDescriptor TextVtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + }; + s_TextVtxFmt = ctx.newVertexFormat(10, TextVtxVmt); + s_TextAlphaPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_TextAddPipeline = ctx.newShaderPipeline(TextVS, TextFS, s_TextVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + boo::VertexElementDescriptor ImageVtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {nullptr, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {nullptr, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + }; + s_ImageVtxFmt = ctx.newVertexFormat(9, ImageVtxVmt); + s_ImageAlphaPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_ImageAddPipeline = ctx.newShaderPipeline(ImgVS, ImgFS, s_ImageVtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + + return nullptr; +} + +} diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp index d98847811..878454979 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp @@ -77,6 +77,8 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f}; +void CTexturedQuadFilter::Shutdown() {} + URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex) @@ -98,6 +100,8 @@ CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterTyp m_tex = tex; } +void CTexturedQuadFilterAlpha::Shutdown() {} + URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha) } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index 3c8b44856..3a3bfd9fd 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -97,11 +97,48 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) +static boo::IShaderPipeline* s_AlphaPipeline = nullptr; +static boo::IShaderPipeline* s_AddPipeline = nullptr; +static boo::IShaderPipeline* s_MultPipeline = nullptr; + +static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type) +{ + switch (type) + { + case CCameraFilterPass::EFilterType::Blend: + return s_AlphaPipeline; + case CCameraFilterPass::EFilterType::Add: + return s_AddPipeline; + case CCameraFilterPass::EFilterType::Multiply: + return s_MultPipeline; + default: + return nullptr; + } +} + +static boo::IShaderPipeline* s_AAlphaPipeline = nullptr; +static boo::IShaderPipeline* s_AAddPipeline = nullptr; +static boo::IShaderPipeline* s_AMultPipeline = nullptr; + +static boo::IShaderPipeline* SelectAlphaPipeline(CCameraFilterPass::EFilterType type) +{ + switch (type) + { + case CCameraFilterPass::EFilterType::Blend: + return s_AAlphaPipeline; + case CCameraFilterPass::EFilterType::Add: + return s_AAddPipeline; + case CCameraFilterPass::EFilterType::Multiply: + return s_AMultPipeline; + default: + return nullptr; + } +} + struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, + CCameraFilterPass::EFilterType type, CTexturedQuadFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -114,7 +151,7 @@ struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, + CCameraFilterPass::EFilterType type, CTexturedQuadFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectPipeline(type), vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } @@ -140,29 +176,22 @@ struct CTexturedQuadFilterVulkanDataBindingFactory : TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut) +CTexturedQuadFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"tex"}; const char* uniNames[] = {"TexuredQuadUniform"}; - alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -170,12 +199,12 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx, {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterVulkanDataBindingFactory; } #endif @@ -185,8 +214,7 @@ URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha) struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, + CCameraFilterPass::EFilterType type, CTexturedQuadFilterAlpha& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -199,7 +227,7 @@ struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, + CCameraFilterPass::EFilterType type, CTexturedQuadFilterAlpha& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectAlphaPipeline(type), vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } @@ -225,29 +252,22 @@ struct CTexturedQuadFilterAlphaVulkanDataBindingFactory : TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut) +CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"tex"}; const char* uniNames[] = {"TexuredQuadUniform"}; - alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterAlphaGLDataBindingFactory; } #if BOO_HAS_VULKAN TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -255,12 +275,12 @@ CTexturedQuadFilterAlpha::Initialize(boo::VulkanDataFactory::Context& ctx, {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_AAlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AAddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_AMultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterAlphaVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp index 9b292a41f..ec9f61755 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp @@ -103,81 +103,91 @@ static const char* FSAlpha = URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_AlphaPipeline = nullptr; +static boo::IShaderPipeline* s_AddPipeline = nullptr; +static boo::IShaderPipeline* s_MultPipeline = nullptr; + +static boo::IShaderPipeline* SelectPipeline(CCameraFilterPass::EFilterType type) +{ + switch (type) + { + case CCameraFilterPass::EFilterType::Blend: + return s_AlphaPipeline; + case CCameraFilterPass::EFilterType::Add: + return s_AddPipeline; + case CCameraFilterPass::EFilterType::Multiply: + return s_MultPipeline; + default: + return nullptr; + } +} + struct CTexturedQuadFilterMetalDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, + CCameraFilterPass::EFilterType type, CTexturedQuadFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } }; TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CTexturedQuadFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSNoFlip, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_AlphaPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VSNoFlip, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterMetalDataBindingFactory; } struct CTexturedQuadFilterAlphaMetalDataBindingFactory : TMultiBlendShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, + CCameraFilterPass::EFilterType type, CTexturedQuadFilterAlpha& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(SelectPipeline(type), s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 1, texs); } }; TMultiBlendShader::IDataBindingFactory* -CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut) +CTexturedQuadFilterAlpha::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - alphaPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); - additivePipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, - boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); - colorMultiplyPipeOut = ctx.newShaderPipeline(VSFlip, FSAlpha, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, - boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_AlphaPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + s_AddPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + s_MultPipeline = ctx.newShaderPipeline(VSFlip, FSAlpha, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); return new CTexturedQuadFilterAlphaMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp index 605dd77dd..14123a04f 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilter.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilter.cpp @@ -66,6 +66,8 @@ void CThermalColdFilter::draw() CGraphics::g_BooMainCommandQueue->draw(0, 4); } +void CThermalColdFilter::Shutdown() {} + URDE_SPECIALIZE_SHADER(CThermalColdFilter) } diff --git a/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp b/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp index 3cfb5d155..31f08470c 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilterGLSL.cpp @@ -75,11 +75,11 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter) +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CThermalColdFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, CThermalColdFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -92,7 +92,7 @@ struct CThermalColdFilterGLDataBindingFactory : TShader::IDa boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; - return cctx.newShaderDataBinding(pipeline, + return cctx.newShaderDataBinding(s_Pipeline, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 2, texs); } @@ -102,35 +102,30 @@ struct CThermalColdFilterGLDataBindingFactory : TShader::IDa struct CThermalColdFilterVulkanDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CThermalColdFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, vtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; #endif -TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"sceneTex", "shiftTex"}; const char* uniNames[] = {"ThermalColdUniform"}; - pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CThermalColdFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { @@ -138,8 +133,8 @@ TShader::IDataBindingFactory* CThermalColdFilter::Initialize {nullptr, nullptr, boo::VertexSemantic::UV4} }; vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CThermalColdFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CThermalColdFilterMetal.cpp b/Runtime/Graphics/Shaders/CThermalColdFilterMetal.cpp index 0a61207df..458036246 100644 --- a/Runtime/Graphics/Shaders/CThermalColdFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CThermalColdFilterMetal.cpp @@ -85,35 +85,34 @@ static const char* FS = URDE_DECL_SPECIALIZE_SHADER(CThermalColdFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CThermalColdFilterMetalDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CThermalColdFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_shiftTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; -TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CThermalColdFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CThermalColdFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CThermalHotFilter.cpp b/Runtime/Graphics/Shaders/CThermalHotFilter.cpp index ea9afe093..2a736a0ef 100644 --- a/Runtime/Graphics/Shaders/CThermalHotFilter.cpp +++ b/Runtime/Graphics/Shaders/CThermalHotFilter.cpp @@ -36,6 +36,8 @@ void CThermalHotFilter::draw() CGraphics::g_BooMainCommandQueue->draw(0, 4); } +void CThermalHotFilter::Shutdown() {} + URDE_SPECIALIZE_SHADER(CThermalHotFilter) } diff --git a/Runtime/Graphics/Shaders/CThermalHotFilterGLSL.cpp b/Runtime/Graphics/Shaders/CThermalHotFilterGLSL.cpp index f61479b9b..a41435171 100644 --- a/Runtime/Graphics/Shaders/CThermalHotFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CThermalHotFilterGLSL.cpp @@ -52,11 +52,12 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CThermalHotFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, CThermalHotFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -69,7 +70,7 @@ struct CThermalHotFilterGLDataBindingFactory : TShader::IData boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()}; - return cctx.newShaderDataBinding(pipeline, + return cctx.newShaderDataBinding(s_Pipeline, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 2, texs); } @@ -79,44 +80,39 @@ struct CThermalHotFilterGLDataBindingFactory : TShader::IData struct CThermalHotFilterVulkanDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CThermalHotFilter& filter) { boo::VulkanDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; #endif -TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"sceneTex", "paletteTex"}; const char* uniNames[] = {"ThermalHotUniform"}; - pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::DstAlpha, - boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::DstAlpha, + boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false); return new CThermalHotFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::DstAlpha, - boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::DstAlpha, + boo::BlendFactor::InvDstAlpha, boo::Primitive::TriStrips, false, false, false); return new CThermalHotFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CThermalHotFilterMetal.cpp b/Runtime/Graphics/Shaders/CThermalHotFilterMetal.cpp index 446d73ebb..5de44faf0 100644 --- a/Runtime/Graphics/Shaders/CThermalHotFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CThermalHotFilterMetal.cpp @@ -58,36 +58,35 @@ static const char* FS = URDE_DECL_SPECIALIZE_SHADER(CThermalHotFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CThermalHotFilterMetalDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CThermalHotFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, g_Renderer->GetThermoPalette()}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; -TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CThermalHotFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, - boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha, - boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, + boo::BlendFactor::DstAlpha, boo::BlendFactor::InvDstAlpha, + boo::Primitive::TriStrips, false, false, false); return new CThermalHotFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp index 06e7fa869..41bb71883 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilter.cpp @@ -54,6 +54,8 @@ void CXRayBlurFilter::draw(float amount) CGraphics::g_BooMainCommandQueue->draw(0, 4); } +void CXRayBlurFilter::Shutdown() {} + URDE_SPECIALIZE_SHADER(CXRayBlurFilter) } diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilterGLSL.cpp b/Runtime/Graphics/Shaders/CXRayBlurFilterGLSL.cpp index 76789db5c..72ad56c24 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilterGLSL.cpp @@ -64,11 +64,12 @@ BOO_GLSL_BINDING_HEAD URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CXRayBlurFilterGLDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat*, CXRayBlurFilter& filter) { boo::GLDataFactory::Context& cctx = static_cast(ctx); @@ -81,7 +82,7 @@ struct CXRayBlurFilterGLDataBindingFactory : TShader::IDataBind boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, + return cctx.newShaderDataBinding(s_Pipeline, ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, 1, bufs, stages, nullptr, nullptr, 2, texs); } @@ -99,36 +100,33 @@ struct CXRayBlurFilterVulkanDataBindingFactory : TShader::IData boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; #endif -TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut) +TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::GLDataFactory::Context& ctx) { const char* texNames[] = {"sceneTex", "paletteTex"}; const char* uniNames[] = {"XRayBlurUniform"}; - pipeOut = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_Pipeline = ctx.newShaderPipeline(VS, FS, 2, texNames, 1, uniNames, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CXRayBlurFilterGLDataBindingFactory; } #if BOO_HAS_VULKAN -TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::VulkanDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CXRayBlurFilterVulkanDataBindingFactory; } #endif diff --git a/Runtime/Graphics/Shaders/CXRayBlurFilterMetal.cpp b/Runtime/Graphics/Shaders/CXRayBlurFilterMetal.cpp index 3cf25f73b..764fa86aa 100644 --- a/Runtime/Graphics/Shaders/CXRayBlurFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CXRayBlurFilterMetal.cpp @@ -73,35 +73,34 @@ static const char* FS = URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter) +static boo::IVertexFormat* s_VtxFmt = nullptr; +static boo::IShaderPipeline* s_Pipeline = nullptr; + struct CXRayBlurFilterMetalDataBindingFactory : TShader::IDataBindingFactory { boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, CXRayBlurFilter& filter) { boo::MetalDataFactory::Context& cctx = static_cast(ctx); boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; boo::ITexture* texs[] = {CGraphics::g_SpareTexture, filter.m_booTex}; - return cctx.newShaderDataBinding(pipeline, vtxFmt, + return cctx.newShaderDataBinding(s_Pipeline, s_VtxFmt, filter.m_vbo, nullptr, nullptr, 1, bufs, nullptr, nullptr, nullptr, 2, texs); } }; -TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut) +TShader::IDataBindingFactory* CXRayBlurFilter::Initialize(boo::MetalDataFactory::Context& ctx) { const boo::VertexElementDescriptor VtxVmt[] = { {nullptr, nullptr, boo::VertexSemantic::Position4}, {nullptr, nullptr, boo::VertexSemantic::UV4} }; - vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); - pipeOut = ctx.newShaderPipeline(VS, FS, vtxFmtOut, CGraphics::g_ViewportSamples, boo::BlendFactor::One, - boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); + s_VtxFmt = ctx.newVertexFormat(2, VtxVmt); + s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, CGraphics::g_ViewportSamples, boo::BlendFactor::One, + boo::BlendFactor::Zero, boo::Primitive::TriStrips, false, false, false); return new CXRayBlurFilterMetalDataBindingFactory; } diff --git a/Runtime/Graphics/Shaders/CXrayOutlineFilter.hpp b/Runtime/Graphics/Shaders/CXrayOutlineFilter.hpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Runtime/Graphics/Shaders/CXrayOutlineFilterGLSL.cpp b/Runtime/Graphics/Shaders/CXrayOutlineFilterGLSL.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Runtime/Graphics/Shaders/CXrayOutlineFilterHLSL.cpp b/Runtime/Graphics/Shaders/CXrayOutlineFilterHLSL.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Runtime/Graphics/Shaders/CXrayOutlineFilterMetal.cpp b/Runtime/Graphics/Shaders/CXrayOutlineFilterMetal.cpp deleted file mode 100644 index e69de29bb..000000000 diff --git a/Runtime/Graphics/Shaders/TMultiBlendShader.hpp b/Runtime/Graphics/Shaders/TMultiBlendShader.hpp index 85dcf6a83..44fe431a9 100644 --- a/Runtime/Graphics/Shaders/TMultiBlendShader.hpp +++ b/Runtime/Graphics/Shaders/TMultiBlendShader.hpp @@ -11,23 +11,17 @@ namespace urde { -template +template class TMultiBlendShader { public: struct IDataBindingFactory { virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, - FilterImp& filter)=0; + CCameraFilterPass::EFilterType type, + ShaderImp& filter)=0; }; - static boo::IShaderPipeline* m_alphaBlendPipeline; - static boo::IShaderPipeline* m_additiveAlphaPipeline; - static boo::IShaderPipeline* m_colorMultiplyPipeline; - static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */ - static std::unique_ptr m_bindFactory; static boo::GraphicsDataToken m_gfxToken; @@ -42,29 +36,22 @@ public: switch (ctx.platform()) { case boo::IGraphicsDataFactory::Platform::OpenGL: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_alphaBlendPipeline, m_additiveAlphaPipeline, m_colorMultiplyPipeline)); + m_bindFactory.reset(ShaderImp::Initialize(static_cast(ctx))); break; #if _WIN32 case boo::IGraphicsDataFactory::Platform::D3D11: case boo::IGraphicsDataFactory::Platform::D3D12: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_alphaBlendPipeline, m_additiveAlphaPipeline, - m_colorMultiplyPipeline, m_vtxFmt)); + m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_METAL case boo::IGraphicsDataFactory::Platform::Metal: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_alphaBlendPipeline, m_additiveAlphaPipeline, - m_colorMultiplyPipeline, m_vtxFmt)); + m_bindFactory.reset(ShaderImp::Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_VULKAN case boo::IGraphicsDataFactory::Platform::Vulkan: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_alphaBlendPipeline, m_additiveAlphaPipeline, - m_colorMultiplyPipeline, m_vtxFmt)); + m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx))); break; #endif default: break; @@ -75,47 +62,25 @@ public: static void Shutdown() { + ShaderImp::Shutdown(); m_gfxToken.doDestroy(); } static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CCameraFilterPass::EFilterType type, - FilterImp& filter) + ShaderImp& filter) { - if (type == CCameraFilterPass::EFilterType::Add) - return m_bindFactory->BuildShaderDataBinding(ctx, m_additiveAlphaPipeline, m_vtxFmt, filter); - else if (type == CCameraFilterPass::EFilterType::Multiply) - return m_bindFactory->BuildShaderDataBinding(ctx, m_colorMultiplyPipeline, m_vtxFmt, filter); - else - return m_bindFactory->BuildShaderDataBinding(ctx, m_alphaBlendPipeline, m_vtxFmt, filter); + return m_bindFactory->BuildShaderDataBinding(ctx, type, filter); } }; #define URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(cls) \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_alphaBlendPipeline; \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_additiveAlphaPipeline; \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_colorMultiplyPipeline; \ -template <> boo::IVertexFormat* \ -TMultiBlendShader::m_vtxFmt; \ -\ template <> std::unique_ptr::IDataBindingFactory> \ TMultiBlendShader::m_bindFactory; \ template <> boo::GraphicsDataToken \ TMultiBlendShader::m_gfxToken; \ #define URDE_SPECIALIZE_MULTI_BLEND_SHADER(cls) \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_alphaBlendPipeline = nullptr; \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_additiveAlphaPipeline = nullptr; \ -template <> boo::IShaderPipeline* \ -TMultiBlendShader::m_colorMultiplyPipeline = nullptr; \ -template <> boo::IVertexFormat* \ -TMultiBlendShader::m_vtxFmt = nullptr; \ -\ template <> std::unique_ptr::IDataBindingFactory> \ TMultiBlendShader::m_bindFactory = {}; \ template <> boo::GraphicsDataToken \ diff --git a/Runtime/Graphics/Shaders/TMultiBlendShaderDecl.hpp b/Runtime/Graphics/Shaders/TMultiBlendShaderDecl.hpp index 37c0676fe..9731b325a 100644 --- a/Runtime/Graphics/Shaders/TMultiBlendShaderDecl.hpp +++ b/Runtime/Graphics/Shaders/TMultiBlendShaderDecl.hpp @@ -1,25 +1,11 @@ -static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut); +static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx); #if _WIN32 -static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx); #endif #if BOO_HAS_METAL -static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx); #endif #if BOO_HAS_VULKAN -static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& alphaPipeOut, - boo::IShaderPipeline*& additivePipeOut, - boo::IShaderPipeline*& colorMultiplyPipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TMultiBlendShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx); #endif +static void Shutdown(); diff --git a/Runtime/Graphics/Shaders/TShader.hpp b/Runtime/Graphics/Shaders/TShader.hpp index 24389fe8d..e36df3111 100644 --- a/Runtime/Graphics/Shaders/TShader.hpp +++ b/Runtime/Graphics/Shaders/TShader.hpp @@ -10,21 +10,16 @@ namespace urde { -template +template class TShader { public: struct IDataBindingFactory { virtual boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, - boo::IShaderPipeline* pipeline, - boo::IVertexFormat* vtxFmt, - FilterImp& filter)=0; + ShaderImp& filter)=0; }; - static boo::IShaderPipeline* m_pipeline; - static boo::IVertexFormat* m_vtxFmt; /* No OpenGL */ - static std::unique_ptr m_bindFactory; static boo::GraphicsDataToken m_gfxToken; @@ -39,26 +34,22 @@ public: switch (ctx.platform()) { case boo::IGraphicsDataFactory::Platform::OpenGL: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_pipeline)); + m_bindFactory.reset(ShaderImp::Initialize(static_cast(ctx))); break; #if _WIN32 case boo::IGraphicsDataFactory::Platform::D3D11: case boo::IGraphicsDataFactory::Platform::D3D12: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_pipeline, m_vtxFmt)); + m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_METAL case boo::IGraphicsDataFactory::Platform::Metal: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_pipeline, m_vtxFmt)); + m_bindFactory.reset(ShaderImp::Initialize(static_cast(ctx))); break; #endif #if BOO_HAS_VULKAN case boo::IGraphicsDataFactory::Platform::Vulkan: - m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx), - m_pipeline, m_vtxFmt)); + m_bindFactory.reset(FilterImp::Initialize(static_cast(ctx))); break; #endif default: break; @@ -69,32 +60,23 @@ public: static void Shutdown() { + ShaderImp::Shutdown(); m_gfxToken.doDestroy(); } - static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, FilterImp& filter) + static boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, ShaderImp& filter) { - return m_bindFactory->BuildShaderDataBinding(ctx, m_pipeline, m_vtxFmt, filter); + return m_bindFactory->BuildShaderDataBinding(ctx, filter); } }; #define URDE_DECL_SPECIALIZE_SHADER(cls) \ -template <> boo::IShaderPipeline* \ -TShader::m_pipeline; \ -template <> boo::IVertexFormat* \ -TShader::m_vtxFmt; \ -\ template <> std::unique_ptr::IDataBindingFactory> \ TShader::m_bindFactory; \ template <> boo::GraphicsDataToken \ TShader::m_gfxToken; \ #define URDE_SPECIALIZE_SHADER(cls) \ -template <> boo::IShaderPipeline* \ -TShader::m_pipeline = nullptr; \ -template <> boo::IVertexFormat* \ -TShader::m_vtxFmt = nullptr; \ -\ template <> std::unique_ptr::IDataBindingFactory> \ TShader::m_bindFactory = {}; \ template <> boo::GraphicsDataToken \ diff --git a/Runtime/Graphics/Shaders/TShaderDecl.hpp b/Runtime/Graphics/Shaders/TShaderDecl.hpp index 4e83c3730..cc7c128e8 100644 --- a/Runtime/Graphics/Shaders/TShaderDecl.hpp +++ b/Runtime/Graphics/Shaders/TShaderDecl.hpp @@ -1,17 +1,11 @@ - static TShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut); +static TShader<_CLS>::IDataBindingFactory* Initialize(boo::GLDataFactory::Context& ctx); #if _WIN32 - static TShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TShader<_CLS>::IDataBindingFactory* Initialize(boo::ID3DDataFactory::Context& ctx); #endif #if BOO_HAS_METAL - static TShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TShader<_CLS>::IDataBindingFactory* Initialize(boo::MetalDataFactory::Context& ctx); #endif #if BOO_HAS_VULKAN - static TShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx, - boo::IShaderPipeline*& pipeOut, - boo::IVertexFormat*& vtxFmtOut); +static TShader<_CLS>::IDataBindingFactory* Initialize(boo::VulkanDataFactory::Context& ctx); #endif +static void Shutdown(); diff --git a/Runtime/GuiSys/CAuiEnergyBarT01.hpp b/Runtime/GuiSys/CAuiEnergyBarT01.hpp index 628e0f730..272e04fe9 100644 --- a/Runtime/GuiSys/CAuiEnergyBarT01.hpp +++ b/Runtime/GuiSys/CAuiEnergyBarT01.hpp @@ -11,6 +11,7 @@ class CAuiEnergyBarT01 : public CGuiWidget { public: CAuiEnergyBarT01(const CGuiWidgetParms& parms, u32); + FourCC GetWidgetTypeID() const { return FOURCC('ENRG'); } static std::shared_ptr Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); }; diff --git a/Runtime/GuiSys/CAuiImagePane.hpp b/Runtime/GuiSys/CAuiImagePane.hpp index e672acbcb..50fd74952 100644 --- a/Runtime/GuiSys/CAuiImagePane.hpp +++ b/Runtime/GuiSys/CAuiImagePane.hpp @@ -13,6 +13,7 @@ public: CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId, rstl::reserved_vector&& coords, rstl::reserved_vector&& uvs, bool); + FourCC GetWidgetTypeID() const { return FOURCC('IMGP'); } static std::shared_ptr Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); }; } diff --git a/Runtime/GuiSys/CAuiMeter.hpp b/Runtime/GuiSys/CAuiMeter.hpp index 86b7cb908..89a461303 100644 --- a/Runtime/GuiSys/CAuiMeter.hpp +++ b/Runtime/GuiSys/CAuiMeter.hpp @@ -19,7 +19,7 @@ class CAuiMeter : public CGuiGroup public: CAuiMeter(const CGuiWidgetParms& parms, bool noRoundUp, u32 maxCapacity, u32 workerCount); - FourCC GetWidgetTypeID() const {return FOURCC('METR');} + FourCC GetWidgetTypeID() const { return FOURCC('METR'); } void OnVisibleChange(); void SetCurrValue(s32 val); diff --git a/Runtime/GuiSys/CFontImageDef.cpp b/Runtime/GuiSys/CFontImageDef.cpp index 32e5008db..99bbc47c8 100644 --- a/Runtime/GuiSys/CFontImageDef.cpp +++ b/Runtime/GuiSys/CFontImageDef.cpp @@ -3,18 +3,19 @@ namespace urde { -CFontImageDef::CFontImageDef(std::vector>&& texs, +CFontImageDef::CFontImageDef(const std::vector>& texs, float interval, const zeus::CVector2f& vec) -: x0_fps(interval), x4_texs(std::move(texs)), x14_pointsPerTexel(vec) +: x0_fps(interval), x14_pointsPerTexel(vec) { - for (TToken& tok : x4_texs) - tok.Lock(); + x4_texs.reserve(texs.size()); + for (const TToken& tok : texs) + x4_texs.push_back(tok); } -CFontImageDef::CFontImageDef(TToken&& tex, const zeus::CVector2f& vec) -: x0_fps(0.f), x4_texs({std::move(tex)}), x14_pointsPerTexel(vec) +CFontImageDef::CFontImageDef(const TToken& tex, const zeus::CVector2f& vec) +: x0_fps(0.f), x14_pointsPerTexel(vec) { - x4_texs[0].Lock(); + x4_texs.push_back(tex); } bool CFontImageDef::IsLoaded() const diff --git a/Runtime/GuiSys/CFontImageDef.hpp b/Runtime/GuiSys/CFontImageDef.hpp index b84227f8c..9186a81e9 100644 --- a/Runtime/GuiSys/CFontImageDef.hpp +++ b/Runtime/GuiSys/CFontImageDef.hpp @@ -13,12 +13,12 @@ class CFontImageDef { public: float x0_fps; - std::vector> x4_texs; + std::vector> x4_texs; zeus::CVector2f x14_pointsPerTexel; - CFontImageDef(std::vector>&& texs, float fps, + CFontImageDef(const std::vector>& texs, float fps, const zeus::CVector2f& vec); - CFontImageDef(TToken&& tex, const zeus::CVector2f& vec); + CFontImageDef(const TToken& tex, const zeus::CVector2f& vec); bool IsLoaded() const; }; diff --git a/Runtime/GuiSys/CGuiCamera.cpp b/Runtime/GuiSys/CGuiCamera.cpp index 13b159010..c12626db0 100644 --- a/Runtime/GuiSys/CGuiCamera.cpp +++ b/Runtime/GuiSys/CGuiCamera.cpp @@ -10,7 +10,7 @@ CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms, float left, float right, float top, float bottom, float znear, float zfar) -: CGuiWidget(parms), +: CGuiWidget(parms), xf8_proj(EProjection::Orthographic), xfc_left(left), x100_right(right), x104_top(top), x108_bottom(bottom), x10c_znear(znear), x110_zfar(zfar) @@ -19,7 +19,7 @@ CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms, CGuiCamera::CGuiCamera(const CGuiWidgetParms& parms, float fov, float aspect, float znear, float zfar) -: CGuiWidget(parms), +: CGuiWidget(parms), xf8_proj(EProjection::Perspective), xfc_fov(fov), x100_aspect(aspect), x104_znear(znear), x108_zfar(zfar) {} diff --git a/Runtime/GuiSys/CGuiCamera.hpp b/Runtime/GuiSys/CGuiCamera.hpp index 5d57c8195..3e263b33a 100644 --- a/Runtime/GuiSys/CGuiCamera.hpp +++ b/Runtime/GuiSys/CGuiCamera.hpp @@ -41,6 +41,8 @@ public: float top, float bottom, float znear, float zfar); CGuiCamera(const CGuiWidgetParms& parms, float fov, float aspect, float znear, float zfar); + FourCC GetWidgetTypeID() const { return FOURCC('CAMR'); } + static std::shared_ptr Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& vec) const; diff --git a/Runtime/GuiSys/CGuiCompoundWidget.cpp b/Runtime/GuiSys/CGuiCompoundWidget.cpp index 991621e58..155858deb 100644 --- a/Runtime/GuiSys/CGuiCompoundWidget.cpp +++ b/Runtime/GuiSys/CGuiCompoundWidget.cpp @@ -13,7 +13,7 @@ void CGuiCompoundWidget::OnVisibleChange() CGuiWidget* child = static_cast(GetChildObject()); while (child) { - child->SetIsVisible(true); + child->SetIsVisible(GetIsVisible()); child = static_cast(child->GetNextSibling()); } CGuiWidget::OnVisibleChange(); @@ -24,7 +24,7 @@ void CGuiCompoundWidget::OnActiveChange() CGuiWidget* child = static_cast(GetChildObject()); while (child) { - child->SetIsActive(true); + child->SetIsActive(GetIsActive()); child = static_cast(child->GetNextSibling()); } CGuiWidget::OnActiveChange(); diff --git a/Runtime/GuiSys/CGuiFrame.cpp b/Runtime/GuiSys/CGuiFrame.cpp index bb071b15f..421dde89b 100644 --- a/Runtime/GuiSys/CGuiFrame.cpp +++ b/Runtime/GuiSys/CGuiFrame.cpp @@ -110,20 +110,18 @@ void CGuiFrame::Update(float dt) void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const { - if (x4_) - { - CGraphics::SetCullMode(ERglCullMode::None); - CGraphics::SetAmbientColor(zeus::CColor::skWhite); - DisableLights(); - x14_camera->Draw(parms); - // Set one-stage modulate - CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, - ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); + CGraphics::SetCullMode(ERglCullMode::None); + CGraphics::SetAmbientColor(zeus::CColor::skWhite); + DisableLights(); + x14_camera->Draw(parms); + // Set one-stage modulate + CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha, + ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear); + + for (const auto& widget : x2c_widgets) + if (widget->GetIsVisible()) + widget->Draw(parms); - for (const auto& widget : x2c_widgets) - if (widget->GetIsVisible()) - widget->Draw(parms); - } CGraphics::SetCullMode(ERglCullMode::Front); } @@ -160,7 +158,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp) void CGuiFrame::ProcessUserInput(const CFinalInput& input) const { - if (x4_) + if (input.ControllerIdx() != 0) return; for (auto& widget : x2c_widgets) { diff --git a/Runtime/GuiSys/CGuiFrame.hpp b/Runtime/GuiSys/CGuiFrame.hpp index 951c0ec3f..3fc66e458 100644 --- a/Runtime/GuiSys/CGuiFrame.hpp +++ b/Runtime/GuiSys/CGuiFrame.hpp @@ -2,6 +2,7 @@ #define __URDE_CGUIFRAME_HPP__ #include "CGuiWidget.hpp" +#include "CGuiHeadWidget.hpp" #include "CGuiWidgetIdDB.hpp" #include "IObj.hpp" @@ -10,7 +11,6 @@ namespace urde class CGuiSys; class CLight; class CGuiCamera; -class CGuiHeadWidget; class CFinalInput; class CGuiLight; class CVParamTransfer; @@ -44,6 +44,7 @@ public: CGuiWidget* FindWidget(s16 id) const; void SetFrameCamera(std::shared_ptr&& camr) { x14_camera = std::move(camr); } void SetHeadWidget(std::shared_ptr&& hwig) { xc_headWidget = std::move(hwig); } + CGuiHeadWidget* GetHeadWidget() const { return xc_headWidget.get(); } void SortDrawOrder(); void EnableLights(u32 lights) const; void DisableLights() const; diff --git a/Runtime/GuiSys/CGuiGroup.hpp b/Runtime/GuiSys/CGuiGroup.hpp index ed22b0d79..c4ad6a285 100644 --- a/Runtime/GuiSys/CGuiGroup.hpp +++ b/Runtime/GuiSys/CGuiGroup.hpp @@ -13,7 +13,7 @@ class CGuiGroup : public CGuiCompoundWidget bool xc0_b; public: CGuiGroup(const CGuiWidgetParms& parms, int defaultWorker, bool b); - FourCC GetWidgetTypeID() const {return FOURCC('GRUP');} + FourCC GetWidgetTypeID() const { return FOURCC('GRUP'); } void SelectWorkerWidget(int workerId, bool setActive, bool setVisible); CGuiWidget* GetSelectedWidget(); diff --git a/Runtime/GuiSys/CGuiHeadWidget.hpp b/Runtime/GuiSys/CGuiHeadWidget.hpp index 7178710b2..a92d73931 100644 --- a/Runtime/GuiSys/CGuiHeadWidget.hpp +++ b/Runtime/GuiSys/CGuiHeadWidget.hpp @@ -9,7 +9,7 @@ namespace urde class CGuiHeadWidget : public CGuiWidget { public: - FourCC GetWidgetTypeID() const {return FOURCC('HWIG');} + FourCC GetWidgetTypeID() const { return FOURCC('HWIG'); } CGuiHeadWidget(const CGuiWidgetParms& parms); static std::shared_ptr Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp); diff --git a/Runtime/GuiSys/CGuiLight.hpp b/Runtime/GuiSys/CGuiLight.hpp index d957fa3aa..6938b979b 100644 --- a/Runtime/GuiSys/CGuiLight.hpp +++ b/Runtime/GuiSys/CGuiLight.hpp @@ -23,7 +23,7 @@ class CGuiLight : public CGuiWidget public: ~CGuiLight(); CGuiLight(const CGuiWidgetParms& parms, const CLight& light); - FourCC GetWidgetTypeID() const {return FOURCC('LITE');} + FourCC GetWidgetTypeID() const { return FOURCC('LITE'); } CLight BuildLight() const; void SetIsVisible(bool vis); diff --git a/Runtime/GuiSys/CGuiModel.hpp b/Runtime/GuiSys/CGuiModel.hpp index 2bd280220..24aa44559 100644 --- a/Runtime/GuiSys/CGuiModel.hpp +++ b/Runtime/GuiSys/CGuiModel.hpp @@ -16,7 +16,7 @@ class CGuiModel : public CGuiWidget u32 x10c_lightMask; public: CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag); - FourCC GetWidgetTypeID() const {return FOURCC('MODL');} + FourCC GetWidgetTypeID() const { return FOURCC('MODL'); } std::vector GetModelAssets() const; bool GetIsFinishedLoadingWidgetSpecific() const; diff --git a/Runtime/GuiSys/CGuiPane.hpp b/Runtime/GuiSys/CGuiPane.hpp index b3763d930..28cf658ff 100644 --- a/Runtime/GuiSys/CGuiPane.hpp +++ b/Runtime/GuiSys/CGuiPane.hpp @@ -20,7 +20,7 @@ protected: public: CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter); - FourCC GetWidgetTypeID() const {return FOURCC('PANE');} + FourCC GetWidgetTypeID() const { return FOURCC('PANE'); } virtual void ScaleDimensions(const zeus::CVector3f& scale); virtual void SetDimensions(const zeus::CVector2f& dim, bool initVBO); diff --git a/Runtime/GuiSys/CGuiSliderGroup.hpp b/Runtime/GuiSys/CGuiSliderGroup.hpp index 86a5cb8ca..035821aa6 100644 --- a/Runtime/GuiSys/CGuiSliderGroup.hpp +++ b/Runtime/GuiSys/CGuiSliderGroup.hpp @@ -40,7 +40,7 @@ private: public: CGuiSliderGroup(const CGuiWidgetParms& parms, float a, float b, float c, float d); - FourCC GetWidgetTypeID() const {return FOURCC('SLGP');} + FourCC GetWidgetTypeID() const { return FOURCC('SLGP'); } EState GetState() const { return xf0_state; } void SetSelectionChangedCallback(std::function&& func); diff --git a/Runtime/GuiSys/CGuiTableGroup.hpp b/Runtime/GuiSys/CGuiTableGroup.hpp index 2f847e8fe..ba309e5da 100644 --- a/Runtime/GuiSys/CGuiTableGroup.hpp +++ b/Runtime/GuiSys/CGuiTableGroup.hpp @@ -55,7 +55,7 @@ private: public: CGuiTableGroup(const CGuiWidgetParms& parms, int, int, bool); - FourCC GetWidgetTypeID() const {return FOURCC('TBGP');} + FourCC GetWidgetTypeID() const { return FOURCC('TBGP'); } void SetMenuAdvanceCallback(std::function&& cb) { diff --git a/Runtime/GuiSys/CGuiTextPane.cpp b/Runtime/GuiSys/CGuiTextPane.cpp index 2cbbc01ba..4f0b639cf 100644 --- a/Runtime/GuiSys/CGuiTextPane.cpp +++ b/Runtime/GuiSys/CGuiTextPane.cpp @@ -14,7 +14,7 @@ CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const const zeus::CColor& fontCol, const zeus::CColor& outlineCol, s32 extentX, s32 extentY) : CGuiPane(parms, dim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol, - zeus::CColor::skWhite, extentX, extentY, sp) {} + zeus::CColor::skWhite, extentX, extentY, sp, xac_drawFlags) {} void CGuiTextPane::Update(float dt) { @@ -64,6 +64,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const geomCol.a *= parms.x0_alphaMod; const_cast(this)->xd4_textSupport.SetGeometryColor(geomCol); +# if 0 CGraphics::SetDepthWriteMode(xb6_31_depthTest, ERglEnum::LEqual, xb7_24_depthWrite); switch (xac_drawFlags) @@ -95,6 +96,9 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const xd4_textSupport.Render(); break; } +#else + xd4_textSupport.Render(); +#endif } std::shared_ptr CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) diff --git a/Runtime/GuiSys/CGuiTextPane.hpp b/Runtime/GuiSys/CGuiTextPane.hpp index 3478e7f03..94759014b 100644 --- a/Runtime/GuiSys/CGuiTextPane.hpp +++ b/Runtime/GuiSys/CGuiTextPane.hpp @@ -14,13 +14,13 @@ public: CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim, const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props, const zeus::CColor& col1, const zeus::CColor& col2, s32 padX, s32 padY); - FourCC GetWidgetTypeID() const {return FOURCC('TXPN');} + FourCC GetWidgetTypeID() const { return FOURCC('TXPN'); } - CGuiTextSupport* TextSupport() {return &xd4_textSupport;} - const CGuiTextSupport* GetTextSupport() const {return &xd4_textSupport;} + CGuiTextSupport* TextSupport() { return &xd4_textSupport; } + const CGuiTextSupport* GetTextSupport() const { return &xd4_textSupport; } void Update(float dt); bool GetIsFinishedLoadingWidgetSpecific() const; - std::vector GetFontAssets() const {return {xd4_textSupport.x5c_fontId};} + std::vector GetFontAssets() const { return {xd4_textSupport.x5c_fontId}; } void SetDimensions(const zeus::CVector2f& dim, bool initVBO); void ScaleDimensions(const zeus::CVector3f& scale); void Draw(const CGuiWidgetDrawParms& parms) const; diff --git a/Runtime/GuiSys/CGuiTextSupport.cpp b/Runtime/GuiSys/CGuiTextSupport.cpp index 01355d2f6..28d27d52c 100644 --- a/Runtime/GuiSys/CGuiTextSupport.cpp +++ b/Runtime/GuiSys/CGuiTextSupport.cpp @@ -13,9 +13,11 @@ namespace urde CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, const zeus::CColor& outlineCol, - const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store) + const zeus::CColor& geomCol, s32 padX, s32 padY, CSimplePool* store, + CGuiWidget::EGuiModelDrawFlags drawFlags) : x14_props(props), x24_fontColor(fontCol), x28_outlineColor(outlineCol), - x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId) + x2c_geometryColor(geomCol), x34_extentX(padX), x38_extentY(padY), x5c_fontId(fontId), + m_drawFlags(drawFlags) { x2cc_font = store->GetObj({SBIG('FONT'), fontId}); } @@ -138,7 +140,6 @@ void CGuiTextSupport::ClearRenderBuffer() void CGuiTextSupport::CheckAndRebuildTextBuffer() { -#if 0 g_TextExecuteBuf->Clear(); g_TextExecuteBuf->x18_textState.x7c_enableWordWrap = x14_props.x0_wordWrap; g_TextExecuteBuf->BeginBlock(0, 0, x34_extentX, x38_extentY, x14_props.xc_direction, @@ -154,7 +155,6 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer() g_TextParser->ParseText(*g_TextExecuteBuf, initStr.c_str(), initStr.size()); g_TextExecuteBuf->EndBlock(); -#endif } bool CGuiTextSupport::CheckAndRebuildRenderBuffer() @@ -173,11 +173,11 @@ bool CGuiTextSupport::CheckAndRebuildRenderBuffer() if (x308_multipageFlag) { zeus::CVector2i extent(x34_extentX, x38_extentY); - x2ec_renderBufferPages = g_TextExecuteBuf->BuildRenderBufferPages(extent); + x2ec_renderBufferPages = g_TextExecuteBuf->BuildRenderBufferPages(extent, m_drawFlags); } else { - x60_renderBuf.emplace(g_TextExecuteBuf->BuildRenderBuffer()); + x60_renderBuf.emplace(g_TextExecuteBuf->BuildRenderBuffer(m_drawFlags)); x2dc_oneBufBounds = x60_renderBuf->AccumulateTextBounds(); } g_TextExecuteBuf->Clear(); @@ -201,6 +201,7 @@ void CGuiTextSupport::AutoSetExtent() void CGuiTextSupport::Render() const { + const_cast(this)->CheckAndRebuildRenderBuffer(); if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer()) { zeus::CTransform oldModel = CGraphics::g_GXModelMatrix; diff --git a/Runtime/GuiSys/CGuiTextSupport.hpp b/Runtime/GuiSys/CGuiTextSupport.hpp index 40a5591d7..fa62ea722 100644 --- a/Runtime/GuiSys/CGuiTextSupport.hpp +++ b/Runtime/GuiSys/CGuiTextSupport.hpp @@ -5,6 +5,7 @@ #include "RetroTypes.hpp" #include "CToken.hpp" #include "CTextRenderBuffer.hpp" +#include "CGuiWidget.hpp" #include "optional.hpp" #include @@ -91,6 +92,7 @@ class CGuiTextSupport float x54_chFadeTime = 0.1f; float x58_chRate = 10.0f; ResId x5c_fontId = -1; + CGuiWidget::EGuiModelDrawFlags m_drawFlags; std::experimental::optional x60_renderBuf; std::vector x2bc_assets; TLockedToken x2cc_font; @@ -107,7 +109,8 @@ class CGuiTextSupport public: CGuiTextSupport(ResId fontId, const CGuiTextProperties& props, const zeus::CColor& fontCol, const zeus::CColor& outlineCol, - const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store); + const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store, + CGuiWidget::EGuiModelDrawFlags drawFlags); float GetCurrentAnimationOverAge() const; float GetNumCharsTotal() const; float GetNumCharsPrinted() const; diff --git a/Runtime/GuiSys/CGuiWidget.hpp b/Runtime/GuiSys/CGuiWidget.hpp index a056040ef..2c809f71d 100644 --- a/Runtime/GuiSys/CGuiWidget.hpp +++ b/Runtime/GuiSys/CGuiWidget.hpp @@ -101,7 +101,7 @@ public: virtual void Touch() const; virtual bool GetIsVisible() const; virtual bool GetIsActive() const; - virtual FourCC GetWidgetTypeID() const {return FOURCC('BWIG');} + virtual FourCC GetWidgetTypeID() const { return FOURCC('BWIG'); } virtual bool AddWorkerWidget(CGuiWidget* worker); virtual bool GetIsFinishedLoadingWidgetSpecific() const; virtual void OnVisibleChange(); diff --git a/Runtime/GuiSys/CInstruction.cpp b/Runtime/GuiSys/CInstruction.cpp index e8a1da59c..da809fc91 100644 --- a/Runtime/GuiSys/CInstruction.cpp +++ b/Runtime/GuiSys/CInstruction.cpp @@ -238,7 +238,7 @@ void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) tex->GetHeight() * x4_image.x14_pointsPerTexel.y * 2 / 3); buf->AddImage(coords, x4_image); } - state.xd4_curX += tex->GetWidth() * x4_image.x14_pointsPerTexel.x; + state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_pointsPerTexel.x; } } } diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index ce0ee7d33..585eb5216 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -92,7 +92,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in { if (opts.x0_direction == ETextDirection::Horizontal) { - x += glyph->GetA(); + x += glyph->GetLeftPadding(); if (prevGlyph != 0) x += KernLookup(x1c_kerning, prevGlyph->GetKernStart(), *chr); @@ -102,10 +102,10 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in if (renderBuf) { left += x; - top += glyph->GetBaseline() - y; + top += y - glyph->GetBaseline(); renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x4_colors[0]); } - x += glyph->GetC() + glyph->GetB(); + x += glyph->GetRightPadding() + glyph->GetAdvance(); } } prevGlyph = glyph; @@ -113,7 +113,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in if (length == -1) continue; - if ((str - chr) >= length) + if ((chr - str) >= length) break; } @@ -173,8 +173,8 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh if (prevGlyph) advance = KernLookup(x1c_kerning, prevGlyph->GetKernStart(), *chr); - s16 curWidth = prevWidth - (glyph->GetA() + glyph->GetB() + glyph->GetC() + advance); - s16 curHeight = glyph->GetBaseline() - (x8_monoHeight + glyph->GetCellHeight()); + int curWidth = prevWidth + (glyph->GetLeftPadding() + glyph->GetAdvance() + glyph->GetRightPadding() + advance); + int curHeight = glyph->GetBaseline() - (x8_monoHeight + glyph->GetCellHeight()); width = curWidth; prevWidth = curWidth; @@ -189,7 +189,7 @@ void CRasterFont::GetSize(const CDrawStringOptions& opts, int& width, int& heigh if (len == -1) continue; - if ((str - chr) >= len) + if ((chr - str) >= len) break; } } diff --git a/Runtime/GuiSys/CRasterFont.hpp b/Runtime/GuiSys/CRasterFont.hpp index 49754ff6b..5ed34571f 100644 --- a/Runtime/GuiSys/CRasterFont.hpp +++ b/Runtime/GuiSys/CRasterFont.hpp @@ -5,11 +5,11 @@ #include "CToken.hpp" #include "zeus/CVector2i.hpp" #include "CGuiTextSupport.hpp" +#include "Graphics/CTexture.hpp" namespace urde { class IObjectStore; -class CTexture; class CDrawStringOptions; class CTextRenderBuffer; @@ -28,28 +28,30 @@ private: s16 x1a_cellHeight; s16 x1c_baseline; s16 x1e_kernStart; + s16 m_layer; + public: CGlyph() = default; CGlyph(s16 a, s16 b, s32 c, float startU, float startV, float endU, float endV, - s16 cellWidth, s16 cellHeight, s16 baseline, s16 kernStart) + s16 cellWidth, s16 cellHeight, s16 baseline, s16 kernStart, s16 layer=0) : x0_leftPadding(a), x2_advance(b), x4_rightPadding(c), x8_startU(startU), xc_startV(startV), x10_endU(endU), x14_endV(endV), x18_cellWidth(cellWidth), x1a_cellHeight(cellHeight), - x1c_baseline(baseline), x1e_kernStart(kernStart) + x1c_baseline(baseline), x1e_kernStart(kernStart), m_layer(layer) {} - s16 GetA() const { return x0_leftPadding; } - s16 GetB() const { return x2_advance; } - s16 GetC() const { return x4_rightPadding; } - float GetStartU() const { return x8_startU; } - float GetStartV() const { return xc_startV; } - float GetEndU() const { return x10_endU; } - float GetEndV() const { return x14_endV; } - s16 GetCellWidth() const { return x18_cellWidth; } - s16 GetCellHeight() const { return x1a_cellHeight; } - s16 GetBaseline() const { return x1c_baseline; } - s16 GetKernStart() const { return x1e_kernStart; } - + s16 GetLeftPadding() const { return x0_leftPadding; } + s16 GetAdvance() const { return x2_advance; } + s16 GetRightPadding() const { return x4_rightPadding; } + float GetStartU() const { return x8_startU; } + float GetStartV() const { return xc_startV; } + float GetEndU() const { return x10_endU; } + float GetEndV() const { return x14_endV; } + s16 GetCellWidth() const { return x18_cellWidth; } + s16 GetCellHeight() const { return x1a_cellHeight; } + s16 GetBaseline() const { return x1c_baseline; } + s16 GetKernStart() const { return x1e_kernStart; } + s16 GetLayer() const { return m_layer; } }; class CKernPair @@ -146,7 +148,7 @@ public: } void GetSize(const CDrawStringOptions& opts, int& width, int& height, const char16_t* str, int len) const; - TToken& GetTexture() { return x80_texture; } + boo::ITexture* GetTexture() { return x80_texture->GetFontTexture(CTexture::EFontType(x2c_mode)); } }; std::unique_ptr FRasterFontFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, diff --git a/Runtime/GuiSys/CTextExecuteBuffer.cpp b/Runtime/GuiSys/CTextExecuteBuffer.cpp index 1765b55d3..19be8224c 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.cpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.cpp @@ -11,9 +11,9 @@ namespace urde { -CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer() const +CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer(CGuiWidget::EGuiModelDrawFlags df) const { - CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally); + CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally, df); { CFontRenderState rendState; @@ -34,9 +34,10 @@ CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer() const CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iterator start, InstList::const_iterator pgStart, - InstList::const_iterator pgEnd) const + InstList::const_iterator pgEnd, + CGuiWidget::EGuiModelDrawFlags df) const { - CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally); + CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally, df); { CFontRenderState rendState; @@ -71,14 +72,15 @@ CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iter return ret; } -std::list CTextExecuteBuffer::BuildRenderBufferPages(const zeus::CVector2i& extent) const +std::list CTextExecuteBuffer::BuildRenderBufferPages(const zeus::CVector2i& extent, + CGuiWidget::EGuiModelDrawFlags df) const { std::list ret; for (auto it = x0_instList.begin() ; it != x0_instList.end() ;) { const std::shared_ptr& inst = *it; - CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally); + CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally, df); { CFontRenderState rstate; @@ -111,7 +113,7 @@ std::list CTextExecuteBuffer::BuildRenderBufferPages(const ze } } - ret.push_back(BuildRenderBufferPage(x0_instList.cbegin(), it, pageEnd)); + ret.push_back(BuildRenderBufferPage(x0_instList.cbegin(), it, pageEnd, df)); it = pageEnd; } diff --git a/Runtime/GuiSys/CTextExecuteBuffer.hpp b/Runtime/GuiSys/CTextExecuteBuffer.hpp index 22e2888a6..9cae380ac 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.hpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.hpp @@ -24,7 +24,7 @@ class CTextExecuteBuffer CSaveableState x18_textState; CBlockInstruction* xa0_curBlock = nullptr; CLineInstruction* xa4_curLine = nullptr; - std::list>::iterator xa8_curWordIt; + InstList::iterator xa8_curWordIt; s32 xac_curY; s32 xb0_curX; s32 xb4_curWordX = 0; @@ -40,11 +40,13 @@ public: xa8_curWordIt = x0_instList.begin(); } - CTextRenderBuffer BuildRenderBuffer() const; + CTextRenderBuffer BuildRenderBuffer(CGuiWidget::EGuiModelDrawFlags df) const; CTextRenderBuffer BuildRenderBufferPage(InstList::const_iterator start, InstList::const_iterator pgStart, - InstList::const_iterator pgEnd) const; - std::list BuildRenderBufferPages(const zeus::CVector2i& extent) const; + InstList::const_iterator pgEnd, + CGuiWidget::EGuiModelDrawFlags df) const; + std::list BuildRenderBufferPages(const zeus::CVector2i& extent, + CGuiWidget::EGuiModelDrawFlags df) const; std::vector GetAssets() const; void AddString(const char16_t* str, int len); void AddStringFragment(const char16_t* str, int len); diff --git a/Runtime/GuiSys/CTextParser.cpp b/Runtime/GuiSys/CTextParser.cpp index a4c95cc2b..657fd294f 100644 --- a/Runtime/GuiSys/CTextParser.cpp +++ b/Runtime/GuiSys/CTextParser.cpp @@ -240,7 +240,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) AdvanceTokenPos(); } while (commaPos != iterable.size()); - return CFontImageDef(std::move(texs), interval, zeus::CVector2f(1.f, 1.f)); + return CFontImageDef(texs, interval, zeus::CVector2f(1.f, 1.f)); } else if (BeginsWith(str, len, u"SA")) { @@ -267,7 +267,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) AdvanceTokenPos(); } while (commaPos != iterable.size()); - return CFontImageDef(std::move(texs), interval, zeus::CVector2f(scaleX, scaleY)); + return CFontImageDef(texs, interval, zeus::CVector2f(scaleX, scaleY)); } else if (BeginsWith(str, len, u"SI")) { @@ -285,12 +285,12 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) GetAssetIdFromString(&iterable[tokenPos])}); AdvanceTokenPos(); - return CFontImageDef(std::move(tex), zeus::CVector2f(scaleX, scaleY)); + return CFontImageDef(tex, zeus::CVector2f(scaleX, scaleY)); } } TToken tex = x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(str)}); - return CFontImageDef(std::move(tex), zeus::CVector2f(1.f, 1.f)); + return CFontImageDef(tex, zeus::CVector2f(1.f, 1.f)); } ResId CTextParser::GetAssetIdFromString(const char16_t* str) @@ -309,7 +309,8 @@ TToken CTextParser::GetFont(const char16_t* str, int len) void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len) { - for (int b=0, e=0 ; str[e] && (len == -1 || e < len) ;) + int b=0, e=0; + for (b=0, e=0 ; str[e] && (len == -1 || e < len) ;) { if (str[e] != u'&') { @@ -335,6 +336,9 @@ void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int le b = e; } } + + if (e > b) + out.AddString(str + b, e - b); } } diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index 61874a34e..20100d5c2 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -7,34 +7,13 @@ #include "CTextExecuteBuffer.hpp" #include "CFontRenderState.hpp" #include "CInstruction.hpp" +#include "Graphics/Shaders/CTextSupportShader.hpp" namespace urde { -boo::IShaderPipeline* g_TextShaderPipeline = nullptr; -boo::IVertexFormat* g_TextVtxFmt = nullptr; - -boo::IShaderPipeline* g_TextImageShaderPipeline = nullptr; -boo::IVertexFormat* g_TextImageVtxFmt = nullptr; - -CTextRenderBuffer::CTextRenderBuffer(EMode mode) -: x0_mode(mode) {} - -void CTextRenderBuffer::BooCharacterInstance::SetMetrics(const CGlyph& glyph, - const zeus::CVector2i& offset) -{ - m_pos[0].assign(offset.x, 0.f, offset.y); - m_uv[0].assign(glyph.GetStartU(), glyph.GetStartV()); - - m_pos[1].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y); - m_uv[1].assign(glyph.GetEndU(), glyph.GetStartV()); - - m_pos[2].assign(offset.x, 0.f, offset.y + glyph.GetCellHeight()); - m_uv[2].assign(glyph.GetStartU(), glyph.GetEndV()); - - m_pos[3].assign(offset.x + glyph.GetCellWidth(), 0.f, offset.y + glyph.GetCellHeight()); - m_uv[3].assign(glyph.GetEndU(), glyph.GetEndV()); -} +CTextRenderBuffer::CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df) +: x0_mode(mode), m_drawFlags(df) {} CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset) : m_imageDef(imgDef) @@ -47,17 +26,7 @@ CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::C tex.GetHeight() * imgDef.x14_pointsPerTexel.y); } - m_imageData.m_pos[0].assign(offset.x, 0.f, offset.y); - m_imageData.m_uv[0].assign(0.f, 0.f); - - m_imageData.m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y); - m_imageData.m_uv[1].assign(1.f, 0.f); - - m_imageData.m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y); - m_imageData.m_uv[2].assign(0.f, 1.f); - - m_imageData.m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y); - m_imageData.m_uv[3].assign(1.f, 1.f); + m_imageData.SetMetrics(imgSize, offset); } void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, float opacity) @@ -67,7 +36,7 @@ void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, floa case Command::CharacterRender: { BooFontCharacters& fc = rb.m_fontCharacters[m_bindIdx]; - BooCharacterInstance& inst = fc.m_charData[m_instIdx]; + CTextSupportShader::CharacterInstance& inst = fc.m_charData[m_instIdx]; inst.m_fontColor.a = opacity; inst.m_outlineColor.a = opacity; fc.m_dirty = true; @@ -90,70 +59,87 @@ void CTextRenderBuffer::CommitResources() return; m_committed = true; + /* Ensure font textures are ready outside transaction */ + for (BooFontCharacters& chs : m_fontCharacters) + chs.m_font->GetTexture(); + m_booToken = CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool { - m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(BooUniform), 1); + m_uniBuf = CTextSupportShader::s_Uniforms.allocateBlock(CGraphics::g_BooFactory); + auto uBufInfo = m_uniBuf.getBufferInfo(); for (BooFontCharacters& chs : m_fontCharacters) { - chs.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, - sizeof(BooCharacterInstance), - chs.m_charCount); - boo::IVertexFormat* vFmt = g_TextVtxFmt; + chs.m_instBuf = CTextSupportShader::s_CharInsts.allocateBlock(CGraphics::g_BooFactory, chs.m_charCount); + auto iBufInfo = chs.m_instBuf.getBufferInfo(); + + boo::IVertexFormat* vFmt = CTextSupportShader::s_TextVtxFmt; if (ctx.bindingNeedsVertexFormat()) { + boo::IGraphicsBufferD* buf = iBufInfo.first; boo::VertexElementDescriptor elems[] = { - {chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, - {chs.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 1}, }; - vFmt = ctx.newVertexFormat(10, elems); + vFmt = ctx.newVertexFormat(10, elems, 0, iBufInfo.second); } - boo::IGraphicsBuffer* uniforms[] = {m_uniBuf}; - boo::ITexture* texs[] = {chs.m_font.GetObj()->GetTexture()->GetBooTexture()}; - chs.m_dataBinding = ctx.newShaderDataBinding(g_TextShaderPipeline, vFmt, - nullptr, chs.m_instBuf, nullptr, - 1, uniforms, nullptr, 1, texs); + boo::IGraphicsBuffer* uniforms[] = {uBufInfo.first}; + boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex}; + size_t unioffs[] = {uBufInfo.second}; + size_t unisizes[] = {sizeof(CTextSupportShader::Uniform)}; + boo::ITexture* texs[] = {chs.m_font->GetTexture()}; + chs.m_dataBinding = ctx.newShaderDataBinding(CTextSupportShader::SelectTextPipeline(m_drawFlags), + vFmt, nullptr, iBufInfo.first, nullptr, + 1, uniforms, unistages, unioffs, + unisizes, 1, texs, 0, iBufInfo.second); } for (BooImage& img : m_images) { - img.m_instBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(BooImageInstance), 1); - boo::IVertexFormat* vFmt = g_TextImageVtxFmt; + img.m_instBuf = CTextSupportShader::s_ImgInsts.allocateBlock(CGraphics::g_BooFactory, 1); + auto iBufInfo = img.m_instBuf.getBufferInfo(); + + boo::IVertexFormat* vFmt = CTextSupportShader::s_ImageVtxFmt; if (ctx.bindingNeedsVertexFormat()) { + boo::IGraphicsBufferD* buf = iBufInfo.first; boo::VertexElementDescriptor elems[] = { - {img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, - {img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, - {img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, - {img.m_instBuf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, - {img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, - {img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, - {img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, - {img.m_instBuf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, - {img.m_instBuf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 2}, + {buf, nullptr, boo::VertexSemantic::Position4 | boo::VertexSemantic::Instanced, 3}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 0}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 1}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 2}, + {buf, nullptr, boo::VertexSemantic::UV4 | boo::VertexSemantic::Instanced, 3}, + {buf, nullptr, boo::VertexSemantic::Color | boo::VertexSemantic::Instanced, 0}, }; - vFmt = ctx.newVertexFormat(9, elems); + vFmt = ctx.newVertexFormat(9, elems, 0, iBufInfo.second); } - boo::IGraphicsBuffer* uniforms[] = {m_uniBuf}; + boo::IGraphicsBuffer* uniforms[] = {uBufInfo.first}; + boo::PipelineStage unistages[] = {boo::PipelineStage::Vertex}; + size_t unioffs[] = {uBufInfo.second}; + size_t unisizes[] = {sizeof(CTextSupportShader::Uniform)}; img.m_dataBinding.reserve(img.m_imageDef.x4_texs.size()); for (TToken& tex : img.m_imageDef.x4_texs) { boo::ITexture* texs[] = {tex->GetBooTexture()}; - img.m_dataBinding.push_back(ctx.newShaderDataBinding(g_TextImageShaderPipeline, vFmt, - nullptr, img.m_instBuf, nullptr, - 1, uniforms, nullptr, 1, texs)); + img.m_dataBinding.push_back(ctx.newShaderDataBinding(CTextSupportShader::SelectImagePipeline(m_drawFlags), + vFmt, nullptr, iBufInfo.first, nullptr, + 1, uniforms, unistages, unioffs, + unisizes, 1, texs, 0, iBufInfo.second)); } } return true; @@ -169,6 +155,7 @@ void CTextRenderBuffer::SetMode(EMode mode) fc.m_charData.reserve(fc.m_charCount); } m_activeFontCh = -1; + x0_mode = mode; } void CTextRenderBuffer::SetPrimitiveOpacity(int idx, float opacity) @@ -180,26 +167,34 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const { const_cast(this)->CommitResources(); - BooUniform uniforms = {CGraphics::GetPerspectiveProjectionMatrix(true) * - CGraphics::g_GXModelView.toMatrix4f(), col}; - m_uniBuf->load(&uniforms, sizeof(uniforms)); + zeus::CMatrix4f mv = CGraphics::g_GXModelView.toMatrix4f(); + zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true); + zeus::CMatrix4f mat = proj * mv; + + const_cast(this)->m_uniBuf.access() = + CTextSupportShader::Uniform{mat, col}; for (const BooFontCharacters& chs : m_fontCharacters) { - if (chs.m_dirty) + if (chs.m_charData.size()) { - chs.m_instBuf->load(chs.m_charData.data(), sizeof(BooCharacterInstance) * chs.m_charData.size()); - ((BooFontCharacters&)chs).m_dirty = false; + if (chs.m_dirty) + { + memmove(const_cast(chs).m_instBuf.access(), + chs.m_charData.data(), sizeof(CTextSupportShader::CharacterInstance) * + chs.m_charData.size()); + const_cast(chs).m_dirty = false; + } + CGraphics::SetShaderDataBinding(chs.m_dataBinding); + CGraphics::DrawInstances(0, 4, chs.m_charData.size()); } - CGraphics::SetShaderDataBinding(chs.m_dataBinding); - CGraphics::DrawInstances(0, 4, chs.m_charData.size()); } for (const BooImage& img : m_images) { if (img.m_dirty) { - img.m_instBuf->load(&img.m_imageData, sizeof(BooImageInstance)); + *const_cast(img).m_instBuf.access() = img.m_imageData; const_cast(img).m_dirty = false; } int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size(); @@ -216,7 +211,7 @@ void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImage m_images.push_back({image, offset}); } -void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, wchar_t ch, +void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color) { if (m_activeFontCh == -1) @@ -228,7 +223,7 @@ void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, wchar_t ch, { const CGlyph* glyph = chs.m_font.GetObj()->GetGlyph(ch); chs.m_charData.emplace_back(); - BooCharacterInstance& inst = chs.m_charData.back(); + CTextSupportShader::CharacterInstance& inst = chs.m_charData.back(); inst.SetMetrics(*glyph, offset); inst.m_fontColor = m_main * color; inst.m_outlineColor = m_outline * color; @@ -278,7 +273,7 @@ std::pair CTextRenderBuffer::AccumulateTextBou for (const BooFontCharacters& chars : m_fontCharacters) { - for (const BooCharacterInstance& charInst : chars.m_charData) + for (const CTextSupportShader::CharacterInstance& charInst : chars.m_charData) { ret.first.x = std::min(ret.first.x, int(charInst.m_pos[0].x)); ret.first.y = std::min(ret.first.y, int(charInst.m_pos[0].z)); diff --git a/Runtime/GuiSys/CTextRenderBuffer.hpp b/Runtime/GuiSys/CTextRenderBuffer.hpp index 73291c512..d8a76af6b 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.hpp +++ b/Runtime/GuiSys/CTextRenderBuffer.hpp @@ -8,7 +8,8 @@ #include "CToken.hpp" #include "CFontImageDef.hpp" #include "RetroTypes.hpp" - +#include "CGuiWidget.hpp" +#include "Graphics/Shaders/CTextSupportShader.hpp" #include "boo/graphicsdev/IGraphicsDataFactory.hpp" namespace urde @@ -23,6 +24,7 @@ using CTextColor = zeus::CColor; class CTextRenderBuffer { friend class CGuiTextSupport; + friend class CTextSupportShader; public: enum class Command { @@ -64,50 +66,27 @@ private: #else /* Boo-specific text-rendering functionality */ - struct BooUniform - { - zeus::CMatrix4f m_mvp; - zeus::CColor m_uniformColor; - }; - boo::IGraphicsBufferD* m_uniBuf; - - struct BooCharacterInstance - { - zeus::CVector3f m_pos[4]; - zeus::CVector2f m_uv[4]; - zeus::CColor m_fontColor; - zeus::CColor m_outlineColor; - void SetMetrics(const CGlyph& glyph, const zeus::CVector2i& offset); - }; - - struct BooImageInstance - { - zeus::CVector3f m_pos[4]; - zeus::CVector2f m_uv[4]; - zeus::CColor m_color; - }; + hecl::UniformBufferPool::Token m_uniBuf; struct BooFontCharacters { - TToken m_font; - boo::IGraphicsBufferD* m_instBuf = nullptr; + TLockedToken m_font; + hecl::VertexBufferPool::Token m_instBuf; boo::IShaderDataBinding* m_dataBinding = nullptr; - std::vector m_charData; + std::vector m_charData; u32 m_charCount = 0; bool m_dirty = true; BooFontCharacters(const CToken& token) - : m_font(token) - { - } + : m_font(token) {} }; std::vector m_fontCharacters; struct BooImage { CFontImageDef m_imageDef; - boo::IGraphicsBufferD* m_instBuf = nullptr; + hecl::VertexBufferPool::Token m_instBuf; std::vector m_dataBinding; - BooImageInstance m_imageData; + CTextSupportShader::ImageInstance m_imageData; bool m_dirty = true; BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset); }; @@ -129,12 +108,14 @@ private: zeus::CColor m_main; zeus::CColor m_outline; + CGuiWidget::EGuiModelDrawFlags m_drawFlags; + bool m_committed = false; void CommitResources(); #endif public: - CTextRenderBuffer(EMode mode); + CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags df); #if 0 void SetPrimitive(const Primitive&, int); Primitive GetPrimitive(int) const; @@ -150,7 +131,7 @@ public: void SetMode(EMode mode); void Render(const zeus::CColor& col, float) const; void AddImage(const zeus::CVector2i& offset, const CFontImageDef& image); - void AddCharacter(const zeus::CVector2i& offset, wchar_t ch, const zeus::CColor& color); + void AddCharacter(const zeus::CVector2i& offset, char16_t ch, const zeus::CColor& color); void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline); void AddFontChange(const TToken& font); diff --git a/Runtime/MP1/CFrontEndUI.cpp b/Runtime/MP1/CFrontEndUI.cpp index 7b030940b..a275f888d 100644 --- a/Runtime/MP1/CFrontEndUI.cpp +++ b/Runtime/MP1/CFrontEndUI.cpp @@ -175,6 +175,7 @@ void CFrontEndUI::SNewFileSelectFrame::Update(float dt) } if (x10c_saveReady) SetupFrameContents(); + x1c_loadedFrame->Update(dt); } @@ -1246,7 +1247,7 @@ CFrontEndUI::SNesEmulatorFrame::SNesEmulatorFrame() ETextDirection::Horizontal); xc_textSupport = std::make_unique(deface->id, props, zeus::CColor::skWhite, zeus::CColor::skBlack, zeus::CColor::skWhite, - 0, 0, g_SimplePool); + 0, 0, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha); } void CFrontEndUI::SNesEmulatorFrame::SetMode(EMode mode) @@ -2002,7 +2003,7 @@ void CFrontEndUI::Draw() const } } - if (xdc_saveUI) + if (0 && xdc_saveUI) { /* Render memory card feedback strings */ if ((CanShowSaveUI() && !xdc_saveUI->IsHiddenFromFrontEnd()) || diff --git a/Runtime/MP1/CSlideShow.cpp b/Runtime/MP1/CSlideShow.cpp index 97f33a4da..1ff402100 100644 --- a/Runtime/MP1/CSlideShow.cpp +++ b/Runtime/MP1/CSlideShow.cpp @@ -20,13 +20,15 @@ CSlideShow::CSlideShow() xc4_textA = std::make_unique(font->id, propsA, g_tweakSlideShow->GetFontColor(), g_tweakSlideShow->GetOutlineColor(), - zeus::CColor::skWhite, 640, 480, g_SimplePool); + zeus::CColor::skWhite, 640, 480, g_SimplePool, + CGuiWidget::EGuiModelDrawFlags::Alpha); CGuiTextProperties propsB(false, true, EJustification::Right, EVerticalJustification::Bottom); xc8_textB = std::make_unique(font->id, propsB, g_tweakSlideShow->GetFontColor(), g_tweakSlideShow->GetOutlineColor(), - zeus::CColor::skWhite, 640, 480, g_SimplePool); + zeus::CColor::skWhite, 640, 480, g_SimplePool, + CGuiWidget::EGuiModelDrawFlags::Alpha); } xf8_stickTextures.reserve(18); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index c8cd8b83b..6d368864f 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -7,6 +7,7 @@ #include "Graphics/Shaders/CTexturedQuadFilter.hpp" #include "Graphics/Shaders/CCameraBlurFilter.hpp" #include "Graphics/Shaders/CXRayBlurFilter.hpp" +#include "Graphics/Shaders/CTextSupportShader.hpp" #include "Character/CCharLayoutInfo.hpp" #include "Audio/CStreamAudioManager.hpp" #include "CGBASupport.hpp" @@ -23,6 +24,7 @@ URDE_DECL_SPECIALIZE_SHADER(CXRayBlurFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CColoredQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha) +URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTextSupportShader) namespace MP1 { @@ -46,8 +48,8 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi CStreamAudioManager::Initialize(); m->ResetGameState(); - std::shared_ptr splash = std::make_shared(CSplashScreen::ESplashScreen::Nintendo); - x58_ioWinManager.AddIOWin(splash, 1000, 10000); + //std::shared_ptr splash = std::make_shared(CSplashScreen::ESplashScreen::Nintendo); + //x58_ioWinManager.AddIOWin(splash, 1000, 10000); std::shared_ptr mf = std::make_shared(); x58_ioWinManager.AddIOWin(mf, 0, 0); @@ -201,6 +203,7 @@ CMain::BooSetter::BooSetter(boo::IGraphicsDataFactory* factory, TMultiBlendShader::Initialize(); TMultiBlendShader::Initialize(); TMultiBlendShader::Initialize(); + TMultiBlendShader::Initialize(); } void CMain::RegisterResourceTweaks() @@ -303,6 +306,7 @@ void CMain::Shutdown() TMultiBlendShader::Shutdown(); TMultiBlendShader::Shutdown(); TMultiBlendShader::Shutdown(); + TMultiBlendShader::Shutdown(); } #if MP1_USE_BOO diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 844d22188..5a309604b 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -385,7 +385,7 @@ void CWorldTransManager::EnableTransition(ResId fontId, ResId stringId, bool b1, EVerticalJustification::Center, ETextDirection::Horizontal); x8_textData.reset(new CGuiTextSupport(fontId, props, zeus::CColor::skWhite, zeus::CColor::skBlack, zeus::CColor::skWhite, - 640, 448, g_SimplePool)); + 640, 448, g_SimplePool, CGuiWidget::EGuiModelDrawFlags::Alpha)); x8_textData->SetTypeWriteEffectOptions(true, chFadeTime, chFadeRate); xc_strTable = g_SimplePool->GetObj(SObjectTag{FOURCC('STRG'), stringId}); diff --git a/hecl b/hecl index cef5e394b..d4fd78673 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit cef5e394b9f29850e2ec299bf39f33bc0f9f5a10 +Subproject commit d4fd78673feebcc5b29eba53178e545cee695891 diff --git a/specter b/specter index 661b391cd..ba23dd8d9 160000 --- a/specter +++ b/specter @@ -1 +1 @@ -Subproject commit 661b391cd0277bb6de3aeb74d53c990e6ec07099 +Subproject commit ba23dd8d9449076c1ebf7c010c1b45c599456792