diff --git a/Editor/ProjectManager.cpp b/Editor/ProjectManager.cpp index 6b1ee57a9..fb7896ece 100644 --- a/Editor/ProjectManager.cpp +++ b/Editor/ProjectManager.cpp @@ -130,7 +130,8 @@ makeProj: m_vm.SetupEditorView(); m_factoryMP1.IndexMP1Resources(*m_proj); - m_mainMP1.emplace(m_factoryMP1, m_objStore, m_vm.m_mainBooFactory, m_vm.m_mainCommandQueue, m_vm.m_renderTex); + m_mainMP1.emplace(m_factoryMP1, m_objStore, m_vm.m_mainBooFactory, + m_vm.m_mainCommandQueue, m_vm.m_renderTex, *m_vm.m_amuseAllocWrapper); m_vm.InitMP1(*m_mainMP1); m_vm.BuildTestPART(m_objStore); @@ -185,6 +186,12 @@ void ProjectManager::mainUpdate() m_mainMP1->Proc(); } +void ProjectManager::mainDraw() +{ + if (m_mainMP1) + m_mainMP1->Draw(); +} + void ProjectManager::asyncIdle() { m_factoryMP1.AsyncIdle(); diff --git a/Editor/ProjectManager.hpp b/Editor/ProjectManager.hpp index 7f88e4874..b187e5e54 100644 --- a/Editor/ProjectManager.hpp +++ b/Editor/ProjectManager.hpp @@ -52,6 +52,7 @@ public: bool saveProject(); void mainUpdate(); + void mainDraw(); void asyncIdle(); void shutdown(); }; diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 3f88bdfe8..53c0cced9 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -176,8 +176,10 @@ void ViewManager::ParticleView::draw(boo::IGraphicsCommandQueue *gfxQ) if (m_frame == 300) g_GameState->GetWorldTransitionManager()->PleaseStopSoon(); - g_GameState->GetWorldTransitionManager()->Update(1.f / 60.f); - g_GameState->GetWorldTransitionManager()->Draw(); + //g_GameState->GetWorldTransitionManager()->Update(1.f / 60.f); + //g_GameState->GetWorldTransitionManager()->Draw(); + + m_vm.m_projManager.mainDraw(); ++m_frame; } @@ -348,6 +350,7 @@ void ViewManager::init(boo::IApplication* app) m_renderTex = root->renderTex(); m_mainWindow->setWaitCursor(false); m_voiceEngine = boo::NewAudioVoiceEngine(); + m_amuseAllocWrapper.emplace(*m_voiceEngine); /* CGraphics::InitializeBoo(gf, m_mainWindow->getCommandQueue(), root->renderTex()); CModelShaders::Initialize(m_fileStoreManager, gf); diff --git a/Editor/ViewManager.hpp b/Editor/ViewManager.hpp index 57ba8095e..4b35da2c4 100644 --- a/Editor/ViewManager.hpp +++ b/Editor/ViewManager.hpp @@ -3,6 +3,7 @@ #include "hecl/CVarManager.hpp" #include "boo/audiodev/IAudioVoiceEngine.hpp" +#include "amuse/BooBackend.hpp" #include "ProjectManager.hpp" #include "Space.hpp" @@ -75,6 +76,7 @@ class ViewManager : public specter::IViewManager std::unique_ptr m_rsfBuf; std::unique_ptr m_voiceEngine; std::unique_ptr m_videoVoice; + std::experimental::optional m_amuseAllocWrapper; struct AudioVoiceCallback : boo::IAudioVoiceCallback { ViewManager& m_vm; diff --git a/Runtime/Audio/CAudioSys.hpp b/Runtime/Audio/CAudioSys.hpp index e81222b3d..c6ecd7b84 100644 --- a/Runtime/Audio/CAudioSys.hpp +++ b/Runtime/Audio/CAudioSys.hpp @@ -3,12 +3,14 @@ #include "../GCNTypes.hpp" #include "zeus/CVector3f.hpp" +#include "amuse/amuse.hpp" namespace urde { class CAudioSys { + amuse::Engine m_engine; public: struct C3DEmitterParmData { @@ -22,7 +24,8 @@ public: u8 minVol; u8 extra[2]; }; - CAudioSys(u8,u8,u8,u8,u32) + CAudioSys(amuse::IBackendVoiceAllocator& backend, u8,u8,u8,u8,u32) + : m_engine(backend) { } }; diff --git a/Runtime/CIOWinManager.cpp b/Runtime/CIOWinManager.cpp index 3a6db6d5e..a1795038b 100644 --- a/Runtime/CIOWinManager.cpp +++ b/Runtime/CIOWinManager.cpp @@ -44,31 +44,26 @@ bool CIOWinManager::OnIOWinMessage(const CArchitectureMessage& msg) void CIOWinManager::Draw() const { - IOWinPQNode* node = x0_drawRoot; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); iow->PreDraw(); if (!iow->GetIsContinueDraw()) break; - node = node->x8_next; } - node = x0_drawRoot; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); iow->Draw(); if (!iow->GetIsContinueDraw()) break; - node = node->x8_next; } } bool CIOWinManager::DistributeOneMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue) { - IOWinPQNode* node = x4_pumpRoot; - while (node) + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); CIOWin::EMessageReturn mret = iow->OnMessage(msg, x8_localGatherQueue); @@ -104,8 +99,6 @@ bool CIOWinManager::DistributeOneMessage(const CArchitectureMessage& msg, return false; default: break; } - - node = node->x8_next; } return false; @@ -125,22 +118,18 @@ CIOWin* CIOWinManager::FindIOWin(const std::string& name) { size_t findHash = std::hash()(name); - IOWinPQNode* node = x4_pumpRoot; - while (node) + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow->GetNameHash() == findHash) return iow; - node = node->x8_next; } - node = x0_drawRoot; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow->GetNameHash() == findHash) return iow; - node = node->x8_next; } return nullptr; @@ -150,22 +139,18 @@ std::shared_ptr CIOWinManager::FindAndShareIOWin(const std::string& name { size_t findHash = std::hash()(name); - IOWinPQNode* node = x4_pumpRoot; - while (node) + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) { std::shared_ptr iow = node->ShareIOWin(); if (iow->GetNameHash() == findHash) return iow; - node = node->x8_next; } - node = x0_drawRoot; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { std::shared_ptr iow = node->ShareIOWin(); if (iow->GetNameHash() == findHash) return iow; - node = node->x8_next; } return std::shared_ptr(); @@ -173,9 +158,8 @@ std::shared_ptr CIOWinManager::FindAndShareIOWin(const std::string& name void CIOWinManager::ChangeIOWinPriority(CIOWin* toChange, int pumpPrio, int drawPrio) { - IOWinPQNode* node = x4_pumpRoot; IOWinPQNode* prevNode = nullptr; - while (node) + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow == toChange) @@ -198,12 +182,10 @@ void CIOWinManager::ChangeIOWinPriority(CIOWin* toChange, int pumpPrio, int draw break; } prevNode = node; - node = node->x8_next; } - node = x0_drawRoot; prevNode = nullptr; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow == toChange) @@ -226,35 +208,23 @@ void CIOWinManager::ChangeIOWinPriority(CIOWin* toChange, int pumpPrio, int draw break; } prevNode = node; - node = node->x8_next; } } void CIOWinManager::RemoveAllIOWins() { - IOWinPQNode* node = x0_drawRoot; - while (node) - { - IOWinPQNode* delNode = node; - node = node->x8_next; - delete delNode; - } + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) + delete node; x0_drawRoot = nullptr; - node = x4_pumpRoot; - while (node) - { - IOWinPQNode* delNode = node; - node = node->x8_next; - delete delNode; - } + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) + delete node; x4_pumpRoot = nullptr; } void CIOWinManager::RemoveIOWin(CIOWin* chIow) { - IOWinPQNode* node = x4_pumpRoot; IOWinPQNode* prevNode = nullptr; - while (node) + for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow == chIow) @@ -267,12 +237,10 @@ void CIOWinManager::RemoveIOWin(CIOWin* chIow) break; } prevNode = node; - node = node->x8_next; } - node = x0_drawRoot; prevNode = nullptr; - while (node) + for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next) { CIOWin* iow = node->GetIOWin(); if (iow == chIow) @@ -285,32 +253,24 @@ void CIOWinManager::RemoveIOWin(CIOWin* chIow) break; } prevNode = node; - node = node->x8_next; } } void CIOWinManager::AddIOWin(std::weak_ptr chIow, int pumpPrio, int drawPrio) { - IOWinPQNode* node = x4_pumpRoot; + IOWinPQNode* node; IOWinPQNode* prevNode = nullptr; - while (node && pumpPrio > node->x4_prio) - { + for (node = x4_pumpRoot ; node && pumpPrio < node->x4_prio ; node = node->x8_next) prevNode = node; - node = node->x8_next; - } IOWinPQNode* newNode = new IOWinPQNode(chIow, pumpPrio, node); if (prevNode) prevNode->x8_next = newNode; else x4_pumpRoot = newNode; - node = x0_drawRoot; prevNode = nullptr; - while (node && drawPrio > node->x4_prio) - { + for (node = x0_drawRoot ; node && drawPrio < node->x4_prio ; node = node->x8_next) prevNode = node; - node = node->x8_next; - } newNode = new IOWinPQNode(chIow, drawPrio, node); if (prevNode) prevNode->x8_next = newNode; diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp index edc86b660..96e1694e8 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.cpp @@ -4,6 +4,11 @@ namespace urde { +CTexturedQuadFilter::CTexturedQuadFilter(boo::ITexture* tex) +: m_booTex(tex) +{ +} + CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, boo::ITexture* tex) : m_booTex(tex) { @@ -23,7 +28,30 @@ CTexturedQuadFilter::CTexturedQuadFilter(CCameraFilterPass::EFilterType type, m_tex = tex; } -void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale) +void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect) +{ + Vert verts[4] = + { + {{0.f, 0.f}, {0.f, 0.f}}, + {{0.f, 1.f}, {0.f, 1.f}}, + {{1.f, 0.f}, {1.f, 0.f}}, + {{1.f, 1.f}, {1.f, 1.f}}, + }; + m_vbo->load(verts, sizeof(verts)); + + m_uniform.m_matrix[0][0] = rect.size.x * 2.f; + m_uniform.m_matrix[1][1] = rect.size.y * 2.f; + m_uniform.m_matrix[3][0] = rect.position.x * 2.f - 1.f; + m_uniform.m_matrix[3][1] = rect.position.y * 2.f - 1.f; + m_uniform.m_color = color; + m_uniform.m_uvScale = uvScale; + m_uniBuf->load(&m_uniform, sizeof(m_uniform)); + + CGraphics::g_BooMainCommandQueue->setShaderDataBinding(m_dataBind); + CGraphics::g_BooMainCommandQueue->draw(0, 4); +} + +void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) { float xFac = CGraphics::g_CroppedViewport.xc_width / float(CGraphics::g_ViewportResolution.x); float yFac = CGraphics::g_CroppedViewport.x10_height / float(CGraphics::g_ViewportResolution.y); @@ -47,6 +75,29 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale) CGraphics::g_BooMainCommandQueue->draw(0, 4); } +const zeus::CRectangle CTexturedQuadFilter::DefaultRect = {0.f, 0.f, 1.f, 1.f}; + URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) +CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex) +: CTexturedQuadFilter(tex) +{ + m_token = CGraphics::g_BooFactory->commitTransaction([&](boo::IGraphicsDataFactory::Context& ctx) -> bool + { + m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4); + m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); + m_dataBind = TMultiBlendShader::BuildShaderDataBinding(ctx, type, *this); + return true; + }); +} + +CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, + TLockedToken tex) +: CTexturedQuadFilterAlpha(type, tex->GetBooTexture()) +{ + m_tex = tex; +} + +URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha) + } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp index 5e14bce71..ac613bc2c 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilter.hpp @@ -4,6 +4,7 @@ #include "TMultiBlendShader.hpp" #include "zeus/CMatrix4f.hpp" #include "zeus/CColor.hpp" +#include "zeus/CRectangle.hpp" #include "Camera/CCameraFilter.hpp" #include "CToken.hpp" @@ -17,6 +18,7 @@ class CTexturedQuadFilter friend struct CTexturedQuadFilterMetalDataBindingFactory; friend struct CTexturedQuadFilterD3DDataBindingFactory; +protected: struct Vert { zeus::CVector2f m_pos; @@ -25,6 +27,7 @@ class CTexturedQuadFilter struct Uniform { + zeus::CMatrix4f m_matrix; zeus::CColor m_color; float m_uvScale; }; @@ -36,16 +39,33 @@ class CTexturedQuadFilter boo::IShaderDataBinding* m_dataBind = nullptr; Uniform m_uniform; + CTexturedQuadFilter(boo::ITexture* tex); public: + static const zeus::CRectangle DefaultRect; CTexturedQuadFilter(CCameraFilterPass::EFilterType type, TLockedToken tex); CTexturedQuadFilter(CCameraFilterPass::EFilterType type, boo::ITexture* tex); - void draw(const zeus::CColor& color, float uvScale); + void draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect=DefaultRect); + void drawCropped(const zeus::CColor& color, float uvScale); const TLockedToken& GetTex() const { return m_tex; } using _CLS = CTexturedQuadFilter; #include "TMultiBlendShaderDecl.hpp" }; +class CTexturedQuadFilterAlpha : public CTexturedQuadFilter +{ + friend struct CTexturedQuadFilterAlphaGLDataBindingFactory; + friend struct CTexturedQuadFilterAlphaVulkanDataBindingFactory; + friend struct CTexturedQuadFilterAlphaMetalDataBindingFactory; + friend struct CTexturedQuadFilterAlphaD3DDataBindingFactory; + +public: + CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, TLockedToken tex); + CTexturedQuadFilterAlpha(CCameraFilterPass::EFilterType type, boo::ITexture* tex); + using _CLS = CTexturedQuadFilterAlpha; +#include "TMultiBlendShaderDecl.hpp" +}; + } #endif // __URDE_CTEXTUREDQUADFILTER_HPP__ diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index a569864ac..29d8990da 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -13,6 +13,7 @@ BOO_GLSL_BINDING_HEAD "\n" "UBINDING0 uniform TexuredQuadUniform\n" "{\n" +" mat4 mtx;\n" " vec4 color;\n" " float uvScale;\n" "};\n" @@ -28,7 +29,7 @@ BOO_GLSL_BINDING_HEAD "{\n" " vtf.color = color;\n" " vtf.uv = uvIn.xy * uvScale;\n" -" gl_Position = vec4(posIn.xyz, 1.0);\n" +" gl_Position = mtx * vec4(posIn.xyz, 1.0);\n" "}\n"; static const char* FS = @@ -48,6 +49,23 @@ BOO_GLSL_BINDING_HEAD " colorOut = vtf.color * vec4(texture(tex, vtf.uv).rgb, 1.0);\n" "}\n"; +static const char* FSAlpha = +"#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" +" colorOut = vtf.color * texture(tex, vtf.uv);\n" +"}\n"; + URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) struct CTexturedQuadFilterGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory @@ -133,4 +151,89 @@ CTexturedQuadFilter::Initialize(boo::VulkanDataFactory::Context& ctx, } #endif +URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilterAlpha) + +struct CTexturedQuadFilterAlphaGLDataBindingFactory : TMultiBlendShader::IDataBindingFactory +{ + boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, + boo::IShaderPipeline* pipeline, + boo::IVertexFormat*, + CTexturedQuadFilterAlpha& filter) + { + boo::GLDataFactory::Context& cctx = static_cast(ctx); + + const boo::VertexElementDescriptor VtxVmt[] = + { + {filter.m_vbo, nullptr, boo::VertexSemantic::Position4}, + {filter.m_vbo, nullptr, boo::VertexSemantic::UV4} + }; + boo::IGraphicsBuffer* bufs[] = {filter.m_uniBuf}; + boo::PipelineStage stages[] = {boo::PipelineStage::Vertex}; + boo::ITexture* texs[] = {filter.m_booTex}; + return cctx.newShaderDataBinding(pipeline, + ctx.newVertexFormat(2, VtxVmt), filter.m_vbo, nullptr, nullptr, + 1, bufs, stages, nullptr, nullptr, 1, texs); + } +}; + +#if BOO_HAS_VULKAN +struct CTexturedQuadFilterAlphaVulkanDataBindingFactory : TMultiBlendShader::IDataBindingFactory +{ + boo::IShaderDataBinding* BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, + boo::IShaderPipeline* pipeline, + boo::IVertexFormat* vtxFmt, + 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, + filter.m_vbo, nullptr, nullptr, 1, bufs, + nullptr, nullptr, nullptr, 1, texs); + } +}; +#endif + +TMultiBlendShader::IDataBindingFactory* +CTexturedQuadFilterAlpha::Initialize(boo::GLDataFactory::Context& ctx, + boo::IShaderPipeline*& alphaPipeOut, + boo::IShaderPipeline*& additivePipeOut, + boo::IShaderPipeline*& colorMultiplyPipeOut) +{ + const char* texNames[] = {"tex"}; + const char* uniNames[] = {"TexuredQuadUniform"}; + alphaPipeOut = ctx.newShaderPipeline(VS, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + additivePipeOut = ctx.newShaderPipeline(VS, FSAlpha, 1, texNames, 1, uniNames, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + colorMultiplyPipeOut = ctx.newShaderPipeline(VS, 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) +{ + const boo::VertexElementDescriptor VtxVmt[] = + { + {nullptr, nullptr, boo::VertexSemantic::Position4}, + {nullptr, nullptr, boo::VertexSemantic::UV4} + }; + vtxFmtOut = ctx.newVertexFormat(2, VtxVmt); + alphaPipeOut = ctx.newShaderPipeline(VS, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips, false, false, false); + additivePipeOut = ctx.newShaderPipeline(VS, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcAlpha, + boo::BlendFactor::One, boo::Primitive::TriStrips, false, false, false); + colorMultiplyPipeOut = ctx.newShaderPipeline(VS, FSAlpha, vtxFmtOut, boo::BlendFactor::SrcColor, + boo::BlendFactor::DstColor, boo::Primitive::TriStrips, false, false, false); + return new CTexturedQuadFilterAlphaVulkanDataBindingFactory; +} +#endif + } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp index ce26a47ff..3e7707b98 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp @@ -14,6 +14,7 @@ static const char* VS = "\n" "cbuffer TexuredQuadUniform : register(b0)\n" "{\n" +" float4x4 mat;\n" " float4 color;\n" "};\n" "\n" @@ -30,7 +31,7 @@ static const char* VS = " vtf.color = color;\n" " vtf.uv = v.uvIn.xy;\n" " vtf.uv.y = -vtf.uv.y;\n" -" vtf.position = float4(v.posIn.xyz, 1.0);\n" +" vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " return vtf;\n" "}\n"; diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp index 8afa34921..89176ea6c 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterMetal.cpp @@ -16,6 +16,7 @@ static const char* VS = "\n" "struct TexuredQuadUniform\n" "{\n" +" float4x4 mat;\n" " float4 color;\n" "};\n" "\n" @@ -32,7 +33,7 @@ static const char* VS = " vtf.color = tqu.color;\n" " vtf.uv = v.uvIn.xy;\n" " vtf.uv.y = -vtf.uv.y;\n" -" vtf.position = float4(v.posIn.xyz, 1.0);\n" +" vtf.position = tqu.mat * float4(v.posIn.xyz, 1.0);\n" " return vtf;\n" "}\n"; diff --git a/Runtime/GuiSys/CConsoleOutputWindow.cpp b/Runtime/GuiSys/CConsoleOutputWindow.cpp index e69de29bb..b86f5c10b 100644 --- a/Runtime/GuiSys/CConsoleOutputWindow.cpp +++ b/Runtime/GuiSys/CConsoleOutputWindow.cpp @@ -0,0 +1,20 @@ +#include "CConsoleOutputWindow.hpp" + +namespace urde +{ + +CConsoleOutputWindow::CConsoleOutputWindow(int, float, float) +: CIOWin("Console Output Window") +{ +} + +CIOWin::EMessageReturn CConsoleOutputWindow::OnMessage(const CArchitectureMessage&, CArchitectureQueue&) +{ + return EMessageReturn::Normal; +} + +void CConsoleOutputWindow::Draw() const +{ +} + +} diff --git a/Runtime/GuiSys/CConsoleOutputWindow.hpp b/Runtime/GuiSys/CConsoleOutputWindow.hpp index 3e14a3693..acfe77ef5 100644 --- a/Runtime/GuiSys/CConsoleOutputWindow.hpp +++ b/Runtime/GuiSys/CConsoleOutputWindow.hpp @@ -1,11 +1,17 @@ #ifndef __URDE_CCONSOLEOUTPUTWINDOW_HPP__ #define __URDE_CCONSOLEOUTPUTWINDOW_HPP__ +#include "CIOWin.hpp" + namespace urde { -class CConsoleOutputWindow +class CConsoleOutputWindow : public CIOWin { +public: + CConsoleOutputWindow(int, float, float); + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&); + void Draw() const; }; } diff --git a/Runtime/GuiSys/CErrorOutputWindow.cpp b/Runtime/GuiSys/CErrorOutputWindow.cpp new file mode 100644 index 000000000..7b07b0f62 --- /dev/null +++ b/Runtime/GuiSys/CErrorOutputWindow.cpp @@ -0,0 +1,24 @@ +#include "CErrorOutputWindow.hpp" + +namespace urde +{ + +CErrorOutputWindow::CErrorOutputWindow(bool flag) +: CIOWin("Error Output Window") +{ + x18_25_ = true; + x18_26_ = true; + x18_27_ = true; + x18_28_ = flag; +} + +CIOWin::EMessageReturn CErrorOutputWindow::OnMessage(const CArchitectureMessage&, CArchitectureQueue&) +{ + return EMessageReturn::Normal; +} + +void CErrorOutputWindow::Draw() const +{ +} + +} diff --git a/Runtime/GuiSys/CErrorOutputWindow.hpp b/Runtime/GuiSys/CErrorOutputWindow.hpp new file mode 100644 index 000000000..98ec2a627 --- /dev/null +++ b/Runtime/GuiSys/CErrorOutputWindow.hpp @@ -0,0 +1,43 @@ +#ifndef __URDE_CERROROUTPUTWINDOW_HPP__ +#define __URDE_CERROROUTPUTWINDOW_HPP__ + +#include "CIOWin.hpp" +#include "RetroTypes.hpp" + +namespace urde +{ + +class CErrorOutputWindow : public CIOWin +{ +public: + enum class State + { + Zero, + One, + Two + }; +private: + State x14_state = State::Zero; + union + { + struct + { + bool x18_24_; + bool x18_25_; + bool x18_26_; + bool x18_27_; + bool x18_28_; + }; + u16 dummy = 0; + }; + const wchar_t* x1c_msg; +public: + CErrorOutputWindow(bool); + EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&); + bool GetIsContinueDraw() const { return int(x14_state) < 2; } + void Draw() const; +}; + +} + +#endif // __URDE_CERROROUTPUTWINDOW_HPP__ diff --git a/Runtime/GuiSys/CMakeLists.txt b/Runtime/GuiSys/CMakeLists.txt index e87a30579..a7ca2e759 100644 --- a/Runtime/GuiSys/CMakeLists.txt +++ b/Runtime/GuiSys/CMakeLists.txt @@ -13,6 +13,8 @@ set(GUISYS_SOURCES CAuiMeter.hpp CConsoleOutputWindow.cpp CConsoleOutputWindow.hpp + CErrorOutputWindow.cpp + CErrorOutputWindow.hpp CGuiAnimBase.cpp CGuiAnimBase.hpp CGuiAnimController.cpp diff --git a/Runtime/GuiSys/CSplashScreen.cpp b/Runtime/GuiSys/CSplashScreen.cpp index 3b2b818d3..914e51312 100644 --- a/Runtime/GuiSys/CSplashScreen.cpp +++ b/Runtime/GuiSys/CSplashScreen.cpp @@ -65,7 +65,14 @@ void CSplashScreen::Draw() const else if (x18_splashTimeout < 0.5f) color.a = x18_splashTimeout * 2.f; - const_cast(m_quad).draw(color, 1.f); + zeus::CRectangle rect; + float aspect = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y); + rect.size.x = m_quad.GetTex()->GetWidth() / (640.f * aspect); + rect.size.y = m_quad.GetTex()->GetHeight() / 480.f; + rect.position.x = 0.5f - rect.size.x / 2.f; + rect.position.y = 0.5f - rect.size.y / 2.f; + + const_cast(m_quad).draw(color, 1.f, rect); } } diff --git a/Runtime/GuiSys/CSplashScreen.hpp b/Runtime/GuiSys/CSplashScreen.hpp index 87e1a5319..f1ce1a5d3 100644 --- a/Runtime/GuiSys/CSplashScreen.hpp +++ b/Runtime/GuiSys/CSplashScreen.hpp @@ -31,7 +31,7 @@ private: //EProgressivePhase x20_progressivePhase = EProgressivePhase::Before; //bool x24_progressiveSelection = true; bool x25_textureLoaded = false; - CTexturedQuadFilter m_quad; + CTexturedQuadFilterAlpha m_quad; public: CSplashScreen(ESplashScreen); EMessageReturn OnMessage(const CArchitectureMessage&, CArchitectureQueue&); diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 7aceae88c..9e090939e 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -18,15 +18,83 @@ URDE_DECL_SPECIALIZE_SHADER(CCameraBlurFilter) 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) namespace MP1 { +CGameArchitectureSupport::CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend) +: m_audioSys(backend, 0,0,0,0,0), + m_inputGenerator(0.0f /*g_tweakPlayer->GetLeftLogicalThreshold()*/, + 0.0f /*g_tweakPlayer->GetRightLogicalThreshold()*/), + m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) +{ + g_GuiSys = &m_guiSys; + m_inputGenerator.startScanning(); + g_Main->ResetGameState(); + + std::shared_ptr splash = std::make_shared(CSplashScreen::ESplashScreen::Nintendo); + m_ioWinManager.AddIOWin(splash, 1000, 10000); + + std::shared_ptr mf = std::make_shared(); + m_ioWinManager.AddIOWin(mf, 0, 0); + + std::shared_ptr console = std::make_shared(8, 5.f, 0.75f); + m_ioWinManager.AddIOWin(console, 100, 0); + + std::shared_ptr audState = std::make_shared(); + m_ioWinManager.AddIOWin(audState, 100, -1); + + std::shared_ptr errWin = std::make_shared(false); + m_ioWinManager.AddIOWin(errWin, 10000, 100000); +} + +bool CGameArchitectureSupport::Update() +{ + bool finished = false; + m_inputGenerator.Update(1.0 / 60.0, m_archQueue); + + g_GameState->GetWorldTransitionManager()->TouchModels(); + int unk = 0; + m_archQueue.Push(std::move(MakeMsg::CreateFrameBegin(EArchMsgTarget::Game, unk))); + m_archQueue.Push(std::move(MakeMsg::CreateTimerTick(EArchMsgTarget::Game, 1.f / 60.f))); + + m_ioWinManager.PumpMessages(m_archQueue); + + /* + while (m_archQueue) + { + CArchitectureMessage msg = m_archQueue.Pop(); + if (msg.GetTarget() == EArchMsgTarget::ArchitectureSupport) + { + if (msg.GetType() == EArchMsgType::ApplicationExit) + finished = true; + } + + if (msg.GetTarget() == EArchMsgTarget::Game && msg.GetType() == EArchMsgType::UserInput) + { + const CArchMsgParmUserInput* input = msg.GetParm(); + if (input->x4_parm.DStart()) + m_archQueue.Push(std::move(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport))); + } + } + */ + return finished; +} + +void CGameArchitectureSupport::Draw() +{ + m_ioWinManager.Draw(); +} + CMain::CMain(IFactory& resFactory, CSimplePool& resStore, boo::IGraphicsDataFactory* gfxFactory, boo::IGraphicsCommandQueue* cmdQ, - boo::ITextureR* spareTex) -: m_booSetter(gfxFactory, cmdQ, spareTex), x128_globalObjects(resFactory, resStore) + boo::ITextureR* spareTex, + amuse::IBackendVoiceAllocator& backend) +: m_booSetter(gfxFactory, cmdQ, spareTex), + x128_globalObjects(resFactory, resStore), + m_archSupport(backend) { xe4_gameplayResult = EGameplayResult::Playing; g_Main = this; @@ -44,6 +112,7 @@ CMain::BooSetter::BooSetter(boo::IGraphicsDataFactory* factory, TShader::Initialize(); TMultiBlendShader::Initialize(); TMultiBlendShader::Initialize(); + TMultiBlendShader::Initialize(); } void CMain::RegisterResourceTweaks() @@ -88,6 +157,11 @@ bool CMain::Proc() return xe8_b24_finished; } +void CMain::Draw() +{ + m_archSupport.Draw(); +} + void CMain::Shutdown() { TShader::Shutdown(); @@ -97,6 +171,7 @@ void CMain::Shutdown() TShader::Shutdown(); TMultiBlendShader::Shutdown(); TMultiBlendShader::Shutdown(); + TMultiBlendShader::Shutdown(); } #if MP1_USE_BOO diff --git a/Runtime/MP1/MP1.hpp b/Runtime/MP1/MP1.hpp index b4a5eff83..84cffa2d3 100644 --- a/Runtime/MP1/MP1.hpp +++ b/Runtime/MP1/MP1.hpp @@ -30,6 +30,7 @@ #include "GuiSys/CSplashScreen.hpp" #include "CMainFlow.hpp" #include "GuiSys/CConsoleOutputWindow.hpp" +#include "GuiSys/CErrorOutputWindow.hpp" #include "GuiSys/CTextParser.hpp" #include "Audio/CAudioStateWin.hpp" #include "GameGlobalObjects.hpp" @@ -111,10 +112,6 @@ class CGameArchitectureSupport CInputGenerator m_inputGenerator; CGuiSys m_guiSys; CIOWinManager m_ioWinManager; - //CSplashScreen m_splashScreen; - CMainFlow m_mainFlow; - CConsoleOutputWindow m_consoleWindow; - CAudioStateWin m_audioStateWin; boo::SWindowRect m_windowRect; bool m_rectIsDirty; @@ -148,46 +145,9 @@ class CGameArchitectureSupport } public: - CGameArchitectureSupport() - : m_audioSys(0,0,0,0,0), - m_inputGenerator(0.0f /*g_tweakPlayer->GetLeftLogicalThreshold()*/, - 0.0f /*g_tweakPlayer->GetRightLogicalThreshold()*/), - m_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero) - { - g_GuiSys = &m_guiSys; - m_inputGenerator.startScanning(); - } - bool Update() - { - bool finished = false; - m_inputGenerator.Update(1.0 / 60.0, m_archQueue); - - g_GameState->GetWorldTransitionManager()->TouchModels(); - int unk = 0; - m_archQueue.Push(std::move(MakeMsg::CreateFrameBegin(EArchMsgTarget::Game, unk))); - - m_ioWinManager.PumpMessages(m_archQueue); - - /* - while (m_archQueue) - { - CArchitectureMessage msg = m_archQueue.Pop(); - if (msg.GetTarget() == EArchMsgTarget::ArchitectureSupport) - { - if (msg.GetType() == EArchMsgType::ApplicationExit) - finished = true; - } - - if (msg.GetTarget() == EArchMsgTarget::Game && msg.GetType() == EArchMsgType::UserInput) - { - const CArchMsgParmUserInput* input = msg.GetParm(); - if (input->x4_parm.DStart()) - m_archQueue.Push(std::move(MakeMsg::CreateApplicationExit(EArchMsgTarget::ArchitectureSupport))); - } - } - */ - return finished; - } + CGameArchitectureSupport(amuse::IBackendVoiceAllocator& backend); + bool Update(); + void Draw(); bool isRectDirty() { return m_rectIsDirty; } const boo::SWindowRect& getWindowRect() @@ -275,7 +235,8 @@ public: CMain(IFactory& resFactory, CSimplePool& resStore, boo::IGraphicsDataFactory* gfxFactory, boo::IGraphicsCommandQueue* cmdQ, - boo::ITextureR* spareTex); + boo::ITextureR* spareTex, + amuse::IBackendVoiceAllocator& backend); void RegisterResourceTweaks(); void ResetGameState(); void StreamNewGameState(CInputStream&); @@ -285,6 +246,7 @@ public: void Init(const hecl::Runtime::FileStoreManager& storeMgr, boo::IAudioVoiceEngine* voiceEngine); bool Proc(); + void Draw(); void Shutdown(); bool CheckReset(); diff --git a/Runtime/World/CWorldTransManager.cpp b/Runtime/World/CWorldTransManager.cpp index 9f161f44f..0e3383066 100644 --- a/Runtime/World/CWorldTransManager.cpp +++ b/Runtime/World/CWorldTransManager.cpp @@ -242,7 +242,7 @@ void CWorldTransManager::DrawEnabled() CGraphics::ResolveSpareTexture(rect); CGraphics::g_BooMainCommandQueue->clearTarget(true, true); DrawSecondPass(); - m_dissolve.draw(zeus::CColor{1.f, 1.f, 1.f, 1.f - t}, 1.f); + m_dissolve.drawCropped(zeus::CColor{1.f, 1.f, 1.f, 1.f - t}, 1.f); } CWideScreenFilter::SetViewportToFull();