Remove old polyargs

This commit is contained in:
Magnus Norddahl 2019-12-02 00:01:04 +01:00
parent 4a4b79194d
commit d2f4570337
6 changed files with 19 additions and 449 deletions

View File

@ -11,8 +11,6 @@
#pragma warning(disable:4250)
#endif
struct TriVertex;
class PolyBuffer : virtual public IBuffer
{
public:

View File

@ -40,23 +40,9 @@
void PolyDrawArgs::SetTexture(const uint8_t *texels, int width, int height)
{
mTexture = nullptr;
mTexturePixels = texels;
mTextureWidth = width;
mTextureHeight = height;
mTranslation = nullptr;
}
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
{
mTexture = texture;
mTextureWidth = texture->GetPhysicalWidth();
mTextureHeight = texture->GetPhysicalHeight();
if (PolyTriangleDrawer::IsBgra())
mTexturePixels = (const uint8_t *)texture->GetPixelsBgra();
else
mTexturePixels = texture->GetPixels(style);
mTranslation = nullptr;
}
void PolyDrawArgs::SetTexture2(const uint8_t* texels, int width, int height)
@ -65,291 +51,3 @@ void PolyDrawArgs::SetTexture2(const uint8_t* texels, int width, int height)
mTexture2Width = width;
mTexture2Height = height;
}
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
{
// Alphatexture overrides translations.
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
{
FRemapTable *table = TranslationToTable(translationID);
if (table != nullptr && !table->Inactive)
{
if (PolyTriangleDrawer::IsBgra())
mTranslation = (uint8_t*)table->Palette;
else
mTranslation = table->Remap;
mTexture = texture;
mTextureWidth = texture->GetPhysicalWidth();
mTextureHeight = texture->GetPhysicalHeight();
mTexturePixels = texture->GetPixels(style);
return;
}
}
if (style.Flags & STYLEF_RedIsAlpha)
{
mTexture = texture;
mTextureWidth = texture->GetPhysicalWidth();
mTextureHeight = texture->GetPhysicalHeight();
mTexturePixels = texture->GetPixels(style);
}
else
{
SetTexture(texture, style);
}
}
void PolyDrawArgs::SetLight(FSWColormap *base_colormap, uint32_t lightlevel, double globVis, bool fixed)
{
mGlobVis = (float)globVis;
mLight = clamp<uint32_t>(lightlevel, 0, 255);
mFixedLight = fixed;
mLightRed = base_colormap->Color.r;
mLightRed += mLightRed >> 7;
mLightGreen = base_colormap->Color.g;
mLightGreen += mLightGreen >> 7;
mLightBlue = base_colormap->Color.b;
mLightBlue += mLightBlue >> 7;
mLightAlpha = base_colormap->Color.a;
mLightAlpha += mLightAlpha >> 7;
mFadeRed = base_colormap->Fade.r;
mFadeRed += mFadeRed >> 7;
mFadeGreen = base_colormap->Fade.g;
mFadeGreen += mFadeGreen >> 7;
mFadeBlue = base_colormap->Fade.b;
mFadeBlue += mFadeBlue >> 7;
mFadeAlpha = base_colormap->Fade.a;
mFadeAlpha += mFadeAlpha >> 7;
mDesaturate = MIN(abs(base_colormap->Desaturate), 255);
mDesaturate += mDesaturate >> 7;
mSimpleShade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
mColormaps = base_colormap->Maps;
}
void PolyDrawArgs::SetColor(uint32_t bgra, uint8_t palindex)
{
if (PolyTriangleDrawer::IsBgra())
{
mColor = bgra;
}
else
{
mColor = palindex;
}
}
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
{
SetTexture(tex, translationID, renderstyle);
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
if (renderstyle == LegacyRenderStyles[STYLE_Normal] || (r_drawfuzz == 0 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetStyle(Translation() ? TriBlendMode::NormalTranslated : TriBlendMode::Normal, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Add] && fullbright && alpha == 1.0 && !Translation())
{
SetStyle(TriBlendMode::SrcColor, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_SoulTrans])
{
SetStyle(Translation() ? TriBlendMode::AddTranslated : TriBlendMode::Add, transsouls);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Fuzzy] || (r_drawfuzz == 1 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetColor(0xff000000, 0);
SetStyle(TriBlendMode::Fuzzy);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Shadow] || (r_drawfuzz == 2 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetColor(0xff000000, 0);
SetStyle(Translation() ? TriBlendMode::TranslucentStencilTranslated : TriBlendMode::TranslucentStencil, 1.0 - 160 / 255.0);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Stencil])
{
SetStyle(Translation() ? TriBlendMode::StencilTranslated : TriBlendMode::Stencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Translucent])
{
SetStyle(Translation() ? TriBlendMode::TranslucentTranslated : TriBlendMode::Translucent, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Add])
{
SetStyle(Translation() ? TriBlendMode::AddTranslated : TriBlendMode::Add, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Shaded])
{
SetStyle(Translation() ? TriBlendMode::ShadedTranslated : TriBlendMode::Shaded, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_TranslucentStencil])
{
SetStyle(Translation() ? TriBlendMode::TranslucentStencilTranslated : TriBlendMode::TranslucentStencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Subtract])
{
SetStyle(Translation() ? TriBlendMode::SubtractTranslated : TriBlendMode::Subtract, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_AddStencil])
{
SetStyle(Translation() ? TriBlendMode::AddStencilTranslated : TriBlendMode::AddStencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_AddShaded])
{
SetStyle(Translation() ? TriBlendMode::AddShadedTranslated : TriBlendMode::AddShaded, alpha);
}
}
/////////////////////////////////////////////////////////////////////////////
#if 0
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
{
mTexture = texture;
mTextureWidth = texture->GetWidth();
mTextureHeight = texture->GetHeight();
if (PolyTriangleDrawer::IsBgra())
mTexturePixels = (const uint8_t *)texture->GetPixelsBgra();
else
mTexturePixels = texture->GetPixels(style);
mTranslation = nullptr;
}
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
{
// Alphatexture overrides translations.
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
{
FRemapTable *table = TranslationToTable(translationID);
if (table != nullptr && !table->Inactive)
{
if (PolyTriangleDrawer::IsBgra())
mTranslation = (uint8_t*)table->Palette;
else
mTranslation = table->Remap;
mTexture = texture;
mTextureWidth = texture->GetWidth();
mTextureHeight = texture->GetHeight();
mTexturePixels = texture->GetPixels(style);
return;
}
}
if (style.Flags & STYLEF_RedIsAlpha)
{
mTexture = texture;
mTextureWidth = texture->GetWidth();
mTextureHeight = texture->GetHeight();
mTexturePixels = texture->GetPixels(style);
}
else
{
SetTexture(texture, style);
}
}
void RectDrawArgs::SetLight(FSWColormap *base_colormap, uint32_t lightlevel)
{
mLight = clamp<uint32_t>(lightlevel, 0, 255);
mLightRed = base_colormap->Color.r * 256 / 255;
mLightGreen = base_colormap->Color.g * 256 / 255;
mLightBlue = base_colormap->Color.b * 256 / 255;
mLightAlpha = base_colormap->Color.a * 256 / 255;
mFadeRed = base_colormap->Fade.r;
mFadeGreen = base_colormap->Fade.g;
mFadeBlue = base_colormap->Fade.b;
mFadeAlpha = base_colormap->Fade.a;
mDesaturate = MIN(abs(base_colormap->Desaturate), 255) * 255 / 256;
mSimpleShade = (base_colormap->Color.d == 0x00ffffff && base_colormap->Fade.d == 0x00000000 && base_colormap->Desaturate == 0);
mColormaps = base_colormap->Maps;
}
void RectDrawArgs::SetColor(uint32_t bgra, uint8_t palindex)
{
if (PolyTriangleDrawer::IsBgra())
{
mColor = bgra;
}
else
{
mColor = palindex;
}
}
void RectDrawArgs::Draw(PolyRenderThread *thread, double x0, double x1, double y0, double y1, double u0, double u1, double v0, double v1)
{
mX0 = (float)x0;
mX1 = (float)x1;
mY0 = (float)y0;
mY1 = (float)y1;
mU0 = (float)u0;
mU1 = (float)u1;
mV0 = (float)v0;
mV1 = (float)v1;
thread->DrawQueue->Push<DrawRectCommand>(*this);
}
void RectDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
{
SetTexture(tex, translationID, renderstyle);
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
if (renderstyle == LegacyRenderStyles[STYLE_Normal] || (r_drawfuzz == 0 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetStyle(Translation() ? TriBlendMode::NormalTranslated : TriBlendMode::Normal, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Add] && fullbright && alpha == 1.0 && !Translation())
{
SetStyle(TriBlendMode::SrcColor, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_SoulTrans])
{
SetStyle(Translation() ? TriBlendMode::AddTranslated : TriBlendMode::Add, transsouls);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Fuzzy] || (r_drawfuzz == 1 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetColor(0xff000000, 0);
SetStyle(TriBlendMode::Fuzzy);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Shadow] || (r_drawfuzz == 2 && renderstyle == LegacyRenderStyles[STYLE_OptFuzzy]))
{
SetColor(0xff000000, 0);
SetStyle(Translation() ? TriBlendMode::TranslucentStencilTranslated : TriBlendMode::TranslucentStencil, 1.0 - 160 / 255.0);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Stencil])
{
SetStyle(Translation() ? TriBlendMode::StencilTranslated : TriBlendMode::Stencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Translucent])
{
SetStyle(Translation() ? TriBlendMode::TranslucentTranslated : TriBlendMode::Translucent, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Add])
{
SetStyle(Translation() ? TriBlendMode::AddTranslated : TriBlendMode::Add, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Shaded])
{
SetStyle(Translation() ? TriBlendMode::ShadedTranslated : TriBlendMode::Shaded, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_TranslucentStencil])
{
SetStyle(Translation() ? TriBlendMode::TranslucentStencilTranslated : TriBlendMode::TranslucentStencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_Subtract])
{
SetStyle(Translation() ? TriBlendMode::SubtractTranslated : TriBlendMode::Subtract, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_AddStencil])
{
SetStyle(Translation() ? TriBlendMode::AddStencilTranslated : TriBlendMode::AddStencil, alpha);
}
else if (renderstyle == LegacyRenderStyles[STYLE_AddShaded])
{
SetStyle(Translation() ? TriBlendMode::AddShadedTranslated : TriBlendMode::AddShaded, alpha);
}
}
#endif

View File

@ -26,75 +26,23 @@
#include "r_data/colormaps.h"
#include "screen_triangle.h"
class PolyRenderThread;
class FSoftwareTexture;
class Mat4f;
enum class PolyDrawMode
{
Points,
Lines,
Triangles,
TriangleFan,
TriangleStrip
};
class PolyClipPlane
{
public:
PolyClipPlane() : A(0.0f), B(0.0f), C(0.0f), D(1.0f) { }
PolyClipPlane(float a, float b, float c, float d) : A(a), B(b), C(c), D(d) { }
float A, B, C, D;
};
struct TriVertex
{
TriVertex() { }
TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w), u(u), v(v) { }
float x, y, z, w;
float u, v;
};
struct PolyLight
{
uint32_t color;
float x, y, z;
float radius;
};
class PolyDrawArgs
{
public:
//void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
void SetTexture(const uint8_t *texels, int width, int height);
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
void SetTexture2(const uint8_t* texels, int width, int height);
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed);
void SetNoColormap() { mLight = 255; mFixedLight = true; mLightRed = 256; mLightGreen = 256; mLightBlue = 256; mLightAlpha = 256; mFadeRed = 0; mFadeGreen = 0; mFadeBlue = 0; mFadeAlpha = 0; mDesaturate = 0; mSimpleShade = true; mColormaps = nullptr; }
void SetDepthTest(bool enable) { mDepthTest = enable; }
void SetStencilTest(bool enable) { mStencilTest = enable; }
void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; }
void SetWriteColor(bool enable) { mWriteColor = enable; }
void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; }
void SetWriteDepth(bool enable) { mWriteDepth = enable; }
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *texture, bool fullbright);
void SetColor(uint32_t bgra, uint8_t palindex);
void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; }
void SetDynLightColor(uint32_t color) { mDynLightColor = color; }
//const PolyClipPlane &ClipPlane(int index) const { return mClipPlane[index]; }
bool WriteColor() const { return mWriteColor; }
FSoftwareTexture *Texture() const { return mTexture; }
const uint8_t *TexturePixels() const { return mTexturePixels; }
int TextureWidth() const { return mTextureWidth; }
int TextureHeight() const { return mTextureHeight; }
const uint8_t *Translation() const { return mTranslation; }
const uint8_t* Texture2Pixels() const { return mTexture2Pixels; }
int Texture2Width() const { return mTexture2Width; }
@ -108,71 +56,18 @@ public:
bool DepthTest() const { return mDepthTest; }
bool WriteDepth() const { return mWriteDepth; }
TriBlendMode BlendMode() const { return mBlendMode; }
uint32_t Color() const { return mColor; }
uint32_t Alpha() const { return mAlpha; }
float GlobVis() const { return mGlobVis; }
uint32_t Light() const { return mLight; }
const uint8_t *BaseColormap() const { return mColormaps; }
uint16_t ShadeLightAlpha() const { return mLightAlpha; }
uint16_t ShadeLightRed() const { return mLightRed; }
uint16_t ShadeLightGreen() const { return mLightGreen; }
uint16_t ShadeLightBlue() const { return mLightBlue; }
uint16_t ShadeFadeAlpha() const { return mFadeAlpha; }
uint16_t ShadeFadeRed() const { return mFadeRed; }
uint16_t ShadeFadeGreen() const { return mFadeGreen; }
uint16_t ShadeFadeBlue() const { return mFadeBlue; }
uint16_t ShadeDesaturate() const { return mDesaturate; }
bool SimpleShade() const { return mSimpleShade; }
bool NearestFilter() const { return mNearestFilter; }
bool FixedLight() const { return mFixedLight; }
PolyLight *Lights() const { return mLights; }
int NumLights() const { return mNumLights; }
uint32_t DynLightColor() const { return mDynLightColor; }
const FVector3 &Normal() const { return mNormal; }
void SetNormal(const FVector3 &normal) { mNormal = normal; }
private:
bool mDepthTest = false;
bool mStencilTest = true;
bool mWriteStencil = true;
bool mWriteColor = true;
bool mWriteDepth = true;
FSoftwareTexture *mTexture = nullptr;
const uint8_t *mTexturePixels = nullptr;
int mTextureWidth = 0;
int mTextureHeight = 0;
const uint8_t *mTranslation = nullptr;
const uint8_t* mTexture2Pixels = nullptr;
int mTexture2Width = 0;
int mTexture2Height = 0;
uint8_t mStencilTestValue = 0;
uint8_t mStencilWriteValue = 0;
const uint8_t *mColormaps = nullptr;
PolyClipPlane mClipPlane[3];
TriBlendMode mBlendMode = TriBlendMode::Fill;
uint32_t mLight = 0;
uint32_t mColor = 0;
uint32_t mAlpha = 0;
uint16_t mLightAlpha = 0;
uint16_t mLightRed = 0;
uint16_t mLightGreen = 0;
uint16_t mLightBlue = 0;
uint16_t mFadeAlpha = 0;
uint16_t mFadeRed = 0;
uint16_t mFadeGreen = 0;
uint16_t mFadeBlue = 0;
uint16_t mDesaturate = 0;
float mGlobVis = 0.0f;
bool mSimpleShade = true;
bool mNearestFilter = true;
bool mFixedLight = false;
PolyLight *mLights = nullptr;
int mNumLights = 0;
FVector3 mNormal;
uint32_t mDynLightColor = 0;
};

View File

@ -264,7 +264,7 @@ void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPu
PushConstants = &constants;
int numLights = 0;
/*int numLights = 0;
if (constants.uLightIndex >= 0)
{
const FVector4 &lightRange = lights[constants.uLightIndex];
@ -298,7 +298,7 @@ void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPu
}
}
}
drawargs.SetLights(polyLights, numLights);
drawargs.SetLights(polyLights, numLights);*/
}
void PolyTriangleThreadData::PushMatrices(const VSMatrix &modelMatrix, const VSMatrix &normalModelMatrix, const VSMatrix &textureMatrix)
@ -691,9 +691,6 @@ void PolyTriangleThreadData::DrawShadedTriangle(const ShadedTriVertex *const* ve
if (IsDegenerate(vert))
return;
drawargs.SetColor(vert[0]->vColor, 0);
drawargs.SetNormal(FVector3(vert[0]->vWorldNormal.X, vert[0]->vWorldNormal.Y, vert[0]->vWorldNormal.Z));
// Cull, clip and generate additional vertices as needed
ScreenTriVertex clippedvert[max_additional_vertices];
int numclipvert = ClipEdge(vert);

View File

@ -35,6 +35,15 @@ class PolyInputAssembly;
class PolyDepthStencil;
struct PolyPushConstants;
enum class PolyDrawMode
{
Points,
Lines,
Triangles,
TriangleFan,
TriangleStrip
};
class PolyTriangleDrawer
{
public:
@ -225,8 +234,15 @@ public:
const unsigned int *elements = nullptr;
const FVector4 *lights = nullptr;
/*struct PolyLight
{
uint32_t color;
float x, y, z;
float radius;
};
enum { maxPolyLights = 16 };
PolyLight polyLights[maxPolyLights];
PolyLight polyLights[maxPolyLights];*/
PolyMainVertexShader mainVertexShader;

View File

@ -93,40 +93,6 @@ private:
}
};
enum class TriBlendMode
{
Opaque,
Skycap,
FogBoundary,
SrcColor,
Fill,
FillTranslucent,
Normal,
AlphaTest,
Fuzzy,
Stencil,
Translucent,
Add,
Shaded,
TranslucentStencil,
Shadow,
Subtract,
AddStencil,
AddShaded,
OpaqueTranslated,
SrcColorTranslated,
NormalTranslated,
StencilTranslated,
TranslucentTranslated,
AddTranslated,
ShadedTranslated,
TranslucentStencilTranslated,
ShadowTranslated,
SubtractTranslated,
AddStencilTranslated,
AddShadedTranslated
};
class ScreenTriangle
{
public: