From 9f90c647279973b7d7acda9f2c2fcd05f0145063 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 9 Nov 2023 22:50:41 +0100 Subject: [PATCH] use FTranslationID in the high level parts of the hardware renderer. --- src/common/engine/palettecontainer.h | 5 +++++ src/common/rendering/hwrenderer/data/hw_renderstate.h | 6 ++++++ src/rendering/hwrenderer/hw_models.cpp | 2 +- src/rendering/hwrenderer/scene/hw_decal.cpp | 2 +- src/rendering/hwrenderer/scene/hw_drawstructs.h | 2 +- src/rendering/hwrenderer/scene/hw_flats.cpp | 10 +++++----- src/rendering/hwrenderer/scene/hw_portal.cpp | 2 +- src/rendering/hwrenderer/scene/hw_sprites.cpp | 4 ++-- src/rendering/hwrenderer/scene/hw_walls.cpp | 4 ++-- src/rendering/hwrenderer/scene/hw_weapon.cpp | 4 ++-- src/rendering/swrenderer/viewport/r_spritedrawer.cpp | 2 +- 11 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/common/engine/palettecontainer.h b/src/common/engine/palettecontainer.h index b7869e2763f..60991c74e5e 100644 --- a/src/common/engine/palettecontainer.h +++ b/src/common/engine/palettecontainer.h @@ -187,6 +187,11 @@ class PaletteContainer void CopyTranslation(FTranslationID dest, FTranslationID src); FTranslationID StoreTranslation(int slot, FRemapTable* remap); FRemapTable* TranslationToTable(int translation) const; + FRemapTable* TranslationToTable(FTranslationID translation) const + { + return TranslationToTable(translation.index()); + } + void GenerateGlobalBrightmapFromColormap(const uint8_t* cmapdata, int numlevels); void PushIdentityTable(int slot) diff --git a/src/common/rendering/hwrenderer/data/hw_renderstate.h b/src/common/rendering/hwrenderer/data/hw_renderstate.h index 1f5e08d4c24..05fd6bcbf1c 100644 --- a/src/common/rendering/hwrenderer/data/hw_renderstate.h +++ b/src/common/rendering/hwrenderer/data/hw_renderstate.h @@ -635,6 +635,12 @@ class FRenderState SetMaterial(mat, clampmode, translation, overrideshader); } + void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, FTranslationID translation, int overrideshader) + { + SetMaterial(tex, upscalemask, scaleflags, clampmode, translation.index(), overrideshader); + } + + void SetClipSplit(float bottom, float top) { mClipSplit[0] = bottom; diff --git a/src/rendering/hwrenderer/hw_models.cpp b/src/rendering/hwrenderer/hw_models.cpp index a5a766b17dd..d383f07779e 100644 --- a/src/rendering/hwrenderer/hw_models.cpp +++ b/src/rendering/hwrenderer/hw_models.cpp @@ -118,7 +118,7 @@ void FHWModelRenderer::SetInterpolation(double inter) void FHWModelRenderer::SetMaterial(FGameTexture *skin, bool clampNoFilter, FTranslationID translation) { - state.SetMaterial(skin, UF_Skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation.index(), -1); + state.SetMaterial(skin, UF_Skin, 0, clampNoFilter ? CLAMP_NOFILTER : CLAMP_NONE, translation, -1); state.SetLightIndex(modellightindex); } diff --git a/src/rendering/hwrenderer/scene/hw_decal.cpp b/src/rendering/hwrenderer/scene/hw_decal.cpp index f6d515d1717..1e28cdd5fae 100644 --- a/src/rendering/hwrenderer/scene/hw_decal.cpp +++ b/src/rendering/hwrenderer/scene/hw_decal.cpp @@ -76,7 +76,7 @@ void HWDecal::DrawDecal(HWDrawInfo *di, FRenderState &state) state.SetTextureMode(decal->RenderStyle); state.SetRenderStyle(decal->RenderStyle); - state.SetMaterial(texture, UF_Sprite, 0, CLAMP_XY, decal->Translation.index(), -1); + state.SetMaterial(texture, UF_Sprite, 0, CLAMP_XY, decal->Translation, -1); // If srcalpha is one it looks better with a higher alpha threshold diff --git a/src/rendering/hwrenderer/scene/hw_drawstructs.h b/src/rendering/hwrenderer/scene/hw_drawstructs.h index be65b956c16..e86d4b57a6a 100644 --- a/src/rendering/hwrenderer/scene/hw_drawstructs.h +++ b/src/rendering/hwrenderer/scene/hw_drawstructs.h @@ -368,7 +368,7 @@ class HWSprite FRenderStyle RenderStyle; int OverrideShader; - int translation; + FTranslationID translation; int index; float depth; int vertexindex; diff --git a/src/rendering/hwrenderer/scene/hw_flats.cpp b/src/rendering/hwrenderer/scene/hw_flats.cpp index 7bcda7ed361..459fe64452e 100644 --- a/src/rendering/hwrenderer/scene/hw_flats.cpp +++ b/src/rendering/hwrenderer/scene/hw_flats.cpp @@ -214,7 +214,7 @@ void HWFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state) void HWFlat::DrawOtherPlanes(HWDrawInfo *di, FRenderState &state) { - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, NO_TRANSLATION, -1); // Draw the subsectors assigned to it due to missing textures auto pNode = (renderflags&SSRF_RENDERFLOOR) ? @@ -246,7 +246,7 @@ void HWFlat::DrawFloodPlanes(HWDrawInfo *di, FRenderState &state) // This requires a stencil because the projected plane interferes with // the depth buffer - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, NO_TRANSLATION, -1); // Draw the subsectors assigned to it due to missing textures auto pNode = (renderflags&SSRF_RENDERFLOOR) ? @@ -334,14 +334,14 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) { if (sector->special != GLSector_Skybox) { - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, NO_TRANSLATION, -1); SetPlaneTextureRotation(state, &plane, texture); DrawSubsectors(di, state); state.EnableTextureMatrix(false); } else if (!hacktype) { - state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_XY, NO_TRANSLATION, -1); state.SetLightIndex(dynlightindex); state.Draw(DT_TriangleStrip,iboindex, 4); flatvertices += 4; @@ -362,7 +362,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) { if (!texture->GetTranslucency()) state.AlphaFunc(Alpha_GEqual, gl_mask_threshold); else state.AlphaFunc(Alpha_GEqual, 0.f); - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, NO_TRANSLATION, -1); SetPlaneTextureRotation(state, &plane, texture); DrawSubsectors(di, state); state.EnableTextureMatrix(false); diff --git a/src/rendering/hwrenderer/scene/hw_portal.cpp b/src/rendering/hwrenderer/scene/hw_portal.cpp index 565cf2794a0..a453827f357 100644 --- a/src/rendering/hwrenderer/scene/hw_portal.cpp +++ b/src/rendering/hwrenderer/scene/hw_portal.cpp @@ -984,7 +984,7 @@ void HWHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state) state.EnableBrightmap(true); - state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, CLAMP_NONE, NO_TRANSLATION, -1); state.SetObjectColor(origin->specialcolor); SetPlaneTextureRotation(state, sp, texture); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index f573f3f08aa..d8470925f9e 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -1077,7 +1077,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t } } - translation = thing->Translation.index(); + translation = thing->Translation; OverrideShader = -1; trans = thing->Alpha; @@ -1326,7 +1326,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t * if (lump.isValid()) { - translation = 0; + translation = NO_TRANSLATION; //auto tex = TexMan.GetGameTexture(lump, false); ul = 0; diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index 4da62e5d6a5..a2fd3c3b254 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -135,7 +135,7 @@ void HWWall::RenderMirrorSurface(HWWallDispatcher*di, FRenderState &state) state.AlphaFunc(Alpha_Greater, 0); auto tex = TexMan.GetGameTexture(TexMan.mirrorTexture, false); - state.SetMaterial(tex, UF_None, 0, CLAMP_NONE, 0, -1); // do not upscale the mirror texture. + state.SetMaterial(tex, UF_None, 0, CLAMP_NONE, NO_TRANSLATION, -1); // do not upscale the mirror texture. flags &= ~HWWall::HWF_GLOW; RenderWall(state, HWWall::RWF_BLANK); @@ -191,7 +191,7 @@ void HWWall::RenderTexturedWall(HWWallDispatcher*di, FRenderState &state, int rf state.SetGlowParams(topglowcolor, bottomglowcolor); SetGlowPlanes(state, frontsector->ceilingplane, frontsector->floorplane); } - state.SetMaterial(texture, UF_Texture, 0, flags & 3, 0, -1); + state.SetMaterial(texture, UF_Texture, 0, flags & 3, NO_TRANSLATION, -1); #ifdef NPOT_EMULATION // Test code, could be reactivated as a compatibility option in the unlikely event that some old vanilla map eve needs it. if (hw_npottest) diff --git a/src/rendering/hwrenderer/scene/hw_weapon.cpp b/src/rendering/hwrenderer/scene/hw_weapon.cpp index 4cabd6b5eb6..2500a5bf2b1 100644 --- a/src/rendering/hwrenderer/scene/hw_weapon.cpp +++ b/src/rendering/hwrenderer/scene/hw_weapon.cpp @@ -98,8 +98,8 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state) { float thresh = (huds->texture->GetTranslucency() || huds->OverrideShader != -1) ? 0.f : gl_mask_sprite_threshold; state.AlphaFunc(Alpha_GEqual, thresh); - uint32_t trans = huds->weapon->GetTranslation().index(); - if ((huds->weapon->Flags & PSPF_PLAYERTRANSLATED)) trans = huds->owner->Translation.index(); + FTranslationID trans = huds->weapon->GetTranslation(); + if ((huds->weapon->Flags & PSPF_PLAYERTRANSLATED)) trans = huds->owner->Translation; state.SetMaterial(huds->texture, UF_Sprite, CTF_Expand, CLAMP_XY_NOMIP, trans, huds->OverrideShader); state.Draw(DT_TriangleStrip, huds->mx, 4); } diff --git a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp index c08245e12a4..b40ddd8b4b3 100644 --- a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp @@ -469,7 +469,7 @@ namespace swrenderer SetTranslationMap(nullptr); if (translation != NO_TRANSLATION) { - FRemapTable *table = GPalette.TranslationToTable(translation.index()); + FRemapTable *table = GPalette.TranslationToTable(translation); if (table != NULL) { if (viewport->RenderTarget->IsBgra())