mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-21 11:31:41 +00:00
- add nitevis software drawers - todo: hook them up to the sprite code
This commit is contained in:
parent
52b7a77771
commit
52dcec7e85
7 changed files with 230 additions and 2 deletions
|
@ -66,7 +66,9 @@ namespace swrenderer
|
||||||
virtual void DrawSingleSkyColumn(const SkyDrawerArgs &args) = 0;
|
virtual void DrawSingleSkyColumn(const SkyDrawerArgs &args) = 0;
|
||||||
virtual void DrawDoubleSkyColumn(const SkyDrawerArgs &args) = 0;
|
virtual void DrawDoubleSkyColumn(const SkyDrawerArgs &args) = 0;
|
||||||
virtual void DrawColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
virtual void DrawNiteVisColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void FillColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void FillColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
virtual void FillNiteVisColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void FillAddColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void FillAddColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void FillAddClampColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void FillAddClampColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void FillSubClampColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void FillSubClampColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
@ -74,6 +76,7 @@ namespace swrenderer
|
||||||
virtual void DrawFuzzColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawFuzzColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawAddColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawAddColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
virtual void DrawTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
virtual void DrawTranslatedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
virtual void DrawTranslatedNiteVisColumn(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 DrawAddClampShadedColumn(const SpriteDrawerArgs &args) = 0;
|
||||||
|
|
|
@ -933,6 +933,107 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawColumnNiteVisPalCommand::Execute(DrawerThread *thread)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
uint8_t *dest;
|
||||||
|
fixed_t frac;
|
||||||
|
fixed_t fracstep;
|
||||||
|
|
||||||
|
count = args.Count();
|
||||||
|
|
||||||
|
// Framebuffer destination address.
|
||||||
|
dest = args.Dest();
|
||||||
|
|
||||||
|
// Determine scaling,
|
||||||
|
// which is the only mapping to be done.
|
||||||
|
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;
|
||||||
|
|
||||||
|
// [RH] Get local copies of these variables so that the compiler
|
||||||
|
// has a better chance of optimizing this well.
|
||||||
|
const uint8_t *colormap = args.Colormap(args.Viewport());
|
||||||
|
const uint8_t *source = args.TexturePixels();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
uint8_t fg = source[frac >> FRACBITS];
|
||||||
|
|
||||||
|
// lumi is a desaturated colour and goes between 0.0 and 1.0, this is intentional
|
||||||
|
float lumi = ((float)GPalette.BaseColors[colormap[fg]].r * 30.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].g * 59.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].b * 11.f) / 25500.f;
|
||||||
|
float r = 255.f - lumi * 255.f;
|
||||||
|
float g = clamp(511.f - lumi * 511.f, 0.f, 255.f);
|
||||||
|
float b = 255.f - lumi * 255.f;
|
||||||
|
*dest = RGB256k.RGB[(int)r>>2][(int)g>>2][(int)b>>2];
|
||||||
|
|
||||||
|
dest += pitch;
|
||||||
|
frac += fracstep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawColumnTranslatedNiteVisPalCommand::Execute(DrawerThread *thread)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
uint8_t *dest;
|
||||||
|
fixed_t frac;
|
||||||
|
fixed_t fracstep;
|
||||||
|
|
||||||
|
count = args.Count();
|
||||||
|
|
||||||
|
// Framebuffer destination address.
|
||||||
|
dest = args.Dest();
|
||||||
|
|
||||||
|
// Determine scaling,
|
||||||
|
// which is the only mapping to be done.
|
||||||
|
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 *translation = args.TranslationMap();
|
||||||
|
|
||||||
|
// [RH] Get local copies of these variables so that the compiler
|
||||||
|
// has a better chance of optimizing this well.
|
||||||
|
const uint8_t *colormap = args.Colormap(args.Viewport());
|
||||||
|
const uint8_t *source = args.TexturePixels();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
uint8_t fg = translation[source[frac >> FRACBITS]];
|
||||||
|
|
||||||
|
// lumi is a desaturated colour and goes between 0.0 and 1.0, this is intentional
|
||||||
|
float lumi = ((float)GPalette.BaseColors[colormap[fg]].r * 30.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].g * 59.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].b * 11.f) / 25500.f;
|
||||||
|
float r = 255.f - lumi * 255.f;
|
||||||
|
float g = clamp(511.f - lumi * 511.f, 0.f, 255.f);
|
||||||
|
float b = 255.f - lumi * 255.f;
|
||||||
|
*dest = RGB256k.RGB[(int)r>>2][(int)g>>2][(int)b>>2];
|
||||||
|
|
||||||
|
dest += pitch;
|
||||||
|
frac += fracstep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
|
||||||
void FillColumnPalCommand::Execute(DrawerThread *thread)
|
void FillColumnPalCommand::Execute(DrawerThread *thread)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
@ -957,6 +1058,55 @@ namespace swrenderer
|
||||||
} while (--count);
|
} while (--count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FillColumnNiteVisPalCommand::Execute(DrawerThread *thread)
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
uint8_t *dest;
|
||||||
|
fixed_t frac;
|
||||||
|
fixed_t fracstep;
|
||||||
|
|
||||||
|
count = args.Count();
|
||||||
|
|
||||||
|
// Framebuffer destination address.
|
||||||
|
dest = args.Dest();
|
||||||
|
|
||||||
|
// Determine scaling,
|
||||||
|
// which is the only mapping to be done.
|
||||||
|
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;
|
||||||
|
|
||||||
|
// [RH] Get local copies of these variables so that the compiler
|
||||||
|
// has a better chance of optimizing this well.
|
||||||
|
const uint8_t *colormap = args.Colormap(args.Viewport());
|
||||||
|
const uint8_t *source = args.TexturePixels();
|
||||||
|
|
||||||
|
uint8_t fg = args.SolidColor();
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// lumi is a desaturated colour and goes between 0.0 and 1.0, this is intentional
|
||||||
|
float lumi = ((float)GPalette.BaseColors[colormap[fg]].r * 30.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].g * 59.f +
|
||||||
|
GPalette.BaseColors[colormap[fg]].b * 11.f) / 25500.f;
|
||||||
|
float r = 255.f - lumi * 255.f;
|
||||||
|
float g = clamp(511.f - lumi * 511.f, 0.f, 255.f);
|
||||||
|
float b = 255.f - lumi * 255.f;
|
||||||
|
*dest = RGB256k.RGB[(int)r>>2][(int)g>>2][(int)b>>2];
|
||||||
|
|
||||||
|
dest += pitch;
|
||||||
|
frac += fracstep;
|
||||||
|
} while (--count);
|
||||||
|
}
|
||||||
|
|
||||||
void FillColumnAddPalCommand::Execute(DrawerThread *thread)
|
void FillColumnAddPalCommand::Execute(DrawerThread *thread)
|
||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
|
|
|
@ -53,13 +53,16 @@ namespace swrenderer
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawColumnPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
class DrawColumnNiteVisPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class FillColumnPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class FillColumnPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
class FillColumnNiteVisPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class FillColumnAddPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class FillColumnAddPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class FillColumnAddClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class FillColumnAddClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class FillColumnSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class FillColumnSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class FillColumnRevSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class FillColumnRevSubClampPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
class DrawColumnAddPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
class DrawColumnAddPalCommand : 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 DrawColumnTranslatedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
class DrawColumnTranslatedNiteVisPalCommand : 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 DrawColumnAddClampShadedPalCommand : public PalColumnCommand { public: using PalColumnCommand::PalColumnCommand; void Execute(DrawerThread *thread) override; };
|
||||||
|
@ -247,7 +250,9 @@ namespace swrenderer
|
||||||
void DrawSingleSkyColumn(const SkyDrawerArgs &args) override { Queue->Push<DrawSingleSky1PalCommand>(args); }
|
void DrawSingleSkyColumn(const SkyDrawerArgs &args) override { Queue->Push<DrawSingleSky1PalCommand>(args); }
|
||||||
void DrawDoubleSkyColumn(const SkyDrawerArgs &args) override { Queue->Push<DrawDoubleSky1PalCommand>(args); }
|
void DrawDoubleSkyColumn(const SkyDrawerArgs &args) override { Queue->Push<DrawDoubleSky1PalCommand>(args); }
|
||||||
void DrawColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnPalCommand>(args); }
|
void DrawColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnPalCommand>(args); }
|
||||||
|
void DrawNiteVisColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnNiteVisPalCommand>(args); }
|
||||||
void FillColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnPalCommand>(args); }
|
void FillColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnPalCommand>(args); }
|
||||||
|
void FillNiteVisColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnNiteVisPalCommand>(args); }
|
||||||
void FillAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnAddPalCommand>(args); }
|
void FillAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnAddPalCommand>(args); }
|
||||||
void FillAddClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnAddClampPalCommand>(args); }
|
void FillAddClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnAddClampPalCommand>(args); }
|
||||||
void FillSubClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnSubClampPalCommand>(args); }
|
void FillSubClampColumn(const SpriteDrawerArgs &args) override { Queue->Push<FillColumnSubClampPalCommand>(args); }
|
||||||
|
@ -262,6 +267,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
void DrawAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddPalCommand>(args); }
|
void DrawAddColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddPalCommand>(args); }
|
||||||
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTranslatedPalCommand>(args); }
|
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTranslatedPalCommand>(args); }
|
||||||
|
void DrawTranslatedNiteVisColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnTranslatedNiteVisPalCommand>(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 DrawAddClampShadedColumn(const SpriteDrawerArgs &args) override { Queue->Push<DrawColumnAddClampShadedPalCommand>(args); }
|
||||||
|
|
|
@ -115,11 +115,21 @@ namespace swrenderer
|
||||||
Queue->Push<DrawSprite32Command>(args);
|
Queue->Push<DrawSprite32Command>(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SWTruecolorDrawers::DrawNiteVisColumn(const SpriteDrawerArgs &args)
|
||||||
|
{
|
||||||
|
Queue->Push<DrawSpriteNiteVis32Command>(args);
|
||||||
|
}
|
||||||
|
|
||||||
void SWTruecolorDrawers::FillColumn(const SpriteDrawerArgs &args)
|
void SWTruecolorDrawers::FillColumn(const SpriteDrawerArgs &args)
|
||||||
{
|
{
|
||||||
Queue->Push<FillSprite32Command>(args);
|
Queue->Push<FillSprite32Command>(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SWTruecolorDrawers::FillNiteVisColumn(const SpriteDrawerArgs &args)
|
||||||
|
{
|
||||||
|
Queue->Push<FillSpriteNiteVis32Command>(args);
|
||||||
|
}
|
||||||
|
|
||||||
void SWTruecolorDrawers::FillAddColumn(const SpriteDrawerArgs &args)
|
void SWTruecolorDrawers::FillAddColumn(const SpriteDrawerArgs &args)
|
||||||
{
|
{
|
||||||
Queue->Push<FillSpriteAddClamp32Command>(args);
|
Queue->Push<FillSpriteAddClamp32Command>(args);
|
||||||
|
@ -159,6 +169,11 @@ namespace swrenderer
|
||||||
Queue->Push<DrawSpriteTranslated32Command>(args);
|
Queue->Push<DrawSpriteTranslated32Command>(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SWTruecolorDrawers::DrawTranslatedNiteVisColumn(const SpriteDrawerArgs &args)
|
||||||
|
{
|
||||||
|
Queue->Push<DrawSpriteTranslatedNiteVis32Command>(args);
|
||||||
|
}
|
||||||
|
|
||||||
void SWTruecolorDrawers::DrawTranslatedAddColumn(const SpriteDrawerArgs &args)
|
void SWTruecolorDrawers::DrawTranslatedAddColumn(const SpriteDrawerArgs &args)
|
||||||
{
|
{
|
||||||
Queue->Push<DrawSpriteTranslatedAddClamp32Command>(args);
|
Queue->Push<DrawSpriteTranslatedAddClamp32Command>(args);
|
||||||
|
|
|
@ -253,7 +253,9 @@ namespace swrenderer
|
||||||
void DrawSingleSkyColumn(const SkyDrawerArgs &args) override;
|
void DrawSingleSkyColumn(const SkyDrawerArgs &args) override;
|
||||||
void DrawDoubleSkyColumn(const SkyDrawerArgs &args) override;
|
void DrawDoubleSkyColumn(const SkyDrawerArgs &args) override;
|
||||||
void DrawColumn(const SpriteDrawerArgs &args) override;
|
void DrawColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
void DrawNiteVisColumn(const SpriteDrawerArgs &args) override;
|
||||||
void FillColumn(const SpriteDrawerArgs &args) override;
|
void FillColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
void FillNiteVisColumn(const SpriteDrawerArgs &args) override;
|
||||||
void FillAddColumn(const SpriteDrawerArgs &args) override;
|
void FillAddColumn(const SpriteDrawerArgs &args) override;
|
||||||
void FillAddClampColumn(const SpriteDrawerArgs &args) override;
|
void FillAddClampColumn(const SpriteDrawerArgs &args) override;
|
||||||
void FillSubClampColumn(const SpriteDrawerArgs &args) override;
|
void FillSubClampColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
@ -261,6 +263,7 @@ namespace swrenderer
|
||||||
void DrawFuzzColumn(const SpriteDrawerArgs &args) override;
|
void DrawFuzzColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawAddColumn(const SpriteDrawerArgs &args) override;
|
void DrawAddColumn(const SpriteDrawerArgs &args) override;
|
||||||
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override;
|
void DrawTranslatedColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
void DrawTranslatedNiteVisColumn(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 DrawAddClampShadedColumn(const SpriteDrawerArgs &args) override;
|
||||||
|
|
|
@ -29,9 +29,10 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
namespace DrawSprite32TModes
|
namespace DrawSprite32TModes
|
||||||
{
|
{
|
||||||
enum class SpriteBlendModes { Copy, Opaque, Shaded, AddClampShaded, AddClamp, SubClamp, RevSubClamp };
|
enum class SpriteBlendModes { Copy, Opaque, NiteVis, 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 NiteVisSprite { static const int Mode = (int)SpriteBlendModes::NiteVis; };
|
||||||
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 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; };
|
||||||
|
@ -325,6 +326,19 @@ namespace swrenderer
|
||||||
fgcolor.a = 255;
|
fgcolor.a = 255;
|
||||||
return fgcolor;
|
return fgcolor;
|
||||||
}
|
}
|
||||||
|
if (BlendT::Mode == (int)SpriteBlendModes::NiteVis)
|
||||||
|
{
|
||||||
|
// lumi is a desaturated colour and goes between 0.0 and 1.0, this is intentional
|
||||||
|
float lumi = ((float)fgcolor.r * 30.0f +
|
||||||
|
fgcolor.g * 59.0f +
|
||||||
|
fgcolor.b * 11.0f) / 25500.0f;
|
||||||
|
|
||||||
|
fgcolor.r = int(255.0f - lumi * 255.0f);
|
||||||
|
fgcolor.g = int(clamp(511.0f - lumi * 511.0f, 0.0f, 255.0f));
|
||||||
|
fgcolor.b = int(255.0f - lumi * 255.0f);
|
||||||
|
fgcolor.a = 255;
|
||||||
|
return fgcolor;
|
||||||
|
}
|
||||||
else if (BlendT::Mode == (int)SpriteBlendModes::Shaded)
|
else if (BlendT::Mode == (int)SpriteBlendModes::Shaded)
|
||||||
{
|
{
|
||||||
uint32_t alpha = ifgshade;
|
uint32_t alpha = ifgshade;
|
||||||
|
@ -391,11 +405,13 @@ namespace swrenderer
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::CopySprite, DrawSprite32TModes::TextureSampler> DrawSpriteCopy32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::CopySprite, DrawSprite32TModes::TextureSampler> DrawSpriteCopy32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TextureSampler> DrawSprite32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TextureSampler> DrawSprite32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::TextureSampler> DrawSpriteNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteRevSubClamp32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::FillSampler> FillSprite32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::FillSampler> FillSprite32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::FillSampler> FillSpriteNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::FillSampler> FillSpriteAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::FillSampler> FillSpriteAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
||||||
|
@ -404,6 +420,7 @@ namespace swrenderer
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteAddClampShaded32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteAddClampShaded32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedRevSubClamp32Command;
|
||||||
|
|
|
@ -29,9 +29,10 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
namespace DrawSprite32TModes
|
namespace DrawSprite32TModes
|
||||||
{
|
{
|
||||||
enum class SpriteBlendModes { Copy, Opaque, Shaded, AddClampShaded, AddClamp, SubClamp, RevSubClamp };
|
enum class SpriteBlendModes { Copy, Opaque, NiteVis, 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 NiteVisSprite { static const int Mode = (int)SpriteBlendModes::NiteVis; };
|
||||||
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 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; };
|
||||||
|
@ -371,6 +372,36 @@ namespace swrenderer
|
||||||
outcolor = _mm_or_si128(outcolor, _mm_set1_epi32(0xff000000));
|
outcolor = _mm_or_si128(outcolor, _mm_set1_epi32(0xff000000));
|
||||||
return outcolor;
|
return outcolor;
|
||||||
}
|
}
|
||||||
|
if (BlendT::Mode == (int)SpriteBlendModes::NiteVis)
|
||||||
|
{
|
||||||
|
// this is a WIP, todo: translate this to SSE2 instructions later
|
||||||
|
// i am writing it this way for now so the implementation can be changed and
|
||||||
|
// finalized before going full SSE2
|
||||||
|
// it is easier to understand and change in this form, but it's incredibly slow
|
||||||
|
BgraColor bgra_fgcolor[2];
|
||||||
|
BgraColor bgra_outcolor[2];
|
||||||
|
|
||||||
|
_mm_storeu_si128((__m128i*)&bgra_fgcolor[0], _mm_unpacklo_epi16(fgcolor, _mm_setzero_si128()));
|
||||||
|
_mm_storeu_si128((__m128i*)&bgra_fgcolor[1], _mm_unpackhi_epi16(fgcolor, _mm_setzero_si128()));
|
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
|
{
|
||||||
|
// lumi is a desaturated colour and goes between 0.0 and 1.0, this is intentional
|
||||||
|
float lumi = ((float)bgra_fgcolor[i].r * 30.0f +
|
||||||
|
bgra_fgcolor[i].g * 59.0f +
|
||||||
|
bgra_fgcolor[i].b * 11.0f) / 25500.0f;
|
||||||
|
|
||||||
|
bgra_outcolor[i].r = int(255.0f - lumi * 255.0f);
|
||||||
|
bgra_outcolor[i].g = int(clamp(511.0f - lumi * 511.0f, 0.0f, 255.0f));
|
||||||
|
bgra_outcolor[i].b = int(255.0f - lumi * 255.0f);
|
||||||
|
bgra_outcolor[i].a = 255;
|
||||||
|
}
|
||||||
|
|
||||||
|
__m128i outcolor = _mm_packs_epi32(_mm_loadu_si128((__m128i*)&bgra_outcolor[0]), _mm_loadu_si128((__m128i*)&bgra_outcolor[1]));
|
||||||
|
_mm_packus_epi16(outcolor, _mm_setzero_si128());
|
||||||
|
|
||||||
|
return outcolor;
|
||||||
|
}
|
||||||
else if (BlendT::Mode == (int)SpriteBlendModes::Shaded)
|
else if (BlendT::Mode == (int)SpriteBlendModes::Shaded)
|
||||||
{
|
{
|
||||||
__m128i alpha = _mm_set_epi16(ifgshade1, ifgshade1, ifgshade1, ifgshade1, ifgshade0, ifgshade0, ifgshade0, ifgshade0);
|
__m128i alpha = _mm_set_epi16(ifgshade1, ifgshade1, ifgshade1, ifgshade1, ifgshade0, ifgshade0, ifgshade0, ifgshade0);
|
||||||
|
@ -448,11 +479,13 @@ namespace swrenderer
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::CopySprite, DrawSprite32TModes::TextureSampler> DrawSpriteCopy32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::CopySprite, DrawSprite32TModes::TextureSampler> DrawSpriteCopy32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TextureSampler> DrawSprite32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TextureSampler> DrawSprite32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::TextureSampler> DrawSpriteNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TextureSampler> DrawSpriteRevSubClamp32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::FillSampler> FillSprite32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::FillSampler> FillSprite32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::FillSampler> FillSpriteNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::FillSampler> FillSpriteAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::FillSampler> FillSpriteAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::FillSampler> FillSpriteRevSubClamp32Command;
|
||||||
|
@ -461,6 +494,7 @@ namespace swrenderer
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteAddClampShaded32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampShadedSprite, DrawSprite32TModes::ShadedSampler> DrawSpriteAddClampShaded32Command;
|
||||||
|
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::OpaqueSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslated32Command;
|
||||||
|
typedef DrawSprite32T<DrawSprite32TModes::NiteVisSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedNiteVis32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::AddClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedAddClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::SubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedSubClamp32Command;
|
||||||
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedRevSubClamp32Command;
|
typedef DrawSprite32T<DrawSprite32TModes::RevSubClampSprite, DrawSprite32TModes::TranslatedSampler> DrawSpriteTranslatedRevSubClamp32Command;
|
||||||
|
|
Loading…
Reference in a new issue