From 80f98e1218b066a44f188be5693162021af4c595 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Fri, 24 Nov 2017 16:50:24 -1000 Subject: [PATCH] Windows fixes --- Runtime/Graphics/CGraphics.cpp | 2 +- Runtime/Graphics/CGraphics.hpp | 9 +++- Runtime/Graphics/IRenderer.hpp | 2 +- .../Shaders/CFluidPlaneShaderGLSL.cpp | 4 +- .../Shaders/CFluidPlaneShaderHLSL.cpp | 53 ++++++++++++++----- .../Shaders/CFluidPlaneShaderMetal.cpp | 2 +- .../Shaders/CTexturedQuadFilterHLSL.cpp | 1 - Runtime/MP1/MP1.cpp | 1 + hecl | 2 +- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Runtime/Graphics/CGraphics.cpp b/Runtime/Graphics/CGraphics.cpp index 1c43e4439..f937e9945 100644 --- a/Runtime/Graphics/CGraphics.cpp +++ b/Runtime/Graphics/CGraphics.cpp @@ -74,7 +74,7 @@ void CGraphics::SetFog(ERglFogMode mode, float startz, float endz, const zeus::C if (mode == ERglFogMode::None) { g_Fog.m_start = 4096.f; - g_Fog.m_rangeScale = 1.f; + g_Fog.m_rangeScale = 0.f; } else { diff --git a/Runtime/Graphics/CGraphics.hpp b/Runtime/Graphics/CGraphics.hpp index dbe74a356..531e276b3 100644 --- a/Runtime/Graphics/CGraphics.hpp +++ b/Runtime/Graphics/CGraphics.hpp @@ -223,7 +223,7 @@ public: struct CFogState { zeus::CColor m_color; - float m_rangeScale = 1.f; + float m_rangeScale = 0.f; float m_start = 4096.f; }; @@ -313,6 +313,13 @@ public: g_SpareTexture = spareTex; } + static void ShutdownBoo() + { + g_BooFactory = nullptr; + g_BooMainCommandQueue = nullptr; + g_SpareTexture.reset(); + } + static const boo::SystemChar* PlatformName() { return g_BooPlatformName; diff --git a/Runtime/Graphics/IRenderer.hpp b/Runtime/Graphics/IRenderer.hpp index 61141de5f..b6053381f 100644 --- a/Runtime/Graphics/IRenderer.hpp +++ b/Runtime/Graphics/IRenderer.hpp @@ -18,7 +18,7 @@ class CLight; class CAreaOctTree; class CParticleGen; class CModel; -class SShader; +struct SShader; class CSkinnedModel; class CPVSVisSet; struct CAreaRenderOctTree; diff --git a/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp b/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp index d97812c2e..5b2f8ec2b 100644 --- a/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp +++ b/Runtime/Graphics/Shaders/CFluidPlaneShaderGLSL.cpp @@ -669,7 +669,7 @@ CFluidPlaneShader::BuildBinding(boo::GLDataFactory::Context& ctx, texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); if (m_lightmap) texs[texCount++] = (*m_lightmap)->GetBooTexture(); - return ctx.newShaderDataBinding(pipeline, vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3, + return ctx.newShaderDataBinding(pipeline, vtxFmt, m_vbo.get(), nullptr, nullptr, 3, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); } @@ -699,7 +699,7 @@ CFluidPlaneShader::BuildBinding(boo::VulkanDataFactory::Context& ctx, texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); if (m_lightmap) texs[texCount++] = (*m_lightmap)->GetBooTexture(); - return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3, + return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, 3, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); } #endif diff --git a/Runtime/Graphics/Shaders/CFluidPlaneShaderHLSL.cpp b/Runtime/Graphics/Shaders/CFluidPlaneShaderHLSL.cpp index afa801673..c3634148f 100644 --- a/Runtime/Graphics/Shaders/CFluidPlaneShaderHLSL.cpp +++ b/Runtime/Graphics/Shaders/CFluidPlaneShaderHLSL.cpp @@ -66,7 +66,7 @@ static const char* FS = " float start;\n" "};\n" "\n" -"struct LightingUniform\n" +"cbuffer LightingUniform : register(b2)\n" "{\n" " Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n" " float4 ambient;\n" @@ -111,7 +111,7 @@ static const char* FS = "\n" "SamplerState samp : register(s0);\n" "%s" // Textures here -"float4 main(in VertToFrag vtf)\n" +"float4 main(in VertToFrag vtf) : SV_Target0\n" "{\n" " float4 lighting = LightingFunc(vtf.mvPos, normalize(vtf.mvNorm));\n" " float4 colorOut;\n" @@ -120,6 +120,31 @@ static const char* FS = "}\n"; static const char* FSDoor = +"struct Light\n" +"{\n" +" float4 pos;\n" +" float4 dir;\n" +" float4 color;\n" +" float4 linAtt;\n" +" float4 angAtt;\n" +"};\n" +"struct Fog\n" // Reappropriated for indirect texture scaling +"{\n" +" float4 color;\n" +" float indScale;\n" +" float start;\n" +"};\n" +"\n" +"cbuffer LightingUniform : register(b2)\n" +"{\n" +" Light lights[" _XSTR(URDE_MAX_LIGHTS) "];\n" +" float4 ambient;\n" +" float4 kColor0;\n" +" float4 kColor1;\n" +" float4 kColor2;\n" +" float4 kColor3;\n" +" Fog fog;\n" +"};\n" "struct VertToFrag\n" "{\n" " float4 pos : SV_Position;\n" @@ -133,7 +158,7 @@ static const char* FSDoor = "\n" "SamplerState samp : register(s0);\n" "%s" // Textures here -"float4 main(in VertToFrag vtf)\n" +"float4 main(in VertToFrag vtf) : SV_Target0\n" "{\n" " float4 colorOut;\n" "%s" // Combiner expression here @@ -165,19 +190,19 @@ CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidP int bumpMapUv, envBumpMapUv, envMapUv, lightmapUv; if (info.m_hasPatternTex1) - textures += hecl::Format("Texture2D patternTex1 : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D patternTex1 : register(t%d);\n", nextTex++); if (info.m_hasPatternTex2) - textures += hecl::Format("Texture2D patternTex2 : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D patternTex2 : register(t%d);\n", nextTex++); if (info.m_hasColorTex) - textures += hecl::Format("Texture2D colorTex : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D colorTex : register(t%d);\n", nextTex++); if (info.m_hasBumpMap) - textures += hecl::Format("Texture2D bumpMap : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D bumpMap : register(t%d);\n", nextTex++); if (info.m_hasEnvMap) - textures += hecl::Format("Texture2D envMap : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D envMap : register(t%d);\n", nextTex++); if (info.m_hasEnvBumpMap) - textures += hecl::Format("Texture2D envBumpMap : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D envBumpMap : register(t%d);\n", nextTex++); if (info.m_hasLightmap) - textures += hecl::Format("Texture2D lightMap : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D lightMap : register(t%d);\n", nextTex++); if (info.m_hasBumpMap) { @@ -494,11 +519,11 @@ CFluidPlaneShader::BuildShader(boo::ID3DDataFactory::Context& ctx, const SFluidP int nextTex = 0; if (info.m_hasPatternTex1) - textures += hecl::Format("Texture2D patternTex1 : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D patternTex1 : register(t%d);\n", nextTex++); if (info.m_hasPatternTex2) - textures += hecl::Format("Texture2D patternTex2 : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D patternTex2 : register(t%d);\n", nextTex++); if (info.m_hasColorTex) - textures += hecl::Format("Texture2D colorTex : register(t%d)\n", nextTex++); + textures += hecl::Format("Texture2D colorTex : register(t%d);\n", nextTex++); // Tex0 * kColor0 * Tex1 + Tex2 if (info.m_hasPatternTex1 && info.m_hasPatternTex2) @@ -558,7 +583,7 @@ CFluidPlaneShader::BuildBinding(boo::ID3DDataFactory::Context& ctx, texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); if (m_lightmap) texs[texCount++] = (*m_lightmap)->GetBooTexture(); - return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3, + return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, 3, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); } diff --git a/Runtime/Graphics/Shaders/CFluidPlaneShaderMetal.cpp b/Runtime/Graphics/Shaders/CFluidPlaneShaderMetal.cpp index 04077d523..7817fcc9b 100644 --- a/Runtime/Graphics/Shaders/CFluidPlaneShaderMetal.cpp +++ b/Runtime/Graphics/Shaders/CFluidPlaneShaderMetal.cpp @@ -612,7 +612,7 @@ boo::ObjToken CFluidPlaneShader::BuildBinding(boo::Meta texs[texCount++] = (*m_envBumpMap)->GetBooTexture(); if (m_lightmap) texs[texCount++] = (*m_lightmap)->GetBooTexture(); - return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, door ? 1 : 3, + return ctx.newShaderDataBinding(pipeline, s_vtxFmt, m_vbo.get(), nullptr, nullptr, 3, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs, nullptr, nullptr); } diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp index 8787419c8..1e9caeea6 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterHLSL.cpp @@ -64,7 +64,6 @@ static const char* VSNoFlip = " VertToFrag vtf;\n" " vtf.color = color;\n" " vtf.uv = v.uvIn.xy;\n" -" vtf.uv.y = 1.f - vtf.uv.y;\n" " vtf.lod = lod;\n" " vtf.position = mul(mat, float4(v.posIn.xyz, 1.0));\n" " return vtf;\n" diff --git a/Runtime/MP1/MP1.cpp b/Runtime/MP1/MP1.cpp index 53bce5b87..d01b6c9c6 100644 --- a/Runtime/MP1/MP1.cpp +++ b/Runtime/MP1/MP1.cpp @@ -575,6 +575,7 @@ void CMain::Shutdown() TMultiBlendShader::Shutdown(); TMultiBlendShader::Shutdown(); CFluidPlaneShader::Shutdown(); + CGraphics::ShutdownBoo(); } boo::IWindow* CMain::GetMainWindow() const diff --git a/hecl b/hecl index 191ac39ac..6c480c70f 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 191ac39ac3d7246f3ad020d75017a663f94397fa +Subproject commit 6c480c70f1f46f35658576d91241b529d19c7a61