2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 12:27:43 +00:00

Big fixes and big memory leak refactor (linux only for now)

This commit is contained in:
Jack Andersen
2018-05-19 20:14:57 -10:00
parent 5f03362149
commit f60af632b3
84 changed files with 849 additions and 689 deletions

View File

@@ -712,7 +712,7 @@ CBooRenderer::CBooRenderer(IObjectStore& store, IFactory& resFac)
m_staticEntropy = store.GetObj("RandomStaticEntropy");
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
GenerateFogVolumeRampTex(ctx);
GenerateSphereRampTex(ctx);

View File

@@ -334,10 +334,17 @@ public:
return g_BooPlatformName;
}
static void CommitResources(const boo::FactoryCommitFunc& commitFunc)
static void CommitResources(const boo::FactoryCommitFunc& commitFunc __BooTraceArgs)
{
g_BooFactory->commitTransaction(commitFunc);
g_BooFactory->commitTransaction(commitFunc __BooTraceArgsUse);
}
#ifndef NDEBUG
#define CGraphicsCommitResources(...) CGraphics::CommitResources(__VA_ARGS__, __FILE__, __LINE__)
#else
#define CGraphicsCommitResources(...) CGraphics::CommitResources(__VA_ARGS__)
#endif
static void SetShaderDataBinding(const boo::ObjToken<boo::IShaderDataBinding>& binding)
{
g_BooMainCommandQueue->setShaderDataBinding(binding);

View File

@@ -25,7 +25,7 @@ hecl::UniformBufferPool<CLineRenderer::SDrawUniform> CLineRenderer::s_uniformPoo
CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
EPrimitiveMode mode, u32 maxVerts,
const boo::ObjToken<boo::ITexture>& texture,
bool additive, bool zTest)
bool additive, bool zTest, bool zGEqual)
: m_mode(mode), m_maxVerts(maxVerts)
{
if (maxVerts < 2)
@@ -56,12 +56,12 @@ CLineRenderer::CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
}
CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts,
const boo::ObjToken<boo::ITexture>& texture,
bool additive, bool zTest)
bool additive, bool zTest, bool zGEqual)
: m_mode(mode), m_maxVerts(maxVerts)
{
if (maxVerts < 2)
@@ -92,9 +92,9 @@ CLineRenderer::CLineRenderer(EPrimitiveMode mode, u32 maxVerts,
m_uniformBuf = s_uniformPool.allocateBlock(CGraphics::g_BooFactory);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest);
CLineRendererShaders::BuildShaderDataBinding(ctx, *this, texture, additive, zTest, zGEqual);
return true;
});
}

View File

@@ -74,9 +74,9 @@ public:
CLineRenderer(boo::IGraphicsDataFactory::Context& ctx,
EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture,
bool additive, bool zTest = false);
bool additive, bool zTest = false, bool zGEqual = false);
CLineRenderer(EPrimitiveMode mode, u32 maxVerts, const boo::ObjToken<boo::ITexture>& texture,
bool additive, bool zTest = false);
bool additive, bool zTest = false, bool zGEqual = false);
CLineRenderer(CLineRenderer&&) = default;
void Reset();

View File

@@ -271,6 +271,8 @@ public:
static void SetDummyTextures(bool b) { g_DummyTextures = b; }
static void SetRenderModelBlack(bool b) { g_RenderModelBlack = b; }
static void AssertAllFreed();
};
class CModel
@@ -285,8 +287,8 @@ class CModel
std::vector<CBooSurface> x8_surfaces;
std::vector<SShader> x18_matSets;
std::unique_ptr<CBooModel> x28_modelInst;
CModel* x30_next = nullptr;
CModel* x34_prev = nullptr;
//CModel* x30_next = nullptr;
//CModel* x34_prev = nullptr;
int x38_lastFrame;
/* urde addition: boo! */

View File

@@ -19,6 +19,11 @@ bool CBooModel::g_DrawingOccluders = false;
static CBooModel* g_FirstModel = nullptr;
void CBooModel::AssertAllFreed()
{
assert(g_FirstModel == nullptr && "Dangling CBooModels detected");
}
void CBooModel::ClearModelUniformCounters()
{
for (CBooModel* model = g_FirstModel ; model ; model = model->m_next)
@@ -281,7 +286,7 @@ CBooModel::ModelInstance* CBooModel::PushNewModelInstance(int sharedLayoutBuf)
m_instances.emplace_back();
ModelInstance& newInst = m_instances.back();
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
/* Build geometry uniform buffer if shared not available */
boo::ObjToken<boo::IGraphicsBufferD> geomUniformBuf;
@@ -1197,8 +1202,8 @@ std::unique_ptr<CBooModel> CModel::MakeNewInstance(int shaderIdx, int subInsts,
if (shaderIdx >= x18_matSets.size())
shaderIdx = 0;
auto ret = std::make_unique<CBooModel>(m_selfToken, this, &x8_surfaces, x18_matSets[shaderIdx],
m_staticVtxFmt, m_staticVbo, m_ibo,
m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
m_staticVtxFmt, m_staticVbo, m_ibo,
m_aabb, (m_flags & 0x2) != 0, subInsts, txtrOverrides);
if (lockParent)
ret->LockParent();
return ret;
@@ -1275,7 +1280,7 @@ CModel::CModel(std::unique_ptr<u8[]>&& in, u32 /* dataLen */, IObjectStore* stor
matSet.BuildShaders(m_hmdlMeta);
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
/* Index buffer is always static */
if (m_hmdlMeta.indexCount)

View File

@@ -198,7 +198,7 @@ static const char* TexNames[] = {"texY", "texU", "texV"};
void CMoviePlayer::Initialize()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
if (!ctx.bindingNeedsVertexFormat())
{
@@ -426,7 +426,7 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
xa0_bufferQueue.reserve(xf0_preLoadFrames);
/* All set for GPU resources */
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_blockBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(m_viewVertBlock), 1);
m_vertBuf = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(specter::View::TexShaderVert), 4);

View File

@@ -14,7 +14,7 @@ CRainSplashGenerator::CRainSplashGenerator(const zeus::CVector3f& scale, u32 max
x48_24 = false;
x48_25_raining = true;
x0_rainSplashes.reserve(maxSplashes);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
for (int i=0 ; i<maxSplashes ; ++i)
x0_rainSplashes.emplace_back(ctx);

View File

@@ -112,7 +112,7 @@ void CTexture::BuildI4FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -160,7 +160,7 @@ void CTexture::BuildI8FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -209,7 +209,7 @@ void CTexture::BuildIA4FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -258,7 +258,7 @@ void CTexture::BuildIA8FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -366,7 +366,7 @@ void CTexture::BuildC4FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -410,7 +410,7 @@ void CTexture::BuildC8FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -462,7 +462,7 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -519,7 +519,7 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -576,7 +576,7 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * 4).get();
@@ -640,7 +640,7 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1,
boo::TextureClampMode::Repeat, buf.get(), blockCount * 8).get();
@@ -656,7 +656,7 @@ void CTexture::BuildRGBA8(const void* data, size_t length)
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
length, expectedSize);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, data, expectedSize).get();
@@ -671,7 +671,7 @@ void CTexture::BuildC8(const void* data, size_t length)
Log.report(logvisor::Fatal, "insufficient TXTR length (%" PRISize "/%" PRISize ")",
length, texelCount);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
uint32_t nentries = hecl::SBig(*reinterpret_cast<const uint32_t*>(data));
const u8* paletteTexels = reinterpret_cast<const u8*>(data) + 4;
@@ -778,7 +778,7 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype)
h /= 2;
}
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticArrayTexture(x4_w, x6_h, layerCount, x8_mips, boo::TextureFormat::RGBA8,
boo::TextureClampMode::Repeat, buf.get(), texelCount * layerCount * 4).get();
@@ -788,7 +788,7 @@ void CTexture::BuildC8Font(const void* data, EFontType ftype)
void CTexture::BuildDXT1(const void* data, size_t length)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_booTex = ctx.newStaticTexture(x4_w, x6_h, x8_mips, boo::TextureFormat::DXT1,
boo::TextureClampMode::Repeat, data, length).get();

View File

@@ -6,7 +6,7 @@ namespace urde
CAABoxShader::CAABoxShader(bool zOnly)
: m_zOnly(zOnly)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector3f), 34);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);

View File

@@ -5,7 +5,7 @@ namespace urde
CCameraBlurFilter::CCameraBlurFilter()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);

View File

@@ -5,7 +5,7 @@ namespace urde
CColoredQuadFilter::CColoredQuadFilter(EFilterType type)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
struct Vert
{

View File

@@ -21,7 +21,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
{
m_maxVerts = totalVerts;
m_tex = tex;
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), m_maxVerts);
for (int i=0 ; i<3 ; ++i)

View File

@@ -99,7 +99,7 @@ boo::ObjToken<boo::IShaderPipeline> CFluidPlaneShader::Cache::GetOrBuildShader(c
if (CGraphics::g_BooFactory == nullptr)
return nullptr;
CGraphics::CommitResources(
CGraphicsCommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx)
{
switch (ctx.platform())
@@ -148,7 +148,7 @@ void CFluidPlaneShader::Cache::Clear()
void CFluidPlaneShader::PrepareBinding(const boo::ObjToken<boo::IShaderPipeline>& pipeline, u32 maxVertCount, bool door)
{
CGraphics::CommitResources(
CGraphicsCommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Vertex), maxVertCount);

View File

@@ -5,7 +5,7 @@ namespace urde
CFogVolumeFilter::CFogVolumeFilter()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
struct Vert
{

View File

@@ -6,7 +6,7 @@ namespace urde
void CFogVolumePlaneShader::CommitResources(size_t capacity)
{
m_vertCapacity = capacity;
CGraphics::CommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([this, capacity](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(zeus::CVector4f), capacity);
TShader<CFogVolumePlaneShader>::BuildShaderDataBinding(ctx, *this);

View File

@@ -15,6 +15,8 @@ boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_texAdditiveZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlphaZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAdditiveZ;
boo::ObjToken<boo::IShaderPipeline> CLineRendererShaders::m_noTexAlphaZGEqual;
boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_texVtxFmt;
boo::ObjToken<boo::IVertexFormat> CLineRendererShaders::m_noTexVtxFmt;
@@ -25,8 +27,8 @@ void CLineRendererShaders::Initialize()
if (!CGraphics::g_BooFactory)
return;
CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx)
{
switch (ctx.platform())
{
@@ -67,6 +69,7 @@ void CLineRendererShaders::Shutdown()
m_texAdditiveZ.reset();
m_noTexAlphaZ.reset();
m_noTexAdditiveZ.reset();
m_noTexAlphaZGEqual.reset();
m_texVtxFmt.reset();
m_noTexVtxFmt.reset();
}
@@ -74,10 +77,15 @@ void CLineRendererShaders::Shutdown()
void CLineRendererShaders::BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx,
CLineRenderer& renderer,
const boo::ObjToken<boo::ITexture>& texture,
bool additive, bool zTest)
bool additive, bool zTest, bool zGEqual)
{
boo::ObjToken<boo::IShaderPipeline> pipeline;
if (zTest)
if (zGEqual)
{
pipeline = m_noTexAlphaZGEqual;
}
else if (zTest)
{
if (texture)
{

View File

@@ -36,6 +36,8 @@ private:
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlphaZ;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAdditiveZ;
static boo::ObjToken<boo::IShaderPipeline> m_noTexAlphaZGEqual;
static boo::ObjToken<boo::IVertexFormat> m_texVtxFmt;
static boo::ObjToken<boo::IVertexFormat> m_noTexVtxFmt;
@@ -58,7 +60,8 @@ public:
static void Initialize();
static void Shutdown();
static void BuildShaderDataBinding(boo::IGraphicsDataFactory::Context& ctx, CLineRenderer& renderer,
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest);
const boo::ObjToken<boo::ITexture>& texture, bool additive, bool zTest,
bool zGEqual);
};
}

View File

@@ -177,6 +177,11 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None);
m_noTexAlphaZGEqual = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, 0, nullptr, 1, UniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::GEqual,
false, true, false, boo::CullMode::None);
return new struct OGLLineDataBindingFactory;
}
@@ -269,6 +274,11 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None);
m_noTexAlphaZGEqual = ctx.newShaderPipeline(VS_GLSL_NOTEX, FS_GLSL_NOTEX, m_noTexVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::GEqual,
false, true, false, boo::CullMode::None);
return new struct VulkanLineDataBindingFactory;
}
#endif

View File

@@ -182,6 +182,12 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None);
m_noTexAlphaZGEqual = ctx.newShaderPipeline(VS_HLSL_NOTEX, FS_HLSL_NOTEX, nullptr, nullptr,
nullptr, m_noTexVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::GEqual,
false, true, false, boo::CullMode::None);
return new struct HLSLLineDataBindingFactory;
}

View File

@@ -190,6 +190,11 @@ CLineRendererShaders::IDataBindingFactory* CLineRendererShaders::Initialize(boo:
boo::Primitive::TriStrips, boo::ZTest::LEqual,
false, true, false, boo::CullMode::None);
m_noTexAlphaZGEqual = ctx.newShaderPipeline(VS_METAL_NOTEX, FS_METAL_NOTEX, nullptr, nullptr, m_noTexVtxFmt,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::GEqual,
false, true, false, boo::CullMode::None);
return new struct MetalLineDataBindingFactory;
}

View File

@@ -91,7 +91,7 @@ CMapSurfaceShader::Initialize(boo::GLDataFactory::Context& ctx)
const char* uniNames[] = {"MapSurfaceUniform"};
s_Pipeline = ctx.newShaderPipeline(VS, FS, 0, nullptr, 1, uniNames,
boo::BlendFactor::SrcAlpha, boo::BlendFactor::InvSrcAlpha,
boo::Primitive::TriStrips, boo::ZTest::None, false, true,
boo::Primitive::TriStrips, boo::ZTest::GEqual, false, true,
false, boo::CullMode::Backface);
return new CMapSurfaceShaderGLDataBindingFactory;
}
@@ -113,7 +113,7 @@ CMapSurfaceShader::Initialize(boo::VulkanDataFactory::Context& ctx)
s_VtxFmt = ctx.newVertexFormat(1, VtxVmt);
s_Pipeline = ctx.newShaderPipeline(VS, FS, s_VtxFmt, boo::BlendFactor::SrcAlpha,
boo::BlendFactor::InvSrcAlpha, boo::Primitive::TriStrips,
boo::ZTest::None, false, true, false, boo::CullMode::Backface);
boo::ZTest::GEqual, false, true, false, boo::CullMode::Backface);
return new CMapSurfaceShaderVulkanDataBindingFactory;
}

View File

@@ -32,7 +32,8 @@ enum EExtendedShader : uint8_t
ForcedAlphaNoZWrite,
ForcedAdditiveNoZWrite,
ForcedAlphaNoCullNoZWrite,
ForcedAdditiveNoCullNoZWrite
ForcedAdditiveNoCullNoZWrite,
DepthGEqualNoZWrite
};
class CModelShaders

View File

@@ -295,6 +295,12 @@ CModelShaders::GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat)
hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
hecl::Backend::CullMode::None, true, false, true);
/* Depth GEqual no Z-write */
ext.registerExtensionSlot({LightingGLSL, "LightingFunc"}, {MainPostGLSL, "MainPostFunc"},
3, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original,
hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::GEqual,
hecl::Backend::CullMode::Backface, true, false, true);
return ext;
}

View File

@@ -275,6 +275,12 @@ CModelShaders::GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat)
hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
hecl::Backend::CullMode::None, true, false, true);
/* Depth GEqual no Z-write */
ext.registerExtensionSlot({LightingHLSL, "LightingFunc"}, {MainPostHLSL, "MainPostFunc"},
0, nullptr, 0, nullptr, hecl::Backend::BlendFactor::Original,
hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::GEqual,
hecl::Backend::CullMode::Backface, true, false, true);
return ext;
}

View File

@@ -285,6 +285,12 @@ CModelShaders::GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat
hecl::Backend::BlendFactor::One, hecl::Backend::ZTest::Original,
hecl::Backend::CullMode::None, true, false, true);
/* Depth GEqual no Z-write */
ext.registerExtensionSlot({LightingMetal, "LightingFunc"}, {MainPostMetal, "MainPostFunc"},
1, BlockNames, 0, nullptr, hecl::Backend::BlendFactor::Original,
hecl::Backend::BlendFactor::Original, hecl::Backend::ZTest::GEqual,
hecl::Backend::CullMode::Backface, true, false, true);
return ext;
}

View File

@@ -10,7 +10,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex)
if (!m_dataBind || indTex != m_indTex)
{
m_indTex = indTex;
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
{
m_uniBufBlurX = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);

View File

@@ -12,7 +12,7 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
{
m_maxInsts = instances.size();
m_tex = tex;
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([this](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, sizeof(Instance), m_maxInsts);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CMatrix4f), 1);

View File

@@ -9,7 +9,7 @@ namespace urde
CRandomStaticFilter::CRandomStaticFilter(EFilterType type, bool cookieCutter)
: m_cookieCutter(cookieCutter)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
struct Vert
{

View File

@@ -6,7 +6,7 @@ namespace urde
CScanLinesFilter::CScanLinesFilter(EFilterType type, bool even)
: m_even(even)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
m_dataBind = TMultiBlendShader<CScanLinesFilter>::BuildShaderDataBinding(ctx, type, *this);

View File

@@ -33,7 +33,7 @@ void CSpaceWarpFilter::GenerateWarpRampTex(boo::IGraphicsDataFactory::Context& c
CSpaceWarpFilter::CSpaceWarpFilter()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
GenerateWarpRampTex(ctx);
struct Vert

View File

@@ -15,7 +15,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, const boo::ObjToken<b
{
m_flipRect = CGraphics::g_BooFactory->platform() == boo::IGraphicsDataFactory::Platform::Vulkan;
tex->setClampMode(boo::TextureClampMode::ClampToEdge);
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 16);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
@@ -157,7 +157,7 @@ URDE_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, const boo::ObjToken<boo::ITexture>& tex)
: CTexturedQuadFilter(tex)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 32, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);

View File

@@ -6,7 +6,7 @@ namespace urde
CThermalColdFilter::CThermalColdFilter()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_shiftTex = ctx.newDynamicTexture(8, 4, boo::TextureFormat::RGBA8, boo::TextureClampMode::Repeat);

View File

@@ -6,7 +6,7 @@ namespace urde
CThermalHotFilter::CThermalHotFilter()
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
struct Vert
{

View File

@@ -6,7 +6,7 @@ namespace urde
CWorldShadowShader::CWorldShadowShader(u32 w, u32 h)
: m_w(w), m_h(h)
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
m_vbo = ctx.newDynamicBuffer(boo::BufferUse::Vertex, 16, 4);
m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);

View File

@@ -9,7 +9,7 @@ namespace urde
CXRayBlurFilter::CXRayBlurFilter(TLockedToken<CTexture>& tex)
: m_paletteTex(tex), m_booTex(tex->GetPaletteTexture())
{
CGraphics::CommitResources([&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources([&](boo::IGraphicsDataFactory::Context& ctx)
{
struct Vert
{

View File

@@ -29,8 +29,8 @@ public:
if (!CGraphics::g_BooFactory)
return;
CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx)
{
switch (ctx.platform())
{

View File

@@ -28,8 +28,8 @@ public:
if (!CGraphics::g_BooFactory)
return;
CGraphics::CommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
CGraphicsCommitResources(
[&](boo::IGraphicsDataFactory::Context& ctx)
{
switch (ctx.platform())
{