Skip to content

Commit

Permalink
use FTranslationID in the high level parts of the hardware renderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 9, 2023
1 parent c426094 commit 9f90c64
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions src/common/engine/palettecontainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/common/rendering/hwrenderer/data/hw_renderstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/hw_models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_decal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_drawstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class HWSprite
FRenderStyle RenderStyle;
int OverrideShader;

int translation;
FTranslationID translation;
int index;
float depth;
int vertexindex;
Expand Down
10 changes: 5 additions & 5 deletions src/rendering/hwrenderer/scene/hw_flats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?
Expand Down Expand Up @@ -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) ?
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/hwrenderer/scene/hw_sprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/hwrenderer/scene/hw_walls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/rendering/hwrenderer/scene/hw_weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/swrenderer/viewport/r_spritedrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 9f90c64

Please sign in to comment.