Skip to content
Permalink
Browse files

Remove PolyDrawArgs

  • Loading branch information
dpjudas committed Dec 1, 2019
1 parent d2f4570 commit 74c6b9fe6dcd3d86cfee26e5cc67e0b23492bc4b
@@ -708,7 +708,6 @@ set ( SWRENDER_SOURCES

set( POLYRENDER_SOURCES
rendering/polyrenderer/drawers/poly_triangle.cpp
rendering/polyrenderer/drawers/poly_draw_args.cpp
rendering/polyrenderer/drawers/screen_triangle.cpp
rendering/polyrenderer/math/gpu_types.cpp
)

This file was deleted.

This file was deleted.

@@ -319,18 +319,18 @@ void PolyTriangleThreadData::SetDepthClamp(bool on)

void PolyTriangleThreadData::SetDepthMask(bool on)
{
drawargs.SetWriteDepth(on);
WriteDepth = on;
}

void PolyTriangleThreadData::SetDepthFunc(int func)
{
if (func == DF_LEqual || func == DF_Less)
{
drawargs.SetDepthTest(true);
DepthTest = true;
}
else if (func == DF_Always)
{
drawargs.SetDepthTest(false);
DepthTest = false;
}
}

@@ -352,23 +352,26 @@ void PolyTriangleThreadData::SetDepthBias(float depthBiasConstantFactor, float d

void PolyTriangleThreadData::SetColorMask(bool r, bool g, bool b, bool a)
{
drawargs.SetWriteColor(r);
WriteColor = r;
}

void PolyTriangleThreadData::SetStencil(int stencilRef, int op)
{
drawargs.SetStencilTestValue(stencilRef);
StencilTestValue = stencilRef;
if (op == SOP_Increment)
{
drawargs.SetWriteStencil(drawargs.StencilTest(), MIN(stencilRef + 1, (int)255));
WriteStencil = StencilTest;
StencilWriteValue = MIN(stencilRef + 1, (int)255);
}
else if (op == SOP_Decrement)
{
drawargs.SetWriteStencil(drawargs.StencilTest(), MAX(stencilRef - 1, (int)0));
WriteStencil = StencilTest;
StencilWriteValue = MAX(stencilRef - 1, (int)0);
}
else // SOP_Keep
{
drawargs.SetWriteStencil(false, stencilRef);
WriteStencil = false;
StencilWriteValue = stencilRef;
}
}

@@ -384,13 +387,13 @@ void PolyTriangleThreadData::EnableClipDistance(int num, bool state)

void PolyTriangleThreadData::EnableStencil(bool on)
{
drawargs.SetStencilTest(on);
drawargs.SetWriteStencil(on && drawargs.StencilTestValue() != drawargs.StencilWriteValue(), drawargs.StencilWriteValue());
StencilTest = on;
WriteStencil = on && StencilTestValue != StencilWriteValue;
}

void PolyTriangleThreadData::EnableDepthTest(bool on)
{
drawargs.SetDepthTest(on);
DepthTest = on;
}

void PolyTriangleThreadData::SetRenderStyle(FRenderStyle style)
@@ -407,10 +410,10 @@ void PolyTriangleThreadData::SetShader(int specialEffect, int effectState, bool

void PolyTriangleThreadData::SetTexture(int unit, void *pixels, int width, int height)
{
if (unit == 0)
drawargs.SetTexture((uint8_t*)pixels, width, height);
else if (unit == 1)
drawargs.SetTexture2((uint8_t*)pixels, width, height);
textures[unit].pixels = (uint8_t*)pixels;
textures[unit].width = width;
textures[unit].height = height;
textures[unit].bgra = true;
}

void PolyTriangleThreadData::DrawIndexed(int index, int vcount, PolyDrawMode drawmode)
@@ -26,7 +26,6 @@
#include "swrenderer/drawers/r_thread.h"
#include "polyrenderer/drawers/screen_triangle.h"
#include "polyrenderer/math/gpu_types.h"
#include "polyrenderer/drawers/poly_draw_args.h"
#include "polyrenderer/drawers/poly_vertex_shader.h"

class DCanvas;
@@ -228,8 +227,6 @@ class PolyTriangleThreadData
bool AlphaTest = false;
const PolyPushConstants* PushConstants = nullptr;

PolyDrawArgs drawargs;

const void *vertices = nullptr;
const unsigned int *elements = nullptr;
const FVector4 *lights = nullptr;
@@ -246,6 +243,22 @@ class PolyTriangleThreadData

PolyMainVertexShader mainVertexShader;

struct TextureUnit
{
const uint8_t* pixels = nullptr;
int width = 0;
int height = 0;
bool bgra = true;
} textures[16];

bool DepthTest = false;
bool StencilTest = true;
bool WriteStencil = true;
bool WriteColor = true;
bool WriteDepth = true;
uint8_t StencilTestValue = 0;
uint8_t StencilWriteValue = 0;

private:
ShadedTriVertex ShadeVertex(int index);
void DrawShadedPoint(const ShadedTriVertex *const* vertex);
@@ -319,7 +319,7 @@ static void WriteStencil(int y, int x0, int x1, PolyTriangleThreadData* thread)
{
size_t pitch = thread->depthstencil->Width();
uint8_t* line = thread->depthstencil->StencilValues() + pitch * y;
uint8_t value = thread->drawargs.StencilWriteValue();
uint8_t value = thread->StencilWriteValue;
if (!thread->AlphaTest)
{
for (int x = x0; x < x1; x++)
@@ -375,13 +375,13 @@ static void RunShader(int x0, int x1, PolyTriangleThreadData* thread)
}
else if (thread->SpecialEffect == EFF_BURN) // burn.fp
{
int texWidth = thread->drawargs.TextureWidth();
int texHeight = thread->drawargs.TextureHeight();
const uint32_t* texPixels = (const uint32_t*)thread->drawargs.TexturePixels();
int texWidth = thread->textures[0].width;
int texHeight = thread->textures[0].height;
const uint32_t* texPixels = (const uint32_t*)thread->textures[0].pixels;

int tex2Width = thread->drawargs.Texture2Width();
int tex2Height = thread->drawargs.Texture2Height();
const uint32_t* tex2Pixels = (const uint32_t*)thread->drawargs.Texture2Pixels();
int tex2Width = thread->textures[1].width;
int tex2Height = thread->textures[1].height;
const uint32_t* tex2Pixels = (const uint32_t*)thread->textures[1].pixels;

uint32_t frag = thread->mainVertexShader.vColor;
uint32_t frag_r = RPART(frag);
@@ -441,9 +441,9 @@ static void RunShader(int x0, int x1, PolyTriangleThreadData* thread)
}
else // func_normal
{
int texWidth = thread->drawargs.TextureWidth();
int texHeight = thread->drawargs.TextureHeight();
const uint32_t* texPixels = (const uint32_t*)thread->drawargs.TexturePixels();
int texWidth = thread->textures[0].width;
int texHeight = thread->textures[0].height;
const uint32_t* texPixels = (const uint32_t*)thread->textures[0].pixels;

switch (constants->uTextureMode)
{
@@ -626,11 +626,11 @@ static void DrawSpan(int y, int x0, int x1, const TriDrawTriangleArgs* args, Pol

RunShader(x0, x1, thread);

if (thread->drawargs.WriteColor())
if (thread->WriteColor)
WriteColor(y, x0, x1, thread);
if (thread->drawargs.WriteDepth())
if (thread->WriteDepth)
WriteDepth(y, x0, x1, thread);
if (thread->drawargs.WriteStencil())
if (thread->WriteStencil)
WriteStencil(y, x0, x1, thread);
}

@@ -652,7 +652,7 @@ static void TestSpan(int y, int x0, int x1, const TriDrawTriangleArgs* args, Pol
{
stencilbuffer = thread->depthstencil->StencilValues();
stencilLine = stencilbuffer + pitch * y;
stencilTestValue = thread->drawargs.StencilTestValue();
stencilTestValue = thread->StencilTestValue;
}

float* zbuffer;
@@ -760,8 +760,8 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat
void(*testfunc)(int y, int x0, int x1, const TriDrawTriangleArgs * args, PolyTriangleThreadData * thread);

int opt = 0;
if (thread->drawargs.DepthTest()) opt |= TriScreenDrawerModes::SWTRI_DepthTest;
if (thread->drawargs.StencilTest()) opt |= TriScreenDrawerModes::SWTRI_StencilTest;
if (thread->DepthTest) opt |= TriScreenDrawerModes::SWTRI_DepthTest;
if (thread->StencilTest) opt |= TriScreenDrawerModes::SWTRI_StencilTest;
testfunc = ScreenTriangle::TestSpanOpts[opt];

topY += thread->skipped_by_thread(topY);
@@ -1,5 +1,4 @@
#include "../swrenderer/textures/r_swtexture.h"
#include "drawers/poly_draw_args.cpp"
#include "drawers/poly_triangle.cpp"
#include "drawers/screen_triangle.cpp"
#include "math/gpu_types.cpp"

0 comments on commit 74c6b9f

Please sign in to comment.
You can’t perform that action at this time.