mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Remove PolyDrawArgs
This commit is contained in:
parent
d2f4570337
commit
74c6b9fe6d
7 changed files with 50 additions and 162 deletions
|
@ -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
|
||||
)
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
** Polygon Doom software renderer
|
||||
** Copyright (c) 2016 Magnus Norddahl
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any damages
|
||||
** arising from the use of this software.
|
||||
**
|
||||
** Permission is granted to anyone to use this software for any purpose,
|
||||
** including commercial applications, and to alter it and redistribute it
|
||||
** freely, subject to the following restrictions:
|
||||
**
|
||||
** 1. The origin of this software must not be misrepresented; you must not
|
||||
** claim that you wrote the original software. If you use this software
|
||||
** in a product, an acknowledgment in the product documentation would be
|
||||
** appreciated but is not required.
|
||||
** 2. Altered source versions must be plainly marked as such, and must not be
|
||||
** misrepresented as being the original software.
|
||||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
|
||||
#include "w_wad.h"
|
||||
#include "v_video.h"
|
||||
#include "doomstat.h"
|
||||
#include "st_stuff.h"
|
||||
#include "g_game.h"
|
||||
#include "g_level.h"
|
||||
#include "r_data/r_translate.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "swrenderer/r_swcolormaps.h"
|
||||
#include "poly_draw_args.h"
|
||||
#include "swrenderer/viewport/r_viewport.h"
|
||||
#include "polyrenderer/drawers/poly_triangle.h"
|
||||
|
||||
void PolyDrawArgs::SetTexture(const uint8_t *texels, int width, int height)
|
||||
{
|
||||
mTexturePixels = texels;
|
||||
mTextureWidth = width;
|
||||
mTextureHeight = height;
|
||||
}
|
||||
|
||||
void PolyDrawArgs::SetTexture2(const uint8_t* texels, int width, int height)
|
||||
{
|
||||
mTexture2Pixels = texels;
|
||||
mTexture2Width = width;
|
||||
mTexture2Height = height;
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
** Polygon Doom software renderer
|
||||
** Copyright (c) 2016 Magnus Norddahl
|
||||
**
|
||||
** This software is provided 'as-is', without any express or implied
|
||||
** warranty. In no event will the authors be held liable for any damages
|
||||
** arising from the use of this software.
|
||||
**
|
||||
** Permission is granted to anyone to use this software for any purpose,
|
||||
** including commercial applications, and to alter it and redistribute it
|
||||
** freely, subject to the following restrictions:
|
||||
**
|
||||
** 1. The origin of this software must not be misrepresented; you must not
|
||||
** claim that you wrote the original software. If you use this software
|
||||
** in a product, an acknowledgment in the product documentation would be
|
||||
** appreciated but is not required.
|
||||
** 2. Altered source versions must be plainly marked as such, and must not be
|
||||
** misrepresented as being the original software.
|
||||
** 3. This notice may not be removed or altered from any source distribution.
|
||||
**
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "r_data/r_translate.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "screen_triangle.h"
|
||||
|
||||
class PolyDrawArgs
|
||||
{
|
||||
public:
|
||||
void SetTexture(const uint8_t *texels, int width, int height);
|
||||
void SetTexture2(const uint8_t* texels, int width, int height);
|
||||
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; }
|
||||
|
||||
bool WriteColor() const { return mWriteColor; }
|
||||
|
||||
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
||||
int TextureWidth() const { return mTextureWidth; }
|
||||
int TextureHeight() const { return mTextureHeight; }
|
||||
|
||||
const uint8_t* Texture2Pixels() const { return mTexture2Pixels; }
|
||||
int Texture2Width() const { return mTexture2Width; }
|
||||
int Texture2Height() const { return mTexture2Height; }
|
||||
|
||||
bool WriteStencil() const { return mWriteStencil; }
|
||||
bool StencilTest() const { return mStencilTest; }
|
||||
uint8_t StencilTestValue() const { return mStencilTestValue; }
|
||||
uint8_t StencilWriteValue() const { return mStencilWriteValue; }
|
||||
|
||||
bool DepthTest() const { return mDepthTest; }
|
||||
bool WriteDepth() const { return mWriteDepth; }
|
||||
|
||||
private:
|
||||
bool mDepthTest = false;
|
||||
bool mStencilTest = true;
|
||||
bool mWriteStencil = true;
|
||||
bool mWriteColor = true;
|
||||
bool mWriteDepth = true;
|
||||
const uint8_t *mTexturePixels = nullptr;
|
||||
int mTextureWidth = 0;
|
||||
int mTextureHeight = 0;
|
||||
const uint8_t* mTexture2Pixels = nullptr;
|
||||
int mTexture2Width = 0;
|
||||
int mTexture2Height = 0;
|
||||
uint8_t mStencilTestValue = 0;
|
||||
uint8_t mStencilWriteValue = 0;
|
||||
};
|
|
@ -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 @@ public:
|
|||
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 @@ public:
|
|||
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue