2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-06-10 08:33:38 +00:00

CElementGenShaders, CDecalShaders fixes

Add conditions for HSH_PROFILE_MODE
This commit is contained in:
Luke Street 2020-10-21 01:12:07 -04:00
parent 2874a48166
commit c8ba49bb50
31 changed files with 157 additions and 49 deletions

View File

@ -755,9 +755,10 @@ void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering) {
ViewBlock uniform = {zeus::CMatrix4f{}, mulColor};
uniform.m_mv[0][0] = widthFac;
#if !HSH_PROFILE_MODE
m_uniBuf.load(uniform);
m_shadBind.draw(0, 4);
#endif
}
void CNESEmulator::LoadPassword(const u8* state) {

View File

@ -326,6 +326,7 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
m_final = true;
}
#if !HSH_PROFILE_MODE
m_uniformBuf.load(SDrawUniform{moduColor, CGraphics::g_Fog});
if (m_textured) {
if (!g_StaticLineVertsTex.empty()) {
@ -338,6 +339,7 @@ void CLineRenderer::Render(bool alphaWrite, const zeus::CColor& moduColor) {
m_shaderBind[alphaWrite].draw(0, g_StaticLineVertsNoTex.size());
}
}
#endif
}
} // namespace urde

View File

@ -253,7 +253,9 @@ CMoviePlayer::CMoviePlayer(const char* path, float preLoadSeconds, bool loop, bo
SetFrame({-0.5f, 0.5f, 0.f}, {-0.5f, -0.5f, 0.f}, {0.5f, -0.5f, 0.f}, {0.5f, 0.5f, 0.f});
m_viewVertBlock.m_mv = zeus::CMatrix4f{};
#if !HSH_PROFILE_MODE
m_blockBuf.load(m_viewVertBlock);
#endif
}
void CMoviePlayer::SetStaticAudioVolume(int vol) {
@ -398,7 +400,9 @@ void CMoviePlayer::SetFrame(const zeus::CVector3f& a, const zeus::CVector3f& b,
m_frame[1].m_pos = b;
m_frame[2].m_pos = d;
m_frame[3].m_pos = c;
#if !HSH_PROFILE_MODE
m_vertBuf.load(m_frame);
#endif
}
void CMoviePlayer::DrawFrame() {
@ -522,6 +526,7 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
uintptr_t planeSizeHalf = planeSize / 2;
uintptr_t planeSizeQuarter = planeSizeHalf / 2;
#if !HSH_PROFILE_MODE
if (m_deinterlace) {
/* Deinterlace into 2 discrete 60-fps half-res textures */
u8* mappedData = (u8*)tex.Y[0].map();
@ -546,6 +551,7 @@ void CMoviePlayer::DecodeFromRead(const void* data) {
tex.U.load(m_yuvBuf.get() + planeSize, planeSizeQuarter);
tex.V.load(m_yuvBuf.get() + planeSize + planeSizeQuarter, planeSizeQuarter);
}
#endif
break;
}

View File

@ -59,7 +59,9 @@ void CAABoxShader::draw(const zeus::CColor& color) {
m_uniform.m_xf = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color;
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, VertexCount);
}

View File

@ -56,7 +56,9 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
{hsh::float2{1.0, -1.0}, {xBias + xFac, yBias + yFac}},
{hsh::float2{1.0, 1.0}, {xBias + xFac, yBias}},
}};
#if !HSH_PROFILE_MODE
m_vbo.load(verts);
#endif
// m_uniform.m_uv.size()
for (size_t i = 0; i < 6; ++i) {
@ -74,7 +76,9 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
m_uniform.m_uv[i].y = amtY * yFac;
}
m_uniform.m_opacity = std::min(amount / 2.f, 1.f);
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -39,6 +39,7 @@ CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) {
SCOPED_GRAPHICS_DEBUG_GROUP("CColoredQuadFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniform.m_matrix = zeus::CMatrix4f{};
m_uniform.m_matrix[0][0] = rect.size.x() * 2.f;
m_uniform.m_matrix[1][1] = rect.size.y() * 2.f;
@ -46,6 +47,7 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
m_uniform.m_color = color;
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -56,7 +56,9 @@ void CColoredStripShader::draw(const zeus::CColor& color, size_t numVerts, const
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color;
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, numVerts);
}

View File

@ -40,16 +40,15 @@ struct CDecalShaderNoTexPipeline : pipeline<std::conditional_t<Additive, Additiv
template struct CDecalShaderNoTexPipeline<true>;
template struct CDecalShaderNoTexPipeline<false>;
hsh::binding& CDecalShaders::BuildShaderDataBinding(CQuadDecal& decal, hsh::texture2d tex) {
void CDecalShaders::BuildShaderDataBinding(hsh::binding& binding, CQuadDecal& decal, hsh::texture2d tex) {
bool additive = decal.m_desc->x18_ADD;
if (decal.m_desc->x14_TEX) {
bool redToAlpha = additive && CDecal::GetMoveRedToAlphaBuffer();
m_dataBind.hsh_tex_bind(
binding.hsh_tex_bind(
CDecalShaderTexPipeline<additive, redToAlpha>(decal.m_instBuf.get(), decal.m_uniformBuf.get(), tex));
} else {
m_dataBind.hsh_notex_bind(CDecalShaderNoTexPipeline<additive>(decal.m_instBuf.get(), decal.m_uniformBuf.get()));
binding.hsh_notex_bind(CDecalShaderNoTexPipeline<additive>(decal.m_instBuf.get(), decal.m_uniformBuf.get()));
}
return m_dataBind;
}
} // namespace urde

View File

@ -6,10 +6,8 @@ namespace urde {
struct CQuadDecal;
class CDecalShaders {
hsh::binding m_dataBind;
public:
hsh::binding& BuildShaderDataBinding(CQuadDecal& decal, hsh::texture2d tex);
static void BuildShaderDataBinding(hsh::binding& binding, CQuadDecal& decal, hsh::texture2d tex);
};
} // namespace urde

View File

@ -77,6 +77,7 @@ struct CElementGenShadersNoTexPipeline
}
};
template struct CElementGenShadersNoTexPipeline<BlendMode::Regular, false, true, false>;
template struct CElementGenShadersNoTexPipeline<BlendMode::Additive, false, true, false>;
CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen& gen) {
const auto* desc = gen.x1c_genDesc.GetObj();
@ -89,41 +90,61 @@ CElementGenShaders::EShaderClass CElementGenShaders::GetShaderClass(CElementGen&
return EShaderClass::NoTex;
}
hsh::binding& CElementGenShaders::BuildShaderDataBinding(CElementGen& gen, bool pmus) {
void CElementGenShaders::BuildShaderDataBinding(CElementGen& gen) {
const auto& desc = gen.x1c_genDesc;
BlendMode mode = BlendMode::Regular;
BlendMode pmusMode = BlendMode::Regular;
if (CElementGen::g_subtractBlend) {
mode = BlendMode::Subtract;
} else if (gen.x26c_26_AAPH) {
mode = BlendMode::Additive;
pmusMode = BlendMode::Subtract;
} else {
if (gen.x26c_26_AAPH) {
mode = BlendMode::Additive;
}
if (desc->x44_31_x31_25_PMAB) {
pmusMode = BlendMode::Additive;
}
}
hsh::vertex_buffer_typeless instBuf = pmus ? gen.m_instBufPmus.get() : gen.m_instBuf.get();
hsh::uniform_buffer_typeless uniBuf = pmus ? gen.m_uniformBufPmus.get() : gen.m_uniformBuf.get();
switch (GetShaderClass(gen)) {
case EShaderClass::Tex: {
hsh::texture2d tex = desc->x54_x40_TEXR->GetValueTexture(0)->GetBooTexture();
m_shaderBind.hsh_tex_bind(
gen.m_binding.hsh_tex_bind(
CElementGenShadersTexPipeline<mode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF,
CElementGen::sMoveRedToAlphaBuffer>(instBuf, uniBuf, tex));
CElementGen::sMoveRedToAlphaBuffer>(gen.m_instBuf.get(), gen.m_uniformBuf.get(),
tex));
if (gen.x1c_genDesc->x45_24_x31_26_PMUS)
gen.m_bindingPmus.hsh_tex_pmus_bind(
CElementGenShadersTexPipeline<pmusMode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF,
CElementGen::sMoveRedToAlphaBuffer>(gen.m_instBufPmus.get(),
gen.m_uniformBufPmus.get(), tex));
break;
}
case EShaderClass::IndTex: {
hsh::texture2d texrTex = desc->x54_x40_TEXR->GetValueTexture(0)->GetBooTexture();
hsh::texture2d tindTex = desc->x58_x44_TIND->GetValueTexture(0)->GetBooTexture();
hsh::render_texture2d sceneTex = CGraphics::g_SpareTexture.get_color(0);
m_shaderBind.hsh_indtex_bind(
gen.m_binding.hsh_indtex_bind(
CElementGenShadersIndTexPipeline<mode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF,
desc->x45_30_x32_24_CIND>(instBuf, uniBuf, texrTex, tindTex, sceneTex));
desc->x45_30_x32_24_CIND>(gen.m_instBuf.get(), gen.m_uniformBuf.get(), texrTex,
tindTex, sceneTex));
if (gen.x1c_genDesc->x45_24_x31_26_PMUS)
gen.m_bindingPmus.hsh_indtex_pmus_bind(
CElementGenShadersIndTexPipeline<pmusMode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest,
gen.x26c_27_ZBUF, desc->x45_30_x32_24_CIND>(
gen.m_instBufPmus.get(), gen.m_uniformBufPmus.get(), texrTex, tindTex, sceneTex));
break;
}
case EShaderClass::NoTex: {
m_shaderBind.hsh_notex_bind(
gen.m_binding.hsh_notex_bind(
CElementGenShadersNoTexPipeline<mode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest, gen.x26c_27_ZBUF>(
instBuf, uniBuf));
gen.m_instBuf.get(), gen.m_uniformBuf.get()));
if (gen.x1c_genDesc->x45_24_x31_26_PMUS)
gen.m_bindingPmus.hsh_notex_pmus_bind(
CElementGenShadersNoTexPipeline<pmusMode, g_Renderer->IsThermalVisorHotPass(), gen.x26c_28_zTest,
gen.x26c_27_ZBUF>(gen.m_instBufPmus.get(), gen.m_uniformBufPmus.get()));
break;
}
}
return m_shaderBind;
}
} // namespace urde

View File

@ -7,13 +7,10 @@ namespace urde {
class CElementGen;
class CElementGenShaders {
hsh::binding m_shaderBind;
public:
enum class EShaderClass { Tex, IndTex, NoTex };
static EShaderClass GetShaderClass(CElementGen& gen);
hsh::binding& BuildShaderDataBinding(CElementGen& gen, bool pmus);
static void BuildShaderDataBinding(CElementGen& gen);
};
} // namespace urde

View File

@ -42,6 +42,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
}
}
#if !HSH_PROFILE_MODE
size_t vertIter = 0;
Vertex* verts = m_vbo.map();
if (!verts0.empty()) {
@ -75,6 +76,7 @@ void CEnergyBarShader::draw(const zeus::CColor& color0, const std::vector<Vertex
m_uniBuf[2].load(m_uniform);
m_dataBind[2].draw(vertIter, verts2.size());
}
#endif
}
} // namespace urde

View File

@ -67,14 +67,18 @@ CFogVolumeFilter::CFogVolumeFilter() {
void CFogVolumeFilter::draw2WayPass(const zeus::CColor& color) {
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw2WayPass", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniBuf.load({color});
#endif
m_dataBind2Way.draw(0, 4);
}
void CFogVolumeFilter::draw1WayPass(const zeus::CColor& color) {
SCOPED_GRAPHICS_DEBUG_GROUP("CFogVolumeFilter::draw1WayPass", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniBuf.load({color});
#endif
m_dataBind1Way.draw(0, 4);
}

View File

@ -23,7 +23,9 @@ CMapSurfaceShader::CMapSurfaceShader(hsh::vertex_buffer<Vert> vbo, hsh::index_bu
void CMapSurfaceShader::draw(const zeus::CColor& color, u32 start, u32 count) {
SCOPED_GRAPHICS_DEBUG_GROUP("CMapSurfaceShader::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniBuf.load({CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), color});
#endif
m_dataBind.draw_indexed(start, count);
}

View File

@ -129,6 +129,7 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
constexpr float blurScale = 1.0f / 128.0f;
#if !HSH_PROFILE_MODE
/* X Pass */
m_uniBufBlurX.load(
{zeus::CVector4f{g_Viewport.xc_height / float(g_Viewport.x8_width) * radius * blurScale, 0.f, 0.f, 0.f}});
@ -139,11 +140,14 @@ void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
m_uniBufBlurY.load({zeus::CVector4f{0.f, radius * blurScale, 0.f, 0.f}});
m_dataBindBlurY.draw(0, 4);
CGraphics::ResolveSpareTexture(rect, 2);
#endif
}
void CPhazonSuitFilter::draw(const zeus::CColor& color, float indScale, float indOffX, float indOffY) {
SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniBuf.load({color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)});
#endif
m_dataBind.draw(0, 4);
}

View File

@ -32,8 +32,10 @@ void CRadarPaintShader::draw(const std::vector<Instance>& instances, const CText
m_dataBind.hsh_bind(CRadarPaintShaderPipeline(m_vbo.get(), m_uniBuf.get(), tex2d));
}
#if !HSH_PROFILE_MODE
m_uniBuf.load({CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f()});
m_vbo.load(instances);
#endif
m_dataBind.draw_instanced(0, 4, instances.size());
}

View File

@ -86,7 +86,9 @@ void CRandomStaticFilter::draw(const zeus::CColor& color, float t) {
m_uniform.color = color;
m_uniform.randOff = ROUND_UP_32(int64_t(rand()) * 32767 / RAND_MAX);
m_uniform.discardThres = 1.f - t;
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -34,7 +34,9 @@ void CScanLinesFilter::draw(const zeus::CColor& color) {
SCOPED_GRAPHICS_DEBUG_GROUP("CScanLinesFilter::draw", zeus::skMagenta);
m_uniform.color = color;
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 670);
}

View File

@ -161,7 +161,9 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) {
m_uniform.m_strength.x =
m_uniform.m_matrix[0][0] * m_strength * 0.5f * (clipRect.x10_height / float(clipRect.xc_width));
m_uniform.m_strength.y = m_uniform.m_matrix[1][1] * m_strength * 0.5f;
#if !HSH_PROFILE_MODE
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -65,6 +65,7 @@ CTexturedQuadFilter::CTexturedQuadFilter(EFilterType type, TLockedToken<CTexture
void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const zeus::CRectangle& rect, float z) {
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
const std::array<Vert, 4> verts{{
{{0.f, 0.f, z}, {0.f, 0.f}},
{{0.f, 1.f, z}, {0.f, uvScale}},
@ -81,6 +82,7 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
m_uniform.m_matrix[3][3] = 1.f;
m_uniform.m_color = color;
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}
@ -99,10 +101,12 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
{{1.f, -1.f, 0.f}, {(xBias + xFac) * uvScale, yBias * uvScale}},
{{1.f, 1.f, 0.f}, {(xBias + xFac) * uvScale, (yBias + yFac) * uvScale}},
}};
#if !HSH_PROFILE_MODE
m_vbo.load(verts);
m_uniform.m_color = color;
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}
@ -110,12 +114,14 @@ void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale)
void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const std::array<Vert, 4>& verts, float lod) {
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawVerts", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_vbo.load(verts);
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = color;
m_uniform.m_lod = lod;
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}
@ -123,6 +129,7 @@ void CTexturedQuadFilter::drawVerts(const zeus::CColor& color, const std::array<
void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& color, float t) {
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::DrawFilter", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniform.m_matrix = zeus::CMatrix4f();
m_uniform.m_lod = 0.f;
m_uniform.m_color = color;
@ -166,6 +173,7 @@ void CTexturedQuadFilter::DrawFilter(EFilterShape shape, const zeus::CColor& col
m_vbo.load(FullscreenVerts);
m_dataBind.draw(0, FullscreenVerts.size());
}
#endif
}
CTexturedQuadFilterAlpha::CTexturedQuadFilterAlpha(EFilterType type, hsh::texture2d tex) {

View File

@ -61,8 +61,10 @@ CThermalColdFilter::CThermalColdFilter() {
void CThermalColdFilter::draw() {
SCOPED_GRAPHICS_DEBUG_GROUP("CThermalColdFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport);
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -44,8 +44,10 @@ CThermalHotFilter::CThermalHotFilter() {
void CThermalHotFilter::draw() {
SCOPED_GRAPHICS_DEBUG_GROUP("CThermalHotFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport);
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -39,6 +39,7 @@ void CWorldShadowShader::bindRenderTarget() { m_tex.attach(); }
void CWorldShadowShader::drawBase(float extent) {
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::drawBase", zeus::skMagenta);
#if !HSH_PROFILE_MODE
const std::array<Vert, 4> verts{{
{{-extent, 0.f, extent}},
{{extent, 0.f, extent}},
@ -50,6 +51,7 @@ void CWorldShadowShader::drawBase(float extent) {
m_uniform.m_matrix = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniform.m_color = zeus::skWhite;
m_uniBuf.load(m_uniform);
#endif
m_zDataBind.draw(0, 4);
}
@ -57,8 +59,10 @@ void CWorldShadowShader::drawBase(float extent) {
void CWorldShadowShader::lightenShadow() {
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldShadowShader::lightenShadow", zeus::skMagenta);
#if !HSH_PROFILE_MODE
m_uniform.m_color = zeus::CColor(1.f, 0.25f);
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -65,6 +65,7 @@ CXRayBlurFilter::CXRayBlurFilter(TLockedToken<CTexture>& tex) : m_paletteTex(tex
void CXRayBlurFilter::draw(float amount) {
SCOPED_GRAPHICS_DEBUG_GROUP("CXRayBlurFilter::draw", zeus::skMagenta);
#if !HSH_PROFILE_MODE
CGraphics::ResolveSpareTexture(CGraphics::g_CroppedViewport);
const float blurL = amount * g_tweakGui->GetXrayBlurScaleLinear() * 0.25f;
@ -81,6 +82,7 @@ void CXRayBlurFilter::draw(float amount) {
}
m_uniBuf.load(m_uniform);
#endif
m_dataBind.draw(0, 4);
}

View File

@ -90,6 +90,7 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) {
const zeus::CMatrix4f proj = CGraphics::GetPerspectiveProjectionMatrix(true);
const zeus::CMatrix4f mat = proj * mv;
#if !HSH_PROFILE_MODE
m_uniBuf.load({mat, col});
if (m_drawFlags == CGuiWidget::EGuiModelDrawFlags::AlphaAdditiveOverdraw) {
zeus::CColor colPremul = col * col.a();
@ -121,6 +122,7 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) {
img.m_dataBindingOverdraw[idx].draw_instanced(0, 4, 1);
}
}
#endif
}
void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImageDef& image) {

View File

@ -130,6 +130,9 @@ void CFlaahgra::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateM
}
GetMirrorWaypoints(mgr);
#if HSH_PROFILE_MODE
GatherAssets(mgr);
#endif
break;
}
case EScriptObjectMessage::Activate: {

View File

@ -29,6 +29,14 @@ CDecal::CDecal(const TToken<CDecalDescription>& desc, const zeus::CTransform& xf
} else {
x5c_29_modelInvalid = true;
}
for (auto& decal : x3c_decalQuads) {
hsh::texture2d tex{};
if (CUVElement* texDesc = decal.m_desc->x14_TEX.get()) {
tex = texDesc->GetValueTexture(x58_frameIdx)->GetBooTexture();
}
CDecalShaders::BuildShaderDataBinding(decal.m_binding, decal, tex);
}
}
bool CDecal::InitQuad(CQuadDecal& quad, const SQuadDescr& desc) {
@ -97,18 +105,16 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
modXf.origin += offset;
CGraphics::SetModelMatrix(modXf);
#if !HSH_PROFILE_MODE
SParticleUniforms uniformData = {
CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(),
{1.f, 1.f, 1.f, 1.f},
};
decal.m_uniformBuf.load(uniformData);
#endif
SUVElementSet uvSet = {0.f, 1.f, 0.f, 1.f};
if (CUVElement* tex = desc.x14_TEX.get()) {
TLockedToken<CTexture> texObj = tex->GetValueTexture(x58_frameIdx);
if (!texObj.IsLoaded()) {
return;
}
tex->GetValueUV(x58_frameIdx, uvSet);
g_instTexData.clear();
@ -135,9 +141,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
inst.uvs[2] = hsh::float2(uvSet.xMin, uvSet.yMax);
inst.uvs[3] = hsh::float2(uvSet.xMax, uvSet.yMax);
#if !HSH_PROFILE_MODE
decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instTexData.data(), g_instTexData.size()});
m_shaderBuilder.BuildShaderDataBinding(decal, texObj->GetBooTexture())
.draw_instanced(0, 4, g_instIndTexData.size());
#endif
decal.m_binding.draw_instanced(0, 4, g_instTexData.size());
} else {
g_instNoTexData.clear();
g_instNoTexData.reserve(1);
@ -159,8 +166,10 @@ void CDecal::RenderQuad(CQuadDecal& decal, const SQuadDescr& desc) {
}
inst.color = color;
#if !HSH_PROFILE_MODE
decal.m_instBuf.load(hsh::detail::ArrayProxy{g_instNoTexData.data(), g_instNoTexData.size()});
m_shaderBuilder.BuildShaderDataBinding(decal, hsh::texture2d{}).draw_instanced(0, 4, g_instNoTexData.size());
#endif
decal.m_binding.draw_instanced(0, 4, g_instNoTexData.size());
}
}

View File

@ -22,6 +22,7 @@ struct CQuadDecal {
CQuadDecal() = default;
CQuadDecal(s32 i, float f) : x4_lifetime(i), x8_rotation(f) {}
hsh::binding m_binding;
hsh::dynamic_owner<hsh::vertex_buffer_typeless> m_instBuf;
hsh::dynamic_owner<hsh::uniform_buffer<SParticleUniforms>> m_uniformBuf;
};
@ -41,8 +42,6 @@ class CDecal {
bool x5c_29_modelInvalid : 1 = false;
zeus::CVector3f x60_rotation;
CDecalShaders m_shaderBuilder{};
bool InitQuad(CQuadDecal& quad, const SQuadDescr& desc);
public:

View File

@ -238,6 +238,8 @@ CElementGen::CElementGen(TToken<CGenDescription> gen, EModelOrientationType orie
}
m_uniformBufPmus = hsh::create_dynamic_uniform_buffer<SParticleUniforms>();
}
if (!x26c_31_LINE)
CElementGenShaders::BuildShaderDataBinding(*this);
}
CElementGen::~CElementGen() {
@ -912,7 +914,9 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
break;
}
#if !HSH_PROFILE_MODE
m_uniformBufPmus.load({CGraphics::GetPerspectiveProjectionMatrix(true), {1.f, 1.f, 1.f, 1.f}});
#endif
}
zeus::CTransform orient = zeus::CTransform();
@ -1044,9 +1048,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
if (g_subtractBlend) {
model->Draw({5, 0, 1, zeus::CColor(1.f, 0.5f)});
} else if (desc->x44_31_x31_25_PMAB) {
CModelFlags flags{7, 0, 1, col};
flags.m_extendedShader = EExtendedShader::ForcedAdditiveNoZWrite;
model->Draw(flags);
model->Draw({7, 0, 1, col});
} else if (1.f == col.a()) {
model->Draw({0, 0, 3, zeus::skWhite});
} else {
@ -1061,12 +1063,16 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
if (desc->x45_24_x31_26_PMUS) {
switch (m_shaderClass) {
case CElementGenShaders::EShaderClass::Tex:
#if !HSH_PROFILE_MODE
m_instBufPmus.load<SParticleInstanceTex>(g_instTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instTexData.size());
#endif
m_bindingPmus.draw_instanced(0, 4, g_instTexData.size());
break;
case CElementGenShaders::EShaderClass::NoTex:
#if !HSH_PROFILE_MODE
m_instBufPmus.load<SParticleInstanceNoTex>(g_instNoTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, true).draw_instanced(0, 4, g_instNoTexData.size());
#endif
m_bindingPmus.draw_instanced(0, 4, g_instNoTexData.size());
break;
default:
break;
@ -1076,7 +1082,7 @@ void CElementGen::RenderModels(const CActorLights* actorLights) {
if (x26d_26_modelsUseLights)
CGraphics::DisableAllLights();
CGraphics::SetCullMode(ERglCullMode::Front);
CGraphics::SetCullMode(ERglCullMode::Back);
if (moveRedToAlphaBuffer) {
/* Restore passthrough */
}
@ -1238,7 +1244,9 @@ void CElementGen::RenderParticles() {
constUVs = texr->HasConstantUV();
}
#if !HSH_PROFILE_MODE
m_uniformBuf.load(uniformData);
#endif
std::vector<CParticleListItem> sortItems;
if (desc->x44_28_x30_28_SORT) {
@ -1257,9 +1265,9 @@ void CElementGen::RenderParticles() {
});
}
bool moveRedToAlphaBuffer = false;
if (sMoveRedToAlphaBuffer && x26c_26_AAPH)
moveRedToAlphaBuffer = true;
// bool moveRedToAlphaBuffer = false;
// if (sMoveRedToAlphaBuffer && x26c_26_AAPH)
// moveRedToAlphaBuffer = true;
int mbspVal = std::max(1, x270_MBSP);
@ -1471,12 +1479,16 @@ void CElementGen::RenderParticles() {
switch (m_shaderClass) {
case CElementGenShaders::EShaderClass::Tex:
#if !HSH_PROFILE_MODE
m_instBuf.load<SParticleInstanceTex>(g_instTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size());
#endif
m_binding.draw_instanced(0, 4, g_instTexData.size());
break;
case CElementGenShaders::EShaderClass::NoTex:
#if !HSH_PROFILE_MODE
m_instBuf.load<SParticleInstanceNoTex>(g_instNoTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size());
#endif
m_binding.draw_instanced(0, 4, g_instNoTexData.size());
break;
default:
break;
@ -1585,12 +1597,16 @@ void CElementGen::RenderParticles() {
}
switch (m_shaderClass) {
case CElementGenShaders::EShaderClass::Tex:
#if !HSH_PROFILE_MODE
m_instBuf.load<SParticleInstanceTex>(g_instTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instTexData.size());
#endif
m_binding.draw_instanced(0, 4, g_instTexData.size());
break;
case CElementGenShaders::EShaderClass::NoTex:
#if !HSH_PROFILE_MODE
m_instBuf.load<SParticleInstanceNoTex>(g_instNoTexData);
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instNoTexData.size());
#endif
m_binding.draw_instanced(0, 4, g_instNoTexData.size());
break;
default:
break;
@ -1609,8 +1625,10 @@ void CElementGen::RenderParticlesIndirectTexture() {
x178_localScaleTransform;
CGraphics::SetModelMatrix(systemViewPointMatrix);
#if !HSH_PROFILE_MODE
m_uniformBuf.load(
{CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f(), {1.f, 1.f, 1.f, 1.f}});
#endif
CGraphics::SetAlphaCompare(ERglAlphaFunc::Always, 0, ERglAlphaOp::And, ERglAlphaFunc::Always, 0);
@ -1721,13 +1739,14 @@ void CElementGen::RenderParticlesIndirectTexture() {
inst.texrTindUVs[3] = zeus::CVector4f{uvs.xMin, uvs.yMin, uvsInd.xMin, uvsInd.yMin};
inst.sceneUVs =
zeus::CVector4f{clipRect.x18_uvXMin, 1.f - clipRect.x24_uvYMax, clipRect.x1c_uvXMax, 1.f - clipRect.x20_uvYMin};
m_shaderBuilder.BuildShaderDataBinding(*this, false).draw_instanced(0, 4, g_instIndTexData.size() - 1);
m_binding.draw_instanced(0, 4, g_instIndTexData.size() - 1);
}
if (!g_instIndTexData.empty()) {
#if !HSH_PROFILE_MODE
m_instBuf.load<SParticleInstanceIndTex>(g_instIndTexData);
// CGraphics::SetShaderDataBinding(m_normalDataBind);
// CGraphics::DrawInstances(0, 4, g_instIndTexData.size());
#endif
m_binding.draw_instanced(0, 4, g_instIndTexData.size());
}
}

View File

@ -134,6 +134,8 @@ private:
std::unique_ptr<CLineRenderer> m_lineRenderer;
CElementGenShaders::EShaderClass m_shaderClass;
hsh::binding m_binding;
hsh::binding m_bindingPmus;
void AccumulateBounds(const zeus::CVector3f& pos, float size);

View File

@ -1002,11 +1002,13 @@ void CParticleSwoosh::Render(const CActorLights*) {
}
}
#if !HSH_PROFILE_MODE
zeus::CMatrix4f mvp = CGraphics::GetPerspectiveProjectionMatrix(true) * CGraphics::g_GXModelView.toMatrix4f();
m_uniformBuf.load({mvp});
if (!m_cachedVerts.empty()) {
m_vertBuf.load(m_cachedVerts);
}
#endif
}
void CParticleSwoosh::SetOrientation(const zeus::CTransform& xf) {