Move rgba drawers to be dispatched by r_draw_tc

This commit is contained in:
Magnus Norddahl 2016-12-05 09:22:45 +01:00
parent 8a12d040de
commit 7ffab207cb
6 changed files with 2391 additions and 1278 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,31 @@
// Emacs style mode select -*- C++ -*- /*
//----------------------------------------------------------------------------- ** Drawer commands for the RT family of drawers
// ** Copyright (c) 2016 Magnus Norddahl
// $Id:$ **
// ** This software is provided 'as-is', without any express or implied
// Copyright (C) 1993-1996 by id Software, Inc. ** warranty. In no event will the authors be held liable for any damages
// ** arising from the use of this software.
// This source is available for distribution and/or modification **
// only under the terms of the DOOM Source Code License as ** Permission is granted to anyone to use this software for any purpose,
// published by id Software. All rights reserved. ** including commercial applications, and to alter it and redistribute it
// ** freely, subject to the following restrictions:
// The source is distributed in the hope that it will be useful, **
// but WITHOUT ANY WARRANTY; without even the implied warranty of ** 1. The origin of this software must not be misrepresented; you must not
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License ** claim that you wrote the original software. If you use this software
// for more details. ** in a product, an acknowledgment in the product documentation would be
// ** appreciated but is not required.
// DESCRIPTION: ** 2. Altered source versions must be plainly marked as such, and must not be
// System specific interface stuff. ** misrepresented as being the original software.
// ** 3. This notice may not be removed or altered from any source distribution.
//----------------------------------------------------------------------------- **
*/
#pragma once
#ifndef __R_DRAW_RGBA__
#define __R_DRAW_RGBA__
#include "r_draw.h" #include "r_draw.h"
#include "v_palette.h" #include "v_palette.h"
#include "r_thread.h" #include "r_thread.h"
#include "r_drawers.h"
#ifndef NO_SSE #ifndef NO_SSE
#include <immintrin.h> #include <immintrin.h>
@ -38,173 +38,511 @@ EXTERN_CVAR(Float, r_lod_bias)
namespace swrenderer namespace swrenderer
{ {
// Give the compiler a strong hint we want these functions inlined:
#ifndef FORCEINLINE
#if defined(_MSC_VER)
#define FORCEINLINE __forceinline
#elif defined(__GNUC__)
#define FORCEINLINE __attribute__((always_inline)) inline
#else
#define FORCEINLINE inline
#endif
#endif
///////////////////////////////////////////////////////////////////////////// // Promise compiler we have no aliasing of this pointer
// Drawer commands: #ifndef RESTRICT
#if defined(_MSC_VER)
#define RESTRICT __restrict
#elif defined(__GNUC__)
#define RESTRICT __restrict__
#else
#define RESTRICT
#endif
#endif
class ApplySpecialColormapRGBACommand : public DrawerCommand #define DECLARE_DRAW_COMMAND(name, func, base) \
{ class name##LLVMCommand : public base \
BYTE *buffer; { \
int pitch; public: \
int width; using base::base; \
int height; void Execute(DrawerThread *thread) override \
int start_red; { \
int start_green; WorkerThreadData d = ThreadData(thread); \
int start_blue; Drawers::Instance()->func(&args, &d); \
int end_red; } \
int end_green; };
int end_blue;
public: class DrawSpanLLVMCommand : public DrawerCommand
ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; }
};
template<typename CommandType, typename BlendMode>
class DrawerBlendCommand : public CommandType
{
public:
void Execute(DrawerThread *thread) override
{ {
typename CommandType::LoopIterator loop(this, thread); public:
if (!loop) return; DrawSpanLLVMCommand();
BlendMode blend(*this, loop);
do void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
protected:
DrawSpanArgs args;
private:
inline static bool sampler_setup(const uint32_t * &source, int &xbits, int &ybits, bool mipmapped);
};
class DrawSpanMaskedLLVMCommand : public DrawSpanLLVMCommand
{
public:
void Execute(DrawerThread *thread) override;
};
class DrawSpanTranslucentLLVMCommand : public DrawSpanLLVMCommand
{
public:
void Execute(DrawerThread *thread) override;
};
class DrawSpanMaskedTranslucentLLVMCommand : public DrawSpanLLVMCommand
{
public:
void Execute(DrawerThread *thread) override;
};
class DrawSpanAddClampLLVMCommand : public DrawSpanLLVMCommand
{
public:
void Execute(DrawerThread *thread) override;
};
class DrawSpanMaskedAddClampLLVMCommand : public DrawSpanLLVMCommand
{
public:
void Execute(DrawerThread *thread) override;
};
class DrawWall4LLVMCommand : public DrawerCommand
{
protected:
DrawWallArgs args;
WorkerThreadData ThreadData(DrawerThread *thread);
public:
DrawWall4LLVMCommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawWall1LLVMCommand : public DrawerCommand
{
protected:
DrawWallArgs args;
WorkerThreadData ThreadData(DrawerThread *thread);
public:
DrawWall1LLVMCommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawColumnLLVMCommand : public DrawerCommand
{
protected:
DrawColumnArgs args;
WorkerThreadData ThreadData(DrawerThread *thread);
FString DebugInfo() override;
public:
DrawColumnLLVMCommand();
void Execute(DrawerThread *thread) override;
};
class DrawSkyLLVMCommand : public DrawerCommand
{
protected:
DrawSkyArgs args;
WorkerThreadData ThreadData(DrawerThread *thread);
public:
DrawSkyLLVMCommand(uint32_t solid_top, uint32_t solid_bottom);
FString DebugInfo() override;
};
DECLARE_DRAW_COMMAND(DrawWallMasked4, mvlinec4, DrawWall4LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallAdd4, tmvline4_add, DrawWall4LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallAddClamp4, tmvline4_addclamp, DrawWall4LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallSubClamp4, tmvline4_subclamp, DrawWall4LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallRevSubClamp4, tmvline4_revsubclamp, DrawWall4LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallMasked1, mvlinec1, DrawWall1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallAdd1, tmvline1_add, DrawWall1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallAddClamp1, tmvline1_addclamp, DrawWall1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallSubClamp1, tmvline1_subclamp, DrawWall1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawWallRevSubClamp1, tmvline1_revsubclamp, DrawWall1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnAdd, DrawColumnAdd, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnTranslated, DrawColumnTranslated, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnTlatedAdd, DrawColumnTlatedAdd, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnShaded, DrawColumnShaded, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnAddClamp, DrawColumnAddClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnAddClampTranslated, DrawColumnAddClampTranslated, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnSubClamp, DrawColumnSubClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnSubClampTranslated, DrawColumnSubClampTranslated, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRevSubClamp, DrawColumnRevSubClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRevSubClampTranslated, DrawColumnRevSubClampTranslated, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(FillColumn, FillColumn, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(FillColumnAdd, FillColumnAdd, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(FillColumnAddClamp, FillColumnAddClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(FillColumnSubClamp, FillColumnSubClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(FillColumnRevSubClamp, FillColumnRevSubClamp, DrawColumnLLVMCommand);
DECLARE_DRAW_COMMAND(DrawSingleSky1, DrawSky1, DrawSkyLLVMCommand);
DECLARE_DRAW_COMMAND(DrawSingleSky4, DrawSky4, DrawSkyLLVMCommand);
DECLARE_DRAW_COMMAND(DrawDoubleSky1, DrawDoubleSky1, DrawSkyLLVMCommand);
DECLARE_DRAW_COMMAND(DrawDoubleSky4, DrawDoubleSky4, DrawSkyLLVMCommand);
class DrawFuzzColumnRGBACommand : public DrawerCommand
{
int _x;
int _yl;
int _yh;
uint8_t * RESTRICT _destorg;
int _pitch;
int _fuzzpos;
int _fuzzviewheight;
public:
DrawFuzzColumnRGBACommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class FillSpanRGBACommand : public DrawerCommand
{
int _x1;
int _x2;
int _y;
uint8_t * RESTRICT _destorg;
fixed_t _light;
int _color;
public:
FillSpanRGBACommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawSlabRGBACommand : public DrawerCommand
{
int _dx;
fixed_t _v;
int _dy;
fixed_t _vi;
const uint8_t *_voxelptr;
uint32_t *_p;
ShadeConstants _shade_constants;
const uint8_t *_colormap;
fixed_t _light;
int _pitch;
int _start_y;
public:
DrawSlabRGBACommand(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p, ShadeConstants shade_constants, const uint8_t *colormap, fixed_t light);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawFogBoundaryLineRGBACommand : public DrawerCommand
{
int _y;
int _x;
int _x2;
uint8_t * RESTRICT _destorg;
fixed_t _light;
ShadeConstants _shade_constants;
public:
DrawFogBoundaryLineRGBACommand(int y, int x, int x2);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawTiltedSpanRGBACommand : public DrawerCommand
{
int _x1;
int _x2;
int _y;
uint8_t * RESTRICT _destorg;
fixed_t _light;
ShadeConstants _shade_constants;
FVector3 _plane_sz;
FVector3 _plane_su;
FVector3 _plane_sv;
bool _plane_shade;
int _planeshade;
float _planelightfloat;
fixed_t _pviewx;
fixed_t _pviewy;
int _xbits;
int _ybits;
const uint32_t * RESTRICT _source;
public:
DrawTiltedSpanRGBACommand(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);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class DrawColoredSpanRGBACommand : public DrawerCommand
{
int _y;
int _x1;
int _x2;
uint8_t * RESTRICT _destorg;
fixed_t _light;
int _color;
public:
DrawColoredSpanRGBACommand(int y, int x1, int x2);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class FillTransColumnRGBACommand : public DrawerCommand
{
int _x;
int _y1;
int _y2;
int _color;
int _a;
uint8_t * RESTRICT _destorg;
int _pitch;
fixed_t _light;
public:
FillTransColumnRGBACommand(int x, int y1, int y2, int color, int a);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class ApplySpecialColormapRGBACommand : public DrawerCommand
{
uint8_t *buffer;
int pitch;
int width;
int height;
int start_red;
int start_green;
int start_blue;
int end_red;
int end_green;
int end_blue;
public:
ApplySpecialColormapRGBACommand(FSpecialColormap *colormap, DFrameBuffer *screen);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override { return "ApplySpecialColormapRGBACommand"; }
};
template<typename CommandType, typename BlendMode>
class DrawerBlendCommand : public CommandType
{
public:
void Execute(DrawerThread *thread) override
{ {
blend.Blend(*this, loop); typename CommandType::LoopIterator loop(this, thread);
} while (loop.next()); if (!loop) return;
} BlendMode blend(*this, loop);
}; do
{
blend.Blend(*this, loop);
} while (loop.next());
}
};
///////////////////////////////////////////////////////////////////////////// class DrawColumnRt1LLVMCommand : public DrawerCommand
// Pixel shading inline functions:
// Give the compiler a strong hint we want these functions inlined:
#ifndef FORCEINLINE
#if defined(_MSC_VER)
#define FORCEINLINE __forceinline
#elif defined(__GNUC__)
#define FORCEINLINE __attribute__((always_inline)) inline
#else
#define FORCEINLINE inline
#endif
#endif
// Promise compiler we have no aliasing of this pointer
#ifndef RESTRICT
#if defined(_MSC_VER)
#define RESTRICT __restrict
#elif defined(__GNUC__)
#define RESTRICT __restrict__
#else
#define RESTRICT
#endif
#endif
class LightBgra
{
public:
// calculates the light constant passed to the shade_pal_index function
FORCEINLINE static uint32_t calc_light_multiplier(dsfixed_t light)
{ {
return 256 - (light >> (FRACBITS - 8)); protected:
} DrawColumnArgs args;
WorkerThreadData ThreadData(DrawerThread *thread);
// Calculates a ARGB8 color for the given palette index and light multiplier public:
FORCEINLINE static uint32_t shade_pal_index_simple(uint32_t index, uint32_t light) DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh);
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand);
/////////////////////////////////////////////////////////////////////////////
class RtInitColsRGBACommand : public DrawerCommand
{ {
const PalEntry &color = GPalette.BaseColors[index]; BYTE * RESTRICT buff;
uint32_t red = color.r;
uint32_t green = color.g;
uint32_t blue = color.b;
red = red * light / 256; public:
green = green * light / 256; RtInitColsRGBACommand(BYTE *buff);
blue = blue * light / 256; void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
return 0xff000000 | (red << 16) | (green << 8) | blue; template<typename InputPixelType>
} class DrawColumnHorizRGBACommand : public DrawerCommand
// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap
FORCEINLINE static uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants)
{ {
const PalEntry &color = GPalette.BaseColors[index]; int _count;
uint32_t alpha = color.d & 0xff000000; fixed_t _iscale;
uint32_t red = color.r; fixed_t _texturefrac;
uint32_t green = color.g; const InputPixelType * RESTRICT _source;
uint32_t blue = color.b; int _x;
if (constants.simple_shade) int _yl;
int _yh;
public:
DrawColumnHorizRGBACommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
class FillColumnHorizRGBACommand : public DrawerCommand
{
int _x;
int _yl;
int _yh;
int _count;
uint32_t _color;
public:
FillColumnHorizRGBACommand();
void Execute(DrawerThread *thread) override;
FString DebugInfo() override;
};
/////////////////////////////////////////////////////////////////////////////
// Pixel shading inline functions:
class LightBgra
{
public:
// calculates the light constant passed to the shade_pal_index function
FORCEINLINE static uint32_t calc_light_multiplier(dsfixed_t light)
{ {
return 256 - (light >> (FRACBITS - 8));
}
// Calculates a ARGB8 color for the given palette index and light multiplier
FORCEINLINE static uint32_t shade_pal_index_simple(uint32_t index, uint32_t light)
{
const PalEntry &color = GPalette.BaseColors[index];
uint32_t red = color.r;
uint32_t green = color.g;
uint32_t blue = color.b;
red = red * light / 256; red = red * light / 256;
green = green * light / 256; green = green * light / 256;
blue = blue * light / 256; blue = blue * light / 256;
return 0xff000000 | (red << 16) | (green << 8) | blue;
} }
else
// Calculates a ARGB8 color for the given palette index, light multiplier and dynamic colormap
FORCEINLINE static uint32_t shade_pal_index(uint32_t index, uint32_t light, const ShadeConstants &constants)
{ {
uint32_t inv_light = 256 - light; const PalEntry &color = GPalette.BaseColors[index];
uint32_t inv_desaturate = 256 - constants.desaturate; uint32_t alpha = color.d & 0xff000000;
uint32_t red = color.r;
uint32_t green = color.g;
uint32_t blue = color.b;
if (constants.simple_shade)
{
red = red * light / 256;
green = green * light / 256;
blue = blue * light / 256;
}
else
{
uint32_t inv_light = 256 - light;
uint32_t inv_desaturate = 256 - constants.desaturate;
uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate;
red = (red * inv_desaturate + intensity) / 256; red = (red * inv_desaturate + intensity) / 256;
green = (green * inv_desaturate + intensity) / 256; green = (green * inv_desaturate + intensity) / 256;
blue = (blue * inv_desaturate + intensity) / 256; blue = (blue * inv_desaturate + intensity) / 256;
red = (constants.fade_red * inv_light + red * light) / 256; red = (constants.fade_red * inv_light + red * light) / 256;
green = (constants.fade_green * inv_light + green * light) / 256; green = (constants.fade_green * inv_light + green * light) / 256;
blue = (constants.fade_blue * inv_light + blue * light) / 256; blue = (constants.fade_blue * inv_light + blue * light) / 256;
red = (red * constants.light_red) / 256; red = (red * constants.light_red) / 256;
green = (green * constants.light_green) / 256; green = (green * constants.light_green) / 256;
blue = (blue * constants.light_blue) / 256; blue = (blue * constants.light_blue) / 256;
}
return alpha | (red << 16) | (green << 8) | blue;
} }
return alpha | (red << 16) | (green << 8) | blue;
}
FORCEINLINE static uint32_t shade_bgra_simple(uint32_t color, uint32_t light) FORCEINLINE static uint32_t shade_bgra_simple(uint32_t color, uint32_t light)
{
uint32_t red = RPART(color) * light / 256;
uint32_t green = GPART(color) * light / 256;
uint32_t blue = BPART(color) * light / 256;
return 0xff000000 | (red << 16) | (green << 8) | blue;
}
FORCEINLINE static uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants)
{
uint32_t alpha = color & 0xff000000;
uint32_t red = (color >> 16) & 0xff;
uint32_t green = (color >> 8) & 0xff;
uint32_t blue = color & 0xff;
if (constants.simple_shade)
{ {
red = red * light / 256; uint32_t red = RPART(color) * light / 256;
green = green * light / 256; uint32_t green = GPART(color) * light / 256;
blue = blue * light / 256; uint32_t blue = BPART(color) * light / 256;
return 0xff000000 | (red << 16) | (green << 8) | blue;
} }
else
FORCEINLINE static uint32_t shade_bgra(uint32_t color, uint32_t light, const ShadeConstants &constants)
{ {
uint32_t inv_light = 256 - light; uint32_t alpha = color & 0xff000000;
uint32_t inv_desaturate = 256 - constants.desaturate; uint32_t red = (color >> 16) & 0xff;
uint32_t green = (color >> 8) & 0xff;
uint32_t blue = color & 0xff;
if (constants.simple_shade)
{
red = red * light / 256;
green = green * light / 256;
blue = blue * light / 256;
}
else
{
uint32_t inv_light = 256 - light;
uint32_t inv_desaturate = 256 - constants.desaturate;
uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate; uint32_t intensity = ((red * 77 + green * 143 + blue * 37) >> 8) * constants.desaturate;
red = (red * inv_desaturate + intensity) / 256; red = (red * inv_desaturate + intensity) / 256;
green = (green * inv_desaturate + intensity) / 256; green = (green * inv_desaturate + intensity) / 256;
blue = (blue * inv_desaturate + intensity) / 256; blue = (blue * inv_desaturate + intensity) / 256;
red = (constants.fade_red * inv_light + red * light) / 256; red = (constants.fade_red * inv_light + red * light) / 256;
green = (constants.fade_green * inv_light + green * light) / 256; green = (constants.fade_green * inv_light + green * light) / 256;
blue = (constants.fade_blue * inv_light + blue * light) / 256; blue = (constants.fade_blue * inv_light + blue * light) / 256;
red = (red * constants.light_red) / 256; red = (red * constants.light_red) / 256;
green = (green * constants.light_green) / 256; green = (green * constants.light_green) / 256;
blue = (blue * constants.light_blue) / 256; blue = (blue * constants.light_blue) / 256;
}
return alpha | (red << 16) | (green << 8) | blue;
} }
return alpha | (red << 16) | (green << 8) | blue; };
}
};
} }
#endif

1411
src/r_draw_tc.cpp Normal file

File diff suppressed because it is too large Load diff

239
src/r_draw_tc.h Normal file
View file

@ -0,0 +1,239 @@
#pragma once
#include "r_defs.h"
struct FSWColormap;
EXTERN_CVAR(Bool, r_multithreaded);
EXTERN_CVAR(Bool, r_magfilter);
EXTERN_CVAR(Bool, r_minfilter);
EXTERN_CVAR(Bool, r_mipmap);
EXTERN_CVAR(Float, r_lod_bias);
EXTERN_CVAR(Int, r_drawfuzz);
EXTERN_CVAR(Bool, r_drawtrans);
EXTERN_CVAR(Float, transsouls);
EXTERN_CVAR(Int, r_columnmethod);
namespace swrenderer
{
struct vissprite_t;
struct ShadeConstants
{
uint16_t light_alpha;
uint16_t light_red;
uint16_t light_green;
uint16_t light_blue;
uint16_t fade_alpha;
uint16_t fade_red;
uint16_t fade_green;
uint16_t fade_blue;
uint16_t desaturate;
bool simple_shade;
};
extern double dc_texturemid;
namespace drawerargs
{
extern int dc_pitch;
extern lighttable_t *dc_colormap;
extern FSWColormap *dc_fcolormap;
extern ShadeConstants dc_shade_constants;
extern fixed_t dc_light;
extern int dc_x;
extern int dc_yl;
extern int dc_yh;
extern fixed_t dc_iscale;
extern fixed_t dc_texturefrac;
extern uint32_t dc_textureheight;
extern int dc_color;
extern uint32_t dc_srccolor;
extern uint32_t dc_srccolor_bgra;
extern uint32_t *dc_srcblend;
extern uint32_t *dc_destblend;
extern fixed_t dc_srcalpha;
extern fixed_t dc_destalpha;
extern const uint8_t *dc_source;
extern const uint8_t *dc_source2;
extern uint32_t dc_texturefracx;
extern uint8_t *dc_translation;
extern uint8_t *dc_dest;
extern uint8_t *dc_destorg;
extern int dc_destheight;
extern int dc_count;
extern bool drawer_needs_pal_input;
extern uint32_t vplce[4];
extern uint32_t vince[4];
extern uint8_t *palookupoffse[4];
extern fixed_t palookuplight[4];
extern const uint8_t *bufplce[4];
extern const uint8_t *bufplce2[4];
extern uint32_t buftexturefracx[4];
extern uint32_t bufheight[4];
extern int vlinebits;
extern int mvlinebits;
extern int tmvlinebits;
extern int ds_y;
extern int ds_x1;
extern int ds_x2;
extern lighttable_t * ds_colormap;
extern FSWColormap *ds_fcolormap;
extern ShadeConstants ds_shade_constants;
extern dsfixed_t ds_light;
extern dsfixed_t ds_xfrac;
extern dsfixed_t ds_yfrac;
extern dsfixed_t ds_xstep;
extern dsfixed_t ds_ystep;
extern int ds_xbits;
extern int ds_ybits;
extern fixed_t ds_alpha;
extern double ds_lod;
extern const uint8_t *ds_source;
extern bool ds_source_mipmapped;
extern int ds_color;
extern unsigned int dc_tspans[4][MAXHEIGHT];
extern unsigned int *dc_ctspan[4];
extern unsigned int *horizspan[4];
}
extern int ylookup[MAXHEIGHT];
extern uint8_t shadetables[/*NUMCOLORMAPS*16*256*/];
extern FDynamicColormap ShadeFakeColormap[16];
extern uint8_t identitymap[256];
extern FDynamicColormap identitycolormap;
// Spectre/Invisibility.
#define FUZZTABLE 50
extern int fuzzoffset[FUZZTABLE + 1];
extern int fuzzpos;
extern int fuzzviewheight;
extern bool r_swtruecolor;
void R_InitColumnDrawers();
void R_InitShadeMaps();
void R_InitFuzzTable(int fuzzoff);
enum ESPSResult
{
DontDraw, // not useful to draw this
DoDraw0, // draw this as if r_columnmethod is 0
DoDraw1, // draw this as if r_columnmethod is 1
};
ESPSResult R_SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color);
ESPSResult R_SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color);
void R_FinishSetPatchStyle(); // Call this after finished drawing the current thing, in case its style was STYLE_Shade
bool R_GetTransMaskDrawers(fixed_t(**tmvline1)(), void(**tmvline4)());
const uint8_t *R_GetColumn(FTexture *tex, int col);
void wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn);
void maskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn);
void transmaskwallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const uint8_t *(*getcol)(FTexture *tex, int col) = R_GetColumn);
void rt_initcols(uint8_t *buffer = nullptr);
void rt_span_coverage(int x, int start, int stop);
void rt_draw4cols(int sx);
void rt_flip_posts();
void rt_copy1col(int hx, int sx, int yl, int yh);
void rt_copy4cols(int sx, int yl, int yh);
void rt_shaded1col(int hx, int sx, int yl, int yh);
void rt_shaded4cols(int sx, int yl, int yh);
void rt_map1col(int hx, int sx, int yl, int yh);
void rt_add1col(int hx, int sx, int yl, int yh);
void rt_addclamp1col(int hx, int sx, int yl, int yh);
void rt_subclamp1col(int hx, int sx, int yl, int yh);
void rt_revsubclamp1col(int hx, int sx, int yl, int yh);
void rt_tlate1col(int hx, int sx, int yl, int yh);
void rt_tlateadd1col(int hx, int sx, int yl, int yh);
void rt_tlateaddclamp1col(int hx, int sx, int yl, int yh);
void rt_tlatesubclamp1col(int hx, int sx, int yl, int yh);
void rt_tlaterevsubclamp1col(int hx, int sx, int yl, int yh);
void rt_map4cols(int sx, int yl, int yh);
void rt_add4cols(int sx, int yl, int yh);
void rt_addclamp4cols(int sx, int yl, int yh);
void rt_subclamp4cols(int sx, int yl, int yh);
void rt_revsubclamp4cols(int sx, int yl, int yh);
void rt_tlate4cols(int sx, int yl, int yh);
void rt_tlateadd4cols(int sx, int yl, int yh);
void rt_tlateaddclamp4cols(int sx, int yl, int yh);
void rt_tlatesubclamp4cols(int sx, int yl, int yh);
void rt_tlaterevsubclamp4cols(int sx, int yl, int yh);
void R_DrawColumnHoriz();
void R_DrawColumn();
void R_DrawFuzzColumn();
void R_DrawTranslatedColumn();
void R_DrawShadedColumn();
void R_FillColumn();
void R_FillAddColumn();
void R_FillAddClampColumn();
void R_FillSubClampColumn();
void R_FillRevSubClampColumn();
void R_DrawAddColumn();
void R_DrawTlatedAddColumn();
void R_DrawAddClampColumn();
void R_DrawAddClampTranslatedColumn();
void R_DrawSubClampColumn();
void R_DrawSubClampTranslatedColumn();
void R_DrawRevSubClampColumn();
void R_DrawRevSubClampTranslatedColumn();
void R_DrawSpan();
void R_DrawSpanMasked();
void R_DrawSpanTranslucent();
void R_DrawSpanMaskedTranslucent();
void R_DrawSpanAddClamp();
void R_DrawSpanMaskedAddClamp();
void R_FillSpan();
void R_DrawTiltedSpan(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);
void R_DrawColoredSpan(int y, int x1, int x2);
void R_SetupDrawSlab(FSWColormap *base_colormap, float light, int shade);
void R_DrawSlab(int dx, fixed_t v, int dy, fixed_t vi, const uint8_t *vptr, uint8_t *p);
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip);
uint32_t vlinec1();
void vlinec4();
uint32_t mvlinec1();
void mvlinec4();
fixed_t tmvline1_add();
void tmvline4_add();
fixed_t tmvline1_addclamp();
void tmvline4_addclamp();
fixed_t tmvline1_subclamp();
void tmvline4_subclamp();
fixed_t tmvline1_revsubclamp();
void tmvline4_revsubclamp();
void R_FillColumnHoriz();
void R_FillSpan();
inline uint32_t dovline1() { return vlinec1(); }
inline void dovline4() { vlinec4(); }
inline uint32_t domvline1() { return mvlinec1(); }
inline void domvline4() { mvlinec4(); }
void setupvline(int fracbits);
void setupmvline(int fracbits);
void setuptmvline(int fracbits);
void R_DrawSingleSkyCol1(uint32_t solid_top, uint32_t solid_bottom);
void R_DrawSingleSkyCol4(uint32_t solid_top, uint32_t solid_bottom);
void R_DrawDoubleSkyCol1(uint32_t solid_top, uint32_t solid_bottom);
void R_DrawDoubleSkyCol4(uint32_t solid_top, uint32_t solid_bottom);
// Sets dc_colormap and dc_light to their appropriate values depending on the output format (pal vs true color)
void R_SetColorMapLight(FSWColormap *base_colormap, float light, int shade);
void R_SetDSColorMapLight(FSWColormap *base_colormap, float light, int shade);
void R_SetTranslationMap(lighttable_t *translation);
void R_SetupSpanBits(FTexture *tex);
void R_SetSpanColormap(FDynamicColormap *colormap, int shade);
void R_SetSpanSource(FTexture *tex);
void R_MapTiltedPlane(int y, int x1);
void R_MapColoredPlane(int y, int x1);
void R_DrawParticle(vissprite_t *);
}

View file

@ -1,37 +1,23 @@
/* /*
** r_drawt_rgba.cpp ** Drawer commands for the RT family of drawers
** Faster column drawers for modern processors, true color edition ** Copyright (c) 2016 Magnus Norddahl
** **
**--------------------------------------------------------------------------- ** This software is provided 'as-is', without any express or implied
** Copyright 1998-2006 Randy Heit ** warranty. In no event will the authors be held liable for any damages
** All rights reserved. ** arising from the use of this software.
** **
** Redistribution and use in source and binary forms, with or without ** Permission is granted to anyone to use this software for any purpose,
** modification, are permitted provided that the following conditions ** including commercial applications, and to alter it and redistribute it
** are met: ** freely, subject to the following restrictions:
** **
** 1. Redistributions of source code must retain the above copyright ** 1. The origin of this software must not be misrepresented; you must not
** notice, this list of conditions and the following disclaimer. ** claim that you wrote the original software. If you use this software
** 2. Redistributions in binary form must reproduce the above copyright ** in a product, an acknowledgment in the product documentation would be
** notice, this list of conditions and the following disclaimer in the ** appreciated but is not required.
** documentation and/or other materials provided with the distribution. ** 2. Altered source versions must be plainly marked as such, and must not be
** 3. The name of the author may not be used to endorse or promote products ** misrepresented as being the original software.
** derived from this software without specific prior written permission. ** 3. This notice may not be removed or altered from any source distribution.
** **
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
** True color versions of the similar functions in r_drawt.cpp
** Please see r_drawt.cpp for a description of the globals used.
*/ */
#include "templates.h" #include "templates.h"
@ -47,15 +33,7 @@
namespace swrenderer namespace swrenderer
{ {
WorkerThreadData DrawColumnRt1LLVMCommand::ThreadData(DrawerThread *thread)
/////////////////////////////////////////////////////////////////////////////
class DrawColumnRt1LLVMCommand : public DrawerCommand
{
protected:
DrawColumnArgs args;
WorkerThreadData ThreadData(DrawerThread *thread)
{ {
WorkerThreadData d; WorkerThreadData d;
d.core = thread->core; d.core = thread->core;
@ -66,8 +44,7 @@ protected:
return d; return d;
} }
public: DrawColumnRt1LLVMCommand::DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh)
DrawColumnRt1LLVMCommand(int hx, int sx, int yl, int yh)
{ {
using namespace drawerargs; using namespace drawerargs;
@ -105,90 +82,38 @@ public:
DetectRangeError(args.dest, args.dest_y, args.count); DetectRangeError(args.dest, args.dest_y, args.count);
} }
void Execute(DrawerThread *thread) override void DrawColumnRt1LLVMCommand::Execute(DrawerThread *thread)
{ {
WorkerThreadData d = ThreadData(thread); WorkerThreadData d = ThreadData(thread);
Drawers::Instance()->DrawColumnRt1(&args, &d); Drawers::Instance()->DrawColumnRt1(&args, &d);
} }
FString DebugInfo() override FString DrawColumnRt1LLVMCommand::DebugInfo()
{ {
return "DrawColumnRt\n" + args.ToString(); return "DrawColumnRt\n" + args.ToString();
} }
};
#define DECLARE_DRAW_COMMAND(name, func, base) \ /////////////////////////////////////////////////////////////////////////////
class name##LLVMCommand : public base \
{ \
public: \
using base::base; \
void Execute(DrawerThread *thread) override \
{ \
WorkerThreadData d = ThreadData(thread); \
Drawers::Instance()->func(&args, &d); \
} \
};
DECLARE_DRAW_COMMAND(DrawColumnRt1Copy, DrawColumnRt1Copy, DrawColumnRt1LLVMCommand); RtInitColsRGBACommand::RtInitColsRGBACommand(BYTE *buff)
DECLARE_DRAW_COMMAND(DrawColumnRt1Add, DrawColumnRt1Add, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1Shaded, DrawColumnRt1Shaded, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1AddClamp, DrawColumnRt1AddClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1SubClamp, DrawColumnRt1SubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClamp, DrawColumnRt1RevSubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1Translated, DrawColumnRt1Translated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1TlatedAdd, DrawColumnRt1TlatedAdd, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1AddClampTranslated, DrawColumnRt1AddClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1SubClampTranslated, DrawColumnRt1SubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt1RevSubClampTranslated, DrawColumnRt1RevSubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4, DrawColumnRt4, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Copy, DrawColumnRt4Copy, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Add, DrawColumnRt4Add, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Shaded, DrawColumnRt4Shaded, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4AddClamp, DrawColumnRt4AddClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4SubClamp, DrawColumnRt4SubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClamp, DrawColumnRt4RevSubClamp, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4Translated, DrawColumnRt4Translated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4TlatedAdd, DrawColumnRt4TlatedAdd, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4AddClampTranslated, DrawColumnRt4AddClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4SubClampTranslated, DrawColumnRt4SubClampTranslated, DrawColumnRt1LLVMCommand);
DECLARE_DRAW_COMMAND(DrawColumnRt4RevSubClampTranslated, DrawColumnRt4RevSubClampTranslated, DrawColumnRt1LLVMCommand);
/////////////////////////////////////////////////////////////////////////////
class RtInitColsRGBACommand : public DrawerCommand
{
BYTE * RESTRICT buff;
public:
RtInitColsRGBACommand(BYTE *buff)
{ {
this->buff = buff; this->buff = buff;
} }
void Execute(DrawerThread *thread) override void RtInitColsRGBACommand::Execute(DrawerThread *thread)
{ {
thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff; thread->dc_temp_rgba = buff == NULL ? thread->dc_temp_rgbabuff_rgba : (uint32_t*)buff;
} }
FString DebugInfo() override FString RtInitColsRGBACommand::DebugInfo()
{ {
return "RtInitCols"; return "RtInitCols";
} }
};
template<typename InputPixelType> /////////////////////////////////////////////////////////////////////////////
class DrawColumnHorizRGBACommand : public DrawerCommand
{
int _count;
fixed_t _iscale;
fixed_t _texturefrac;
const InputPixelType * RESTRICT _source;
int _x;
int _yl;
int _yh;
public: template<typename InputPixelType>
DrawColumnHorizRGBACommand() DrawColumnHorizRGBACommand<InputPixelType>::DrawColumnHorizRGBACommand()
{ {
using namespace drawerargs; using namespace drawerargs;
@ -201,7 +126,8 @@ public:
_yh = dc_yh; _yh = dc_yh;
} }
void Execute(DrawerThread *thread) override template<typename InputPixelType>
void DrawColumnHorizRGBACommand<InputPixelType>::Execute(DrawerThread *thread)
{ {
int count = _count; int count = _count;
uint32_t *dest; uint32_t *dest;
@ -252,22 +178,19 @@ public:
} while (--count); } while (--count);
} }
FString DebugInfo() override template<typename InputPixelType>
FString DrawColumnHorizRGBACommand<InputPixelType>::DebugInfo()
{ {
return "DrawColumnHoriz"; return "DrawColumnHoriz";
} }
};
class FillColumnHorizRGBACommand : public DrawerCommand // Generate code for the versions we use:
{ template class DrawColumnHorizRGBACommand<uint8_t>;
int _x; template class DrawColumnHorizRGBACommand<uint32_t>;
int _yl;
int _yh;
int _count;
uint32_t _color;
public: /////////////////////////////////////////////////////////////////////////////
FillColumnHorizRGBACommand()
FillColumnHorizRGBACommand::FillColumnHorizRGBACommand()
{ {
using namespace drawerargs; using namespace drawerargs;
@ -278,7 +201,7 @@ public:
_yh = dc_yh; _yh = dc_yh;
} }
void Execute(DrawerThread *thread) override void FillColumnHorizRGBACommand::Execute(DrawerThread *thread)
{ {
int count = _count; int count = _count;
uint32_t color = _color; uint32_t color = _color;
@ -304,220 +227,8 @@ public:
} while (--count); } while (--count);
} }
FString DebugInfo() override FString FillColumnHorizRGBACommand::DebugInfo()
{ {
return "FillColumnHoriz"; return "FillColumnHoriz";
} }
};
/////////////////////////////////////////////////////////////////////////////
// Copies one span at hx to the screen at sx.
void rt_copy1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1CopyLLVMCommand>(hx, sx, yl, yh);
}
// Copies all four spans to the screen starting at sx.
void rt_copy4cols_rgba (int sx, int yl, int yh)
{
// To do: we could do this with SSE using __m128i
rt_copy1col_rgba(0, sx, yl, yh);
rt_copy1col_rgba(1, sx + 1, yl, yh);
rt_copy1col_rgba(2, sx + 2, yl, yh);
rt_copy1col_rgba(3, sx + 3, yl, yh);
}
// Maps one span at hx to the screen at sx.
void rt_map1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1LLVMCommand>(hx, sx, yl, yh);
}
// Maps all four spans to the screen starting at sx.
void rt_map4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4LLVMCommand>(0, sx, yl, yh);
}
// Translates one span at hx to the screen at sx.
void rt_tlate1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1TranslatedLLVMCommand>(hx, sx, yl, yh);
}
// Translates all four spans to the screen starting at sx.
void rt_tlate4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4TranslatedLLVMCommand>(0, sx, yl, yh);
}
// Adds one span at hx to the screen at sx without clamping.
void rt_add1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddLLVMCommand>(hx, sx, yl, yh);
}
// Adds all four spans to the screen starting at sx without clamping.
void rt_add4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddLLVMCommand>(0, sx, yl, yh);
}
// Translates and adds one span at hx to the screen at sx without clamping.
void rt_tlateadd1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampTranslatedLLVMCommand>(hx, sx, yl, yh);
}
// Translates and adds all four spans to the screen starting at sx without clamping.
void rt_tlateadd4cols_rgba(int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampTranslatedLLVMCommand>(0, sx, yl, yh);
}
// Shades one span at hx to the screen at sx.
void rt_shaded1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1ShadedLLVMCommand>(hx, sx, yl, yh);
}
// Shades all four spans to the screen starting at sx.
void rt_shaded4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4ShadedLLVMCommand>(0, sx, yl, yh);
}
// Adds one span at hx to the screen at sx with clamping.
void rt_addclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampLLVMCommand>(hx, sx, yl, yh);
}
// Adds all four spans to the screen starting at sx with clamping.
void rt_addclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampLLVMCommand>(0, sx, yl, yh);
}
// Translates and adds one span at hx to the screen at sx with clamping.
void rt_tlateaddclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1AddClampTranslatedLLVMCommand>(hx, sx, yl, yh);
}
// Translates and adds all four spans to the screen starting at sx with clamping.
void rt_tlateaddclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4AddClampTranslatedLLVMCommand>(0, sx, yl, yh);
}
// Subtracts one span at hx to the screen at sx with clamping.
void rt_subclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1SubClampLLVMCommand>(hx, sx, yl, yh);
}
// Subtracts all four spans to the screen starting at sx with clamping.
void rt_subclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampLLVMCommand>(0, sx, yl, yh);
}
// Translates and subtracts one span at hx to the screen at sx with clamping.
void rt_tlatesubclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1SubClampTranslatedLLVMCommand>(hx, sx, yl, yh);
}
// Translates and subtracts all four spans to the screen starting at sx with clamping.
void rt_tlatesubclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampTranslatedLLVMCommand>(0, sx, yl, yh);
}
// Subtracts one span at hx from the screen at sx with clamping.
void rt_revsubclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1RevSubClampLLVMCommand>(hx, sx, yl, yh);
}
// Subtracts all four spans from the screen starting at sx with clamping.
void rt_revsubclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4SubClampLLVMCommand>(0, sx, yl, yh);
}
// Translates and subtracts one span at hx from the screen at sx with clamping.
void rt_tlaterevsubclamp1col_rgba (int hx, int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt1RevSubClampTranslatedLLVMCommand>(hx, sx, yl, yh);
}
// Translates and subtracts all four spans from the screen starting at sx with clamping.
void rt_tlaterevsubclamp4cols_rgba (int sx, int yl, int yh)
{
DrawerCommandQueue::QueueCommand<DrawColumnRt4RevSubClampTranslatedLLVMCommand>(0, sx, yl, yh);
}
// Before each pass through a rendering loop that uses these routines,
// call this function to set up the span pointers.
void rt_initcols_rgba (BYTE *buff)
{
using namespace drawerargs;
for (int y = 3; y >= 0; y--)
horizspan[y] = dc_ctspan[y] = &dc_tspans[y][0];
DrawerCommandQueue::QueueCommand<RtInitColsRGBACommand>(buff);
}
void rt_span_coverage_rgba(int x, int start, int stop)
{
using namespace drawerargs;
unsigned int **tspan = &dc_ctspan[x & 3];
(*tspan)[0] = start;
(*tspan)[1] = stop;
*tspan += 2;
}
// Stretches a column into a temporary buffer which is later
// drawn to the screen along with up to three other columns.
void R_DrawColumnHoriz_rgba (void)
{
using namespace drawerargs;
if (dc_count <= 0)
return;
int x = dc_x & 3;
unsigned int **span = &dc_ctspan[x];
(*span)[0] = dc_yl;
(*span)[1] = dc_yh;
*span += 2;
if (drawer_needs_pal_input)
DrawerCommandQueue::QueueCommand<DrawColumnHorizRGBACommand<uint8_t>>();
else
DrawerCommandQueue::QueueCommand<DrawColumnHorizRGBACommand<uint32_t>>();
}
// [RH] Just fills a column with a given color
void R_FillColumnHoriz_rgba (void)
{
using namespace drawerargs;
if (dc_count <= 0)
return;
int x = dc_x & 3;
unsigned int **span = &dc_ctspan[x];
(*span)[0] = dc_yl;
(*span)[1] = dc_yh;
*span += 2;
DrawerCommandQueue::QueueCommand<FillColumnHorizRGBACommand>();
}
} }

View file

@ -511,9 +511,9 @@ void R_MapTiltedPlane_C (int y, int x1)
#endif #endif
} }
void R_MapTiltedPlane_rgba (int y, int x1) void R_MapTiltedPlane (int y, int x1)
{ {
R_DrawTiltedSpan_rgba(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy); R_DrawTiltedSpan(y, x1, spanend[y], plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy);
} }
//========================================================================== //==========================================================================
@ -527,9 +527,9 @@ void R_MapColoredPlane_C (int y, int x1)
memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1); memset (ylookup[y] + x1 + dc_destorg, ds_color, spanend[y] - x1 + 1);
} }
void R_MapColoredPlane_rgba(int y, int x1) void R_MapColoredPlane(int y, int x1)
{ {
R_DrawColoredSpan_rgba(y, x1, spanend[y]); R_DrawColoredSpan(y, x1, spanend[y]);
} }
//========================================================================== //==========================================================================
@ -1073,32 +1073,16 @@ static void R_DrawSkyColumnStripe(int start_x, int y1, int y2, int columns, doub
uint32_t solid_top = frontskytex->GetSkyCapColor(false); uint32_t solid_top = frontskytex->GetSkyCapColor(false);
uint32_t solid_bottom = frontskytex->GetSkyCapColor(true); uint32_t solid_bottom = frontskytex->GetSkyCapColor(true);
if (r_swtruecolor) if (columns == 4)
{ if (!backskytex)
if (columns == 4) R_DrawSingleSkyCol4(solid_top, solid_bottom);
if (!backskytex)
R_DrawSingleSkyCol4_rgba(solid_top, solid_bottom);
else
R_DrawDoubleSkyCol4_rgba(solid_top, solid_bottom);
else else
if (!backskytex) R_DrawDoubleSkyCol4(solid_top, solid_bottom);
R_DrawSingleSkyCol1_rgba(solid_top, solid_bottom);
else
R_DrawDoubleSkyCol1_rgba(solid_top, solid_bottom);
}
else else
{ if (!backskytex)
if (columns == 4) R_DrawSingleSkyCol1(solid_top, solid_bottom);
if (!backskytex)
R_DrawSingleSkyCol4(solid_top, solid_bottom);
else
R_DrawDoubleSkyCol4(solid_top, solid_bottom);
else else
if (!backskytex) R_DrawDoubleSkyCol1(solid_top, solid_bottom);
R_DrawSingleSkyCol1(solid_top, solid_bottom);
else
R_DrawDoubleSkyCol1(solid_top, solid_bottom);
}
} }
static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns) static void R_DrawSkyColumn(int start_x, int y1, int y2, int columns)