mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Force colormap/light selection to go through function calls
This commit is contained in:
parent
fd459b1f13
commit
81a20213a7
5 changed files with 119 additions and 97 deletions
|
@ -100,7 +100,7 @@ namespace swrenderer
|
|||
{
|
||||
_iscale = args.dc_iscale;
|
||||
_texturefrac = args.dc_texturefrac;
|
||||
_colormap = args.dc_colormap;
|
||||
_colormap = args.Colormap();
|
||||
_count = args.dc_count;
|
||||
_source = args.dc_source;
|
||||
_dest = args.Dest();
|
||||
|
@ -870,9 +870,9 @@ namespace swrenderer
|
|||
_pitch = dc_pitch;
|
||||
_iscale = args.dc_iscale;
|
||||
_texturefrac = args.dc_texturefrac;
|
||||
_colormap = args.dc_colormap;
|
||||
_colormap = args.Colormap();
|
||||
_source = args.dc_source;
|
||||
_translation = args.dc_translation;
|
||||
_translation = args.TranslationMap();
|
||||
_color = args.dc_color;
|
||||
_srcblend = args.dc_srcblend;
|
||||
_destblend = args.dc_destblend;
|
||||
|
@ -1849,7 +1849,7 @@ namespace swrenderer
|
|||
PalSpanCommand::PalSpanCommand(const SpanDrawerArgs &args)
|
||||
{
|
||||
_source = args.ds_source;
|
||||
_colormap = args.dc_colormap;
|
||||
_colormap = args.Colormap();
|
||||
_xfrac = args.ds_xfrac;
|
||||
_yfrac = args.ds_yfrac;
|
||||
_y = args.ds_y;
|
||||
|
@ -2624,7 +2624,7 @@ namespace swrenderer
|
|||
DrawTiltedSpanPalCommand::DrawTiltedSpanPalCommand(const SpanDrawerArgs &args, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
|
||||
: y(y), x1(x1), x2(x2), plane_sz(plane_sz), plane_su(plane_su), plane_sv(plane_sv), plane_shade(plane_shade), planeshade(planeshade), planelightfloat(planelightfloat), pviewx(pviewx), pviewy(pviewy)
|
||||
{
|
||||
_colormap = args.dc_colormap;
|
||||
_colormap = args.Colormap();
|
||||
_destorg = dc_destorg;
|
||||
_ybits = args.ds_ybits;
|
||||
_xbits = args.ds_xbits;
|
||||
|
@ -2885,7 +2885,7 @@ namespace swrenderer
|
|||
|
||||
DrawFogBoundaryLinePalCommand::DrawFogBoundaryLinePalCommand(const SpanDrawerArgs &args, int y, int x1, int x2) : PalSpanCommand(args), y(y), x1(x1), x2(x2)
|
||||
{
|
||||
_colormap = args.dc_colormap;
|
||||
_colormap = args.Colormap();
|
||||
_destorg = dc_destorg;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace swrenderer
|
|||
{
|
||||
DrawSpanLLVMCommand::DrawSpanLLVMCommand(const SpanDrawerArgs &drawerargs)
|
||||
{
|
||||
auto shade_constants = drawerargs.ColormapConstants();
|
||||
args.xfrac = drawerargs.ds_xfrac;
|
||||
args.yfrac = drawerargs.ds_yfrac;
|
||||
args.xstep = drawerargs.ds_xstep;
|
||||
|
@ -74,20 +75,20 @@ namespace swrenderer
|
|||
args.destorg = (uint32_t*)dc_destorg;
|
||||
args.destpitch = dc_pitch;
|
||||
args.source = (const uint32_t*)drawerargs.ds_source;
|
||||
args.light = LightBgra::calc_light_multiplier(drawerargs.dc_light);
|
||||
args.light_red = drawerargs.dc_shade_constants.light_red;
|
||||
args.light_green = drawerargs.dc_shade_constants.light_green;
|
||||
args.light_blue = drawerargs.dc_shade_constants.light_blue;
|
||||
args.light_alpha = drawerargs.dc_shade_constants.light_alpha;
|
||||
args.fade_red = drawerargs.dc_shade_constants.fade_red;
|
||||
args.fade_green = drawerargs.dc_shade_constants.fade_green;
|
||||
args.fade_blue = drawerargs.dc_shade_constants.fade_blue;
|
||||
args.fade_alpha = drawerargs.dc_shade_constants.fade_alpha;
|
||||
args.desaturate = drawerargs.dc_shade_constants.desaturate;
|
||||
args.light = LightBgra::calc_light_multiplier(drawerargs.Light());
|
||||
args.light_red = shade_constants.light_red;
|
||||
args.light_green = shade_constants.light_green;
|
||||
args.light_blue = shade_constants.light_blue;
|
||||
args.light_alpha = shade_constants.light_alpha;
|
||||
args.fade_red = shade_constants.fade_red;
|
||||
args.fade_green = shade_constants.fade_green;
|
||||
args.fade_blue = shade_constants.fade_blue;
|
||||
args.fade_alpha = shade_constants.fade_alpha;
|
||||
args.desaturate = shade_constants.desaturate;
|
||||
args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8);
|
||||
args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8);
|
||||
args.flags = 0;
|
||||
if (drawerargs.dc_shade_constants.simple_shade)
|
||||
if (shade_constants.simple_shade)
|
||||
args.flags |= DrawSpanArgs::simple_shade;
|
||||
if (!sampler_setup(drawerargs.ds_lod, args.source, args.xbits, args.ybits, drawerargs.ds_source_mipmapped))
|
||||
args.flags |= DrawSpanArgs::nearest_filter;
|
||||
|
@ -182,6 +183,7 @@ namespace swrenderer
|
|||
|
||||
DrawWall1LLVMCommand::DrawWall1LLVMCommand(const WallDrawerArgs &drawerargs)
|
||||
{
|
||||
auto shade_constants = drawerargs.ColormapConstants();
|
||||
args.dest = (uint32_t*)drawerargs.Dest();
|
||||
args.dest_y = drawerargs.DestY();
|
||||
args.pitch = dc_pitch;
|
||||
|
@ -192,20 +194,20 @@ namespace swrenderer
|
|||
args.textureheight[0] = drawerargs.dc_textureheight;
|
||||
args.source[0] = (const uint32 *)drawerargs.dc_source;
|
||||
args.source2[0] = (const uint32 *)drawerargs.dc_source2;
|
||||
args.light[0] = LightBgra::calc_light_multiplier(drawerargs.dc_light);
|
||||
args.light_red = drawerargs.dc_shade_constants.light_red;
|
||||
args.light_green = drawerargs.dc_shade_constants.light_green;
|
||||
args.light_blue = drawerargs.dc_shade_constants.light_blue;
|
||||
args.light_alpha = drawerargs.dc_shade_constants.light_alpha;
|
||||
args.fade_red = drawerargs.dc_shade_constants.fade_red;
|
||||
args.fade_green = drawerargs.dc_shade_constants.fade_green;
|
||||
args.fade_blue = drawerargs.dc_shade_constants.fade_blue;
|
||||
args.fade_alpha = drawerargs.dc_shade_constants.fade_alpha;
|
||||
args.desaturate = drawerargs.dc_shade_constants.desaturate;
|
||||
args.light[0] = LightBgra::calc_light_multiplier(drawerargs.Light());
|
||||
args.light_red = shade_constants.light_red;
|
||||
args.light_green = shade_constants.light_green;
|
||||
args.light_blue = shade_constants.light_blue;
|
||||
args.light_alpha = shade_constants.light_alpha;
|
||||
args.fade_red = shade_constants.fade_red;
|
||||
args.fade_green = shade_constants.fade_green;
|
||||
args.fade_blue = shade_constants.fade_blue;
|
||||
args.fade_alpha = shade_constants.fade_alpha;
|
||||
args.desaturate = shade_constants.desaturate;
|
||||
args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8);
|
||||
args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8);
|
||||
args.flags = 0;
|
||||
if (drawerargs.dc_shade_constants.simple_shade)
|
||||
if (shade_constants.simple_shade)
|
||||
args.flags |= DrawWallArgs::simple_shade;
|
||||
if (args.source2[0] == nullptr)
|
||||
args.flags |= DrawWallArgs::nearest_filter;
|
||||
|
@ -246,11 +248,13 @@ namespace swrenderer
|
|||
|
||||
DrawColumnLLVMCommand::DrawColumnLLVMCommand(const ColumnDrawerArgs &drawerargs)
|
||||
{
|
||||
auto shade_constants = drawerargs.ColormapConstants();
|
||||
|
||||
args.dest = (uint32_t*)drawerargs.Dest();
|
||||
args.source = drawerargs.dc_source;
|
||||
args.source2 = drawerargs.dc_source2;
|
||||
args.colormap = drawerargs.dc_colormap;
|
||||
args.translation = drawerargs.dc_translation;
|
||||
args.colormap = drawerargs.Colormap();
|
||||
args.translation = drawerargs.TranslationMap();
|
||||
args.basecolors = (const uint32_t *)GPalette.BaseColors;
|
||||
args.pitch = dc_pitch;
|
||||
args.count = drawerargs.dc_count;
|
||||
|
@ -259,22 +263,22 @@ namespace swrenderer
|
|||
args.texturefracx = drawerargs.dc_texturefracx;
|
||||
args.textureheight = drawerargs.dc_textureheight;
|
||||
args.texturefrac = drawerargs.dc_texturefrac;
|
||||
args.light = LightBgra::calc_light_multiplier(drawerargs.dc_light);
|
||||
args.light = LightBgra::calc_light_multiplier(drawerargs.Light());
|
||||
args.color = LightBgra::shade_pal_index_simple(drawerargs.dc_color, args.light);
|
||||
args.srccolor = drawerargs.dc_srccolor_bgra;
|
||||
args.srcalpha = drawerargs.dc_srcalpha >> (FRACBITS - 8);
|
||||
args.destalpha = drawerargs.dc_destalpha >> (FRACBITS - 8);
|
||||
args.light_red = drawerargs.dc_shade_constants.light_red;
|
||||
args.light_green = drawerargs.dc_shade_constants.light_green;
|
||||
args.light_blue = drawerargs.dc_shade_constants.light_blue;
|
||||
args.light_alpha = drawerargs.dc_shade_constants.light_alpha;
|
||||
args.fade_red = drawerargs.dc_shade_constants.fade_red;
|
||||
args.fade_green = drawerargs.dc_shade_constants.fade_green;
|
||||
args.fade_blue = drawerargs.dc_shade_constants.fade_blue;
|
||||
args.fade_alpha = drawerargs.dc_shade_constants.fade_alpha;
|
||||
args.desaturate = drawerargs.dc_shade_constants.desaturate;
|
||||
args.light_red = shade_constants.light_red;
|
||||
args.light_green = shade_constants.light_green;
|
||||
args.light_blue = shade_constants.light_blue;
|
||||
args.light_alpha = shade_constants.light_alpha;
|
||||
args.fade_red = shade_constants.fade_red;
|
||||
args.fade_green = shade_constants.fade_green;
|
||||
args.fade_blue = shade_constants.fade_blue;
|
||||
args.fade_alpha = shade_constants.fade_alpha;
|
||||
args.desaturate = shade_constants.desaturate;
|
||||
args.flags = 0;
|
||||
if (drawerargs.dc_shade_constants.simple_shade)
|
||||
if (shade_constants.simple_shade)
|
||||
args.flags |= DrawColumnArgs::simple_shade;
|
||||
if (args.source2 == nullptr)
|
||||
args.flags |= DrawColumnArgs::nearest_filter;
|
||||
|
@ -436,7 +440,7 @@ namespace swrenderer
|
|||
_x2 = drawerargs.ds_x2;
|
||||
_y = drawerargs.ds_y;
|
||||
_destorg = dc_destorg;
|
||||
_light = drawerargs.dc_light;
|
||||
_light = drawerargs.Light();
|
||||
_color = drawerargs.ds_color;
|
||||
}
|
||||
|
||||
|
@ -467,8 +471,8 @@ namespace swrenderer
|
|||
_x2 = x2;
|
||||
|
||||
_destorg = dc_destorg;
|
||||
_light = drawerargs.dc_light;
|
||||
_shade_constants = drawerargs.dc_shade_constants;
|
||||
_light = drawerargs.Light();
|
||||
_shade_constants = drawerargs.ColormapConstants();
|
||||
}
|
||||
|
||||
void DrawFogBoundaryLineRGBACommand::Execute(DrawerThread *thread)
|
||||
|
@ -534,8 +538,8 @@ namespace swrenderer
|
|||
_x2 = x2;
|
||||
_y = y;
|
||||
_destorg = dc_destorg;
|
||||
_light = drawerargs.dc_light;
|
||||
_shade_constants = drawerargs.dc_shade_constants;
|
||||
_light = drawerargs.Light();
|
||||
_shade_constants = drawerargs.ColormapConstants();
|
||||
_plane_sz = plane_sz;
|
||||
_plane_su = plane_su;
|
||||
_plane_sv = plane_sv;
|
||||
|
@ -669,7 +673,7 @@ namespace swrenderer
|
|||
_x2 = x2;
|
||||
|
||||
_destorg = dc_destorg;
|
||||
_light = drawerargs.dc_light;
|
||||
_light = drawerargs.Light();
|
||||
_color = drawerargs.ds_color;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,51 +70,65 @@ namespace swrenderer
|
|||
|
||||
void DrawerArgs::SetColorMapLight(FSWColormap *base_colormap, float light, int shade)
|
||||
{
|
||||
if (r_swtruecolor)
|
||||
{
|
||||
dc_shade_constants.light_red = base_colormap->Color.r * 256 / 255;
|
||||
dc_shade_constants.light_green = base_colormap->Color.g * 256 / 255;
|
||||
dc_shade_constants.light_blue = base_colormap->Color.b * 256 / 255;
|
||||
dc_shade_constants.light_alpha = base_colormap->Color.a * 256 / 255;
|
||||
dc_shade_constants.fade_red = base_colormap->Fade.r;
|
||||
dc_shade_constants.fade_green = base_colormap->Fade.g;
|
||||
dc_shade_constants.fade_blue = base_colormap->Fade.b;
|
||||
dc_shade_constants.fade_alpha = base_colormap->Fade.a;
|
||||
dc_shade_constants.desaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256;
|
||||
dc_shade_constants.simple_shade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
|
||||
dc_colormap = base_colormap->Maps;
|
||||
dc_light = LIGHTSCALE(light, shade);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_colormap = base_colormap->Maps + (GETPALOOKUP(light, shade) << COLORMAPSHIFT);
|
||||
}
|
||||
mBaseColormap = base_colormap;
|
||||
mTranslation = nullptr;
|
||||
mLight = light;
|
||||
mShade = shade;
|
||||
}
|
||||
|
||||
void DrawerArgs::SetTranslationMap(lighttable_t *translation)
|
||||
{
|
||||
if (r_swtruecolor)
|
||||
mBaseColormap = nullptr;
|
||||
mTranslation = translation;
|
||||
}
|
||||
|
||||
uint8_t *DrawerArgs::Colormap() const
|
||||
{
|
||||
if (mBaseColormap)
|
||||
{
|
||||
dc_colormap = nullptr;
|
||||
dc_translation = translation;
|
||||
dc_shade_constants.light_red = 256;
|
||||
dc_shade_constants.light_green = 256;
|
||||
dc_shade_constants.light_blue = 256;
|
||||
dc_shade_constants.light_alpha = 256;
|
||||
dc_shade_constants.fade_red = 0;
|
||||
dc_shade_constants.fade_green = 0;
|
||||
dc_shade_constants.fade_blue = 0;
|
||||
dc_shade_constants.fade_alpha = 256;
|
||||
dc_shade_constants.desaturate = 0;
|
||||
dc_shade_constants.simple_shade = true;
|
||||
dc_light = 0;
|
||||
if (r_swtruecolor)
|
||||
return mBaseColormap->Maps;
|
||||
else
|
||||
return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_colormap = translation;
|
||||
return mTranslation;
|
||||
}
|
||||
}
|
||||
|
||||
ShadeConstants DrawerArgs::ColormapConstants() const
|
||||
{
|
||||
ShadeConstants shadeConstants;
|
||||
if (mBaseColormap)
|
||||
{
|
||||
shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255;
|
||||
shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255;
|
||||
shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255;
|
||||
shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255;
|
||||
shadeConstants.fade_red = mBaseColormap->Fade.r;
|
||||
shadeConstants.fade_green = mBaseColormap->Fade.g;
|
||||
shadeConstants.fade_blue = mBaseColormap->Fade.b;
|
||||
shadeConstants.fade_alpha = mBaseColormap->Fade.a;
|
||||
shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256;
|
||||
shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
shadeConstants.light_red = 256;
|
||||
shadeConstants.light_green = 256;
|
||||
shadeConstants.light_blue = 256;
|
||||
shadeConstants.light_alpha = 256;
|
||||
shadeConstants.fade_red = 0;
|
||||
shadeConstants.fade_green = 0;
|
||||
shadeConstants.fade_blue = 0;
|
||||
shadeConstants.fade_alpha = 256;
|
||||
shadeConstants.desaturate = 0;
|
||||
shadeConstants.simple_shade = true;
|
||||
}
|
||||
return shadeConstants;
|
||||
}
|
||||
|
||||
void SpanDrawerArgs::SetSpanTexture(FTexture *tex)
|
||||
{
|
||||
tex->GetWidth();
|
||||
|
@ -335,7 +349,7 @@ namespace swrenderer
|
|||
{
|
||||
colfunc = &SWPixelFormatDrawers::FillColumn;
|
||||
}
|
||||
else if (dc_translation == NULL)
|
||||
else if (mTranslation == nullptr)
|
||||
{
|
||||
colfunc = basecolfunc;
|
||||
}
|
||||
|
@ -380,7 +394,7 @@ namespace swrenderer
|
|||
{
|
||||
colfunc = &SWPixelFormatDrawers::FillAddColumn;
|
||||
}
|
||||
else if (dc_translation == NULL)
|
||||
else if (mTranslation == nullptr)
|
||||
{
|
||||
colfunc = &SWPixelFormatDrawers::DrawAddColumn;
|
||||
}
|
||||
|
@ -396,7 +410,7 @@ namespace swrenderer
|
|||
{
|
||||
colfunc = &SWPixelFormatDrawers::FillAddClampColumn;
|
||||
}
|
||||
else if (dc_translation == NULL)
|
||||
else if (mTranslation == nullptr)
|
||||
{
|
||||
colfunc = &SWPixelFormatDrawers::DrawAddClampColumn;
|
||||
}
|
||||
|
@ -413,7 +427,7 @@ namespace swrenderer
|
|||
{
|
||||
colfunc = &SWPixelFormatDrawers::FillSubClampColumn;
|
||||
}
|
||||
else if (dc_translation == NULL)
|
||||
else if (mTranslation == nullptr)
|
||||
{
|
||||
colfunc = &SWPixelFormatDrawers::DrawSubClampColumn;
|
||||
}
|
||||
|
@ -433,7 +447,7 @@ namespace swrenderer
|
|||
{
|
||||
colfunc = &SWPixelFormatDrawers::FillRevSubClampColumn;
|
||||
}
|
||||
else if (dc_translation == NULL)
|
||||
else if (mTranslation == nullptr)
|
||||
{
|
||||
colfunc = &SWPixelFormatDrawers::DrawRevSubClampColumn;
|
||||
}
|
||||
|
@ -495,16 +509,16 @@ namespace swrenderer
|
|||
|
||||
if (translation != -1)
|
||||
{
|
||||
dc_translation = NULL;
|
||||
mTranslation = nullptr;
|
||||
if (translation != 0)
|
||||
{
|
||||
FRemapTable *table = TranslationToTable(translation);
|
||||
if (table != NULL && !table->Inactive)
|
||||
{
|
||||
if (r_swtruecolor)
|
||||
dc_translation = (uint8_t*)table->Palette;
|
||||
mTranslation = (uint8_t*)table->Palette;
|
||||
else
|
||||
dc_translation = table->Remap;
|
||||
mTranslation = table->Remap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,10 +48,15 @@ namespace swrenderer
|
|||
bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0);
|
||||
void SetSpanStyle(bool masked, bool additive, fixed_t alpha);
|
||||
|
||||
// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color)
|
||||
void SetColorMapLight(FSWColormap *base_colormap, float light, int shade);
|
||||
void SetTranslationMap(lighttable_t *translation);
|
||||
|
||||
uint8_t *Colormap() const;
|
||||
uint8_t *TranslationMap() const { return mTranslation; }
|
||||
|
||||
ShadeConstants ColormapConstants() const;
|
||||
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
|
||||
|
||||
SWPixelFormatDrawers *Drawers() const;
|
||||
|
||||
ColumnDrawerFunc colfunc;
|
||||
|
@ -60,12 +65,6 @@ namespace swrenderer
|
|||
ColumnDrawerFunc transcolfunc;
|
||||
SpanDrawerFunc spanfunc;
|
||||
|
||||
uint8_t *dc_colormap;
|
||||
ShadeConstants dc_shade_constants;
|
||||
fixed_t dc_light = 0;
|
||||
|
||||
uint8_t *dc_translation;
|
||||
|
||||
uint32_t *dc_srcblend;
|
||||
uint32_t *dc_destblend;
|
||||
fixed_t dc_srcalpha;
|
||||
|
@ -81,6 +80,11 @@ namespace swrenderer
|
|||
private:
|
||||
bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags);
|
||||
static fixed_t GetAlpha(int type, fixed_t alpha);
|
||||
|
||||
FSWColormap *mBaseColormap = nullptr;
|
||||
float mLight = 0.0f;
|
||||
int mShade = 0;
|
||||
uint8_t *mTranslation = nullptr;
|
||||
};
|
||||
|
||||
class SkyDrawerArgs : public DrawerArgs
|
||||
|
|
|
@ -108,7 +108,7 @@ namespace swrenderer
|
|||
|
||||
basecolormap = colormap;
|
||||
GlobVis = LightVisibility::Instance()->FlatPlaneGlobVis() / planeheight;
|
||||
drawerargs.dc_light = 0;
|
||||
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->fixedlightlev >= 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue