mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- Add new drawer: AddClampShadedSprite
- fixed: AddShaded did not have a drawer associated with it in the software renderer - used new drawer for this purpose.
This commit is contained in:
parent
d0c77d7264
commit
a2fc2fb707
7 changed files with 69 additions and 3 deletions
|
@ -71,6 +71,7 @@ namespace swrenderer
|
||||||
virtual void DrawTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawShadedColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawShadedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
virtual void DrawAddClampShadedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawAddClampColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawAddClampColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawSubClampColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawSubClampColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
|
|
@ -1412,6 +1412,48 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawColumnAddClampShadedPalCommand::Execute(DrawerThread *thread)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
uint8_t *dest;
|
||||||
|
fixed_t frac, fracstep;
|
||||||
|
|
||||||
|
count = args.Count();
|
||||||
|
dest = args.Dest();
|
||||||
|
|
||||||
|
fracstep = args.TextureVStep();
|
||||||
|
frac = args.TextureVPos();
|
||||||
|
|
||||||
|
count = thread->count_for_thread(args.DestY(), count);
|
||||||
|
if (count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int pitch = args.Viewport()->RenderTarget->GetPitch();
|
||||||
|
dest = thread->dest_for_thread(args.DestY(), pitch, dest);
|
||||||
|
frac += fracstep * thread->skipped_by_thread(args.DestY());
|
||||||
|
fracstep *= thread->num_cores;
|
||||||
|
pitch *= thread->num_cores;
|
||||||
|
|
||||||
|
const uint8_t *source = args.TexturePixels();
|
||||||
|
const uint8_t *colormap = args.Colormap(args.Viewport());
|
||||||
|
//uint32_t *fgstart = &Col2RGB8[0][args.SolidColor()]; // if someone wants to write the 555's, be my guest.
|
||||||
|
const PalEntry *palette = GPalette.BaseColors;
|
||||||
|
|
||||||
|
int color = args.SolidColor();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
uint32_t val = source[frac >> FRACBITS];
|
||||||
|
|
||||||
|
int r = (palette[*dest].r * (255) + palette[color].r * val) >> 10;
|
||||||
|
int g = (palette[*dest].g * (255) + palette[color].g * val) >> 10;
|
||||||
|
int b = (palette[*dest].b * (255) + palette[color].b * val) >> 10;
|
||||||
|
*dest = RGB256k.RGB[clamp(r,0,63)][clamp(g,0,63)][clamp(b,0,63)];
|
||||||
|
|
||||||
|
dest += pitch;
|
||||||
|
frac += fracstep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread)
|
void DrawColumnAddClampPalCommand::Execute(DrawerThread *thread)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace swrenderer
|
||||||
class DrawColumnTranslatedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnTranslatedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnTlatedAddPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnTlatedAddPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnShadedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnShadedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
class DrawColumnAddClampShadedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnAddClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnAddClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnAddClampTranslatedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnAddClampTranslatedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
@ -236,6 +237,7 @@ namespace swrenderer
|
||||||
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTranslatedPalCommand>(args); }
|
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTranslatedPalCommand>(args); }
|
||||||
void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTlatedAddPalCommand>(args); }
|
void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTlatedAddPalCommand>(args); }
|
||||||
void DrawShadedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnShadedPalCommand>(args); }
|
void DrawShadedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnShadedPalCommand>(args); }
|
||||||
|
void DrawAddClampShadedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampShadedPalCommand>(args); }
|
||||||
void DrawAddClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampPalCommand>(args); }
|
void DrawAddClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampPalCommand>(args); }
|
||||||
void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampTranslatedPalCommand>(args); }
|
void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampTranslatedPalCommand>(args); }
|
||||||
void DrawSubClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnSubClampPalCommand>(args); }
|
void DrawSubClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnSubClampPalCommand>(args); }
|
||||||
|
|
|
@ -156,6 +156,11 @@ namespace swrenderer
|
||||||
Queue->Push<DrawSpriteShaded32Command>(args);
|
Queue->Push<DrawSpriteShaded32Command>(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SWTruecolorDrawers::DrawAddClampShadedColumn(const SpriteDrawerArgs &args)
|
||||||
|
{
|
||||||
|
Queue->Push<DrawSpriteAddClampShaded32Command>(args);
|
||||||
|
}
|
||||||
|
|
||||||
void SWTruecolorDrawers::DrawAddClampColumn(const SpriteDrawerArgs &args)
|
void SWTruecolorDrawers::DrawAddClampColumn(const SpriteDrawerArgs &args)
|
||||||
{
|
{
|
||||||
Queue->Push<DrawSpriteAddClamp32Command>(args);
|
Queue->Push<DrawSpriteAddClamp32Command>(args);
|
||||||
|
|
|
@ -243,6 +243,7 @@ namespace swrenderer
|
||||||
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override;
|
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) override;
|
void DrawTranslatedAddColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawShadedColumn(const SpriteDrawerArgs &args) override;
|
void DrawShadedColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
void DrawAddClampShadedColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawAddClampColumn(const SpriteDrawerArgs &args) override;
|
void DrawAddClampColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) override;
|
void DrawAddClampTranslatedColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawSubClampColumn(const SpriteDrawerArgs &args) override;
|
void DrawSubClampColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
|
|
@ -29,10 +29,11 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
namespace DrawSprite32TModes
|
namespace DrawSprite32TModes
|
||||||
{
|
{
|
||||||
enum class SpriteBlendModes { Copy, Opaque, Shaded, AddClamp, SubClamp, RevSubClamp };
|
enum class SpriteBlendModes { Copy, Opaque, Shaded, AddClampShaded, AddClamp, SubClamp, RevSubClamp };
|
||||||
struct CopySprite { static const int Mode = (int)SpriteBlendModes::Copy; };
|
struct CopySprite { static const int Mode = (int)SpriteBlendModes::Copy; };
|
||||||
struct OpaqueSprite { static const int Mode = (int)SpriteBlendModes::Opaque; };
|
struct OpaqueSprite { static const int Mode = (int)SpriteBlendModes::Opaque; };
|
||||||
struct ShadedSprite { static const int Mode = (int)SpriteBlendModes::Shaded; };
|
struct ShadedSprite { static const int Mode = (int)SpriteBlendModes::Shaded; };
|
||||||
|
struct AddClampShadedSprite { static const int Mode = (int)SpriteBlendModes::AddClampShaded; };
|
||||||
struct AddClampSprite { static const int Mode = (int)SpriteBlendModes::AddClamp; };
|
struct AddClampSprite { static const int Mode = (int)SpriteBlendModes::AddClamp; };
|
||||||
struct SubClampSprite { static const int Mode = (int)SpriteBlendModes::SubClamp; };
|
struct SubClampSprite { static const int Mode = (int)SpriteBlendModes::SubClamp; };
|
||||||
struct RevSubClampSprite { static const int Mode = (int)SpriteBlendModes::RevSubClamp; };
|
struct RevSubClampSprite { static const int Mode = (int)SpriteBlendModes::RevSubClamp; };
|
||||||
|
@ -381,6 +382,16 @@ namespace swrenderer
|
||||||
outcolor = _mm_or_si128(outcolor, _mm_set1_epi32(0xff000000));
|
outcolor = _mm_or_si128(outcolor, _mm_set1_epi32(0xff000000));
|
||||||
return outcolor;
|
return outcolor;
|
||||||
}
|
}
|
||||||
|
else if (BlendT::Mode == (int)SpriteBlendModes::AddClampShaded)
|
||||||
|
{
|
||||||
|
__m128i alpha = _mm_set_epi16(ifgshade1, ifgshade1, ifgshade1, ifgshade1, ifgshade0, ifgshade0, ifgshade0, ifgshade0);
|
||||||
|
|
||||||
|
fgcolor = _mm_srli_epi16(_mm_mullo_epi16(fgcolor, alpha), 8);
|
||||||
|
__m128i outcolor = _mm_add_epi16(fgcolor, bgcolor);
|
||||||
|
outcolor = _mm_packus_epi16(outcolor, _mm_setzero_si128());
|
||||||
|
outcolor = _mm_or_si128(outcolor, _mm_set1_epi32(0xff000000));
|
||||||
|
return outcolor;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint32_t alpha0 = APART(ifgcolor0);
|
uint32_t alpha0 = APART(ifgcolor0);
|
||||||
|
@ -448,6 +459,7 @@ namespace swrenderer
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::ShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteShaded32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::ShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteShaded32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteAddClampShaded32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
||||||
|
|
|
@ -432,12 +432,15 @@ namespace swrenderer
|
||||||
colfunc = &SWPixelFormatDrawers::DrawFuzzColumn;
|
colfunc = &SWPixelFormatDrawers::DrawFuzzColumn;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (style == LegacyRenderStyles[STYLE_Shaded])
|
else if (style == LegacyRenderStyles[STYLE_Shaded] || style == LegacyRenderStyles[STYLE_AddShaded])
|
||||||
{
|
{
|
||||||
// Shaded drawer only gets 16 levels of alpha because it saves memory.
|
// Shaded drawer only gets 16 levels of alpha because it saves memory.
|
||||||
if ((alpha >>= 12) == 0 || basecolormap == nullptr)
|
if ((alpha >>= 12) == 0 || basecolormap == nullptr)
|
||||||
return false;
|
return false;
|
||||||
colfunc = &SWPixelFormatDrawers::DrawShadedColumn;
|
if (style == LegacyRenderStyles[STYLE_Shaded])
|
||||||
|
colfunc = &SWPixelFormatDrawers::DrawShadedColumn;
|
||||||
|
else
|
||||||
|
colfunc = &SWPixelFormatDrawers::DrawAddClampShadedColumn;
|
||||||
drawer_needs_pal_input = true;
|
drawer_needs_pal_input = true;
|
||||||
CameraLight *cameraLight = CameraLight::Instance();
|
CameraLight *cameraLight = CameraLight::Instance();
|
||||||
dc_color = cameraLight->FixedColormap() ? cameraLight->FixedColormap()->Maps[APART(color)] : basecolormap->Maps[APART(color)];
|
dc_color = cameraLight->FixedColormap() ? cameraLight->FixedColormap()->Maps[APART(color)] : basecolormap->Maps[APART(color)];
|
||||||
|
|
Loading…
Reference in a new issue