Remove r_drawers.h and move softpoly drawer related stuff out of the swrenderer

This commit is contained in:
Magnus Norddahl 2017-02-23 09:02:13 +01:00
parent ad507ca246
commit 56045c1293
21 changed files with 153 additions and 188 deletions

View file

@ -801,6 +801,7 @@ file( GLOB HEADER_FILES
polyrenderer/*.h
polyrenderer/math/*.h
polyrenderer/drawers/*.h
polyrenderer/drawers/*.php
polyrenderer/scene/*.h
gl/*.h
gl/api/*.h

View file

@ -34,7 +34,7 @@
#include "v_palette.h"
#include "r_data/colormaps.h"
#include "poly_buffer.h"
#include "swrenderer/drawers/r_drawers.h"
#include "screen_triangle.h"
/////////////////////////////////////////////////////////////////////////////

View file

@ -24,7 +24,7 @@
#include "r_data/r_translate.h"
#include "r_data/colormaps.h"
#include "swrenderer/drawers/r_drawers.h"
#include "screen_triangle.h"
class FTexture;

View file

@ -24,7 +24,7 @@
#include "swrenderer/drawers/r_draw.h"
#include "swrenderer/drawers/r_thread.h"
#include "swrenderer/drawers/r_drawers.h"
#include "polyrenderer/drawers/screen_triangle.h"
#include "polyrenderer/math/tri_matrix.h"
#include "polyrenderer/drawers/poly_buffer.h"
#include "polyrenderer/drawers/poly_draw_args.h"

View file

@ -22,7 +22,126 @@
#pragma once
#include "swrenderer/drawers/r_drawers.h"
#include <cstdint>
#include <vector>
class FString;
struct TriFullSpan
{
uint16_t X;
uint16_t Y;
uint32_t Length;
};
struct TriPartialBlock
{
uint16_t X;
uint16_t Y;
uint32_t Mask0;
uint32_t Mask1;
};
struct WorkerThreadData
{
int32_t core;
int32_t num_cores;
int32_t pass_start_y;
int32_t pass_end_y;
uint32_t *temp;
// Triangle working data:
TriFullSpan *FullSpans;
TriPartialBlock *PartialBlocks;
uint32_t NumFullSpans;
uint32_t NumPartialBlocks;
int32_t StartX;
int32_t StartY;
};
struct TriVertex
{
TriVertex() { }
TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; }
enum { NumVarying = 2 };
float x, y, z, w;
float varying[NumVarying];
};
struct TriUniforms
{
uint32_t light;
uint32_t subsectorDepth;
uint32_t color;
uint32_t srcalpha;
uint32_t destalpha;
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;
float globvis;
uint32_t flags;
enum Flags
{
simple_shade = 1,
nearest_filter = 2,
fixed_light = 4
};
};
struct TriDrawTriangleArgs
{
uint8_t *dest;
int32_t pitch;
TriVertex *v1;
TriVertex *v2;
TriVertex *v3;
int32_t clipleft;
int32_t clipright;
int32_t cliptop;
int32_t clipbottom;
const uint8_t *texturePixels;
uint32_t textureWidth;
uint32_t textureHeight;
const uint8_t *translation;
const TriUniforms *uniforms;
uint8_t *stencilValues;
uint32_t *stencilMasks;
int32_t stencilPitch;
uint8_t stencilTestValue;
uint8_t stencilWriteValue;
uint32_t *subsectorGBuffer;
const uint8_t *colormaps;
const uint8_t *RGB256k;
const uint8_t *BaseColors;
};
enum class TriBlendMode
{
Copy, // blend_copy(shade(fg))
AlphaBlend, // blend_alpha_blend(shade(fg), bg)
AddSolid, // blend_add(shade(fg), bg, srcalpha, destalpha)
Add, // blend_add(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Sub, // blend_sub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Stencil, // blend_stencil(shade(color), fg.a, bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Shaded, // blend_stencil(shade(color), fg.index, bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateCopy, // blend_copy(shade(translate(fg)))
TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg)
TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateRevSub,// blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
AddSrcColorOneMinusSrcColor, // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites
Skycap // Fade to sky color when the V texture coordinate go beyond the [-1, 1] range
};
inline int NumTriBlendModes() { return (int)TriBlendMode::Skycap + 1; }
class ScreenTriangle
{

View file

@ -6,7 +6,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
EXTERN_CVAR(Bool, r_multithreaded);
EXTERN_CVAR(Bool, r_magfilter);

View file

@ -115,7 +115,7 @@ namespace swrenderer
_step_viewpos_z = args.dc_viewpos_step.Z;
}
uint8_t PalWall1Command::AddLights(const TriLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material)
uint8_t PalWall1Command::AddLights(const DrawerLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material)
{
uint32_t lit_r = 0;
uint32_t lit_g = 0;
@ -175,7 +175,7 @@ namespace swrenderer
uint8_t *dest = _dest;
int bits = _fracbits;
int pitch = _pitch;
TriLight *dynlights = _dynlights;
DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_z = _viewpos_z;
float step_viewpos_z = _step_viewpos_z;
@ -226,7 +226,7 @@ namespace swrenderer
uint8_t *dest = _dest;
int bits = _fracbits;
int pitch = _pitch;
TriLight *dynlights = _dynlights;
DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_z = _viewpos_z;
float step_viewpos_z = _step_viewpos_z;
@ -347,7 +347,7 @@ namespace swrenderer
uint8_t *dest = _dest;
int bits = _fracbits;
int pitch = _pitch;
TriLight *dynlights = _dynlights;
DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_z = _viewpos_z;
float step_viewpos_z = _step_viewpos_z;
@ -421,7 +421,7 @@ namespace swrenderer
uint8_t *dest = _dest;
int bits = _fracbits;
int pitch = _pitch;
TriLight *dynlights = _dynlights;
DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_z = _viewpos_z;
float step_viewpos_z = _step_viewpos_z;
@ -494,7 +494,7 @@ namespace swrenderer
uint8_t *dest = _dest;
int bits = _fracbits;
int pitch = _pitch;
TriLight *dynlights = _dynlights;
DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_z = _viewpos_z;
float step_viewpos_z = _step_viewpos_z;
@ -1874,7 +1874,7 @@ namespace swrenderer
_step_viewpos_x = args.dc_viewpos_step.X;
}
uint8_t PalSpanCommand::AddLights(const TriLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material)
uint8_t PalSpanCommand::AddLights(const DrawerLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material)
{
uint32_t lit_r = 0;
uint32_t lit_g = 0;
@ -1949,7 +1949,7 @@ namespace swrenderer
xstep = _xstep;
ystep = _ystep;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;
@ -2037,7 +2037,7 @@ namespace swrenderer
xstep = _xstep;
ystep = _ystep;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;
@ -2113,7 +2113,7 @@ namespace swrenderer
const PalEntry *palette = GPalette.BaseColors;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;
@ -2219,7 +2219,7 @@ namespace swrenderer
const PalEntry *palette = GPalette.BaseColors;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;
@ -2360,7 +2360,7 @@ namespace swrenderer
uint32_t *bg2rgb = _destblend;
const PalEntry *palette = GPalette.BaseColors;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;
@ -2483,7 +2483,7 @@ namespace swrenderer
uint32_t *bg2rgb = _destblend;
const PalEntry *palette = GPalette.BaseColors;
const TriLight *dynlights = _dynlights;
const DrawerLight *dynlights = _dynlights;
int num_dynlights = _num_dynlights;
float viewpos_x = _viewpos_x;
float step_viewpos_x = _step_viewpos_x;

View file

@ -18,7 +18,7 @@ namespace swrenderer
FString DebugInfo() override { return "PalWallCommand"; }
protected:
inline static uint8_t AddLights(const TriLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material);
inline static uint8_t AddLights(const DrawerLight *lights, int num_lights, float viewpos_z, uint8_t fg, uint8_t material);
uint32_t _iscale;
uint32_t _texturefrac;
@ -31,7 +31,7 @@ namespace swrenderer
int _pitch;
uint32_t *_srcblend;
uint32_t *_destblend;
TriLight *_dynlights;
DrawerLight *_dynlights;
int _num_dynlights;
float _viewpos_z;
float _step_viewpos_z;
@ -134,7 +134,7 @@ namespace swrenderer
FString DebugInfo() override { return "PalSpanCommand"; }
protected:
inline static uint8_t AddLights(const TriLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material);
inline static uint8_t AddLights(const DrawerLight *lights, int num_lights, float viewpos_x, uint8_t fg, uint8_t material);
const uint8_t *_source;
const uint8_t *_colormap;
@ -153,7 +153,7 @@ namespace swrenderer
int _color;
fixed_t _srcalpha;
fixed_t _destalpha;
TriLight *_dynlights;
DrawerLight *_dynlights;
int _num_dynlights;
float _viewpos_x;
float _step_viewpos_x;

View file

@ -36,7 +36,6 @@
#include "v_palette.h"
#include "r_data/colormaps.h"
#include "r_draw_rgba.h"
#include "r_drawers.h"
#include "gl/data/gl_matrix.h"
#include "swrenderer/viewport/r_viewport.h"
#include "swrenderer/scene/r_light.h"

View file

@ -25,7 +25,6 @@
#include "r_draw.h"
#include "v_palette.h"
#include "r_thread.h"
#include "r_drawers.h"
#include "swrenderer/viewport/r_skydrawer.h"
#include "swrenderer/viewport/r_spandrawer.h"
#include "swrenderer/viewport/r_walldrawer.h"

View file

@ -1,151 +0,0 @@
/*
** LLVM code generated drawers
** 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 <cstdint>
#include <vector>
class FString;
struct TriFullSpan
{
uint16_t X;
uint16_t Y;
uint32_t Length;
};
struct TriPartialBlock
{
uint16_t X;
uint16_t Y;
uint32_t Mask0;
uint32_t Mask1;
};
struct WorkerThreadData
{
int32_t core;
int32_t num_cores;
int32_t pass_start_y;
int32_t pass_end_y;
uint32_t *temp;
// Triangle working data:
TriFullSpan *FullSpans;
TriPartialBlock *PartialBlocks;
uint32_t NumFullSpans;
uint32_t NumPartialBlocks;
int32_t StartX;
int32_t StartY;
};
struct TriLight
{
uint32_t color;
float x, y, z;
float radius;
};
struct TriVertex
{
TriVertex() { }
TriVertex(float x, float y, float z, float w, float u, float v) : x(x), y(y), z(z), w(w) { varying[0] = u; varying[1] = v; }
enum { NumVarying = 2 };
float x, y, z, w;
float varying[NumVarying];
};
struct TriUniforms
{
uint32_t light;
uint32_t subsectorDepth;
uint32_t color;
uint32_t srcalpha;
uint32_t destalpha;
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;
float globvis;
uint32_t flags;
enum Flags
{
simple_shade = 1,
nearest_filter = 2,
fixed_light = 4
};
};
struct TriDrawTriangleArgs
{
uint8_t *dest;
int32_t pitch;
TriVertex *v1;
TriVertex *v2;
TriVertex *v3;
int32_t clipleft;
int32_t clipright;
int32_t cliptop;
int32_t clipbottom;
const uint8_t *texturePixels;
uint32_t textureWidth;
uint32_t textureHeight;
const uint8_t *translation;
const TriUniforms *uniforms;
uint8_t *stencilValues;
uint32_t *stencilMasks;
int32_t stencilPitch;
uint8_t stencilTestValue;
uint8_t stencilWriteValue;
uint32_t *subsectorGBuffer;
const uint8_t *colormaps;
const uint8_t *RGB256k;
const uint8_t *BaseColors;
};
enum class TriBlendMode
{
Copy, // blend_copy(shade(fg))
AlphaBlend, // blend_alpha_blend(shade(fg), bg)
AddSolid, // blend_add(shade(fg), bg, srcalpha, destalpha)
Add, // blend_add(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Sub, // blend_sub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
RevSub, // blend_revsub(shade(fg), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Stencil, // blend_stencil(shade(color), fg.a, bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
Shaded, // blend_stencil(shade(color), fg.index, bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateCopy, // blend_copy(shade(translate(fg)))
TranslateAlphaBlend, // blend_alpha_blend(shade(translate(fg)), bg)
TranslateAdd, // blend_add(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateSub, // blend_sub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
TranslateRevSub,// blend_revsub(shade(translate(fg)), bg, srcalpha, calc_blend_bgalpha(fg, destalpha))
AddSrcColorOneMinusSrcColor, // glBlendMode(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR) used by GZDoom's fullbright additive sprites
Skycap // Fade to sky color when the V texture coordinate go beyond the [-1, 1] range
};
inline int NumTriBlendModes() { return (int)TriBlendMode::Skycap + 1; }

View file

@ -23,7 +23,7 @@
#pragma once
#include "r_draw.h"
#include "r_drawers.h"
#include "polyrenderer/drawers/screen_triangle.h"
#include <vector>
#include <memory>
#include <thread>

View file

@ -29,7 +29,6 @@
#include "v_palette.h"
#include "r_data/colormaps.h"
#include "gl/dynlights/gl_dynlight.h"
#include "swrenderer/drawers/r_drawers.h"
#include "swrenderer/drawers/r_draw.h"
#include "swrenderer/segments/r_drawsegment.h"
#include "swrenderer/scene/r_opaque_pass.h"
@ -200,7 +199,7 @@ namespace swrenderer
}
drawerargs.dc_num_lights = 0;
drawerargs.dc_lights = Thread->FrameMemory->AllocMemory<TriLight>(max_lights);
drawerargs.dc_lights = Thread->FrameMemory->AllocMemory<DrawerLight>(max_lights);
// Setup lights for column
cur_node = light_list;

View file

@ -204,7 +204,7 @@ namespace swrenderer
drawerargs.dc_viewpos.Z = (float)((viewport->CenterY - y - 0.5) / viewport->InvZtoScale * zspan);
drawerargs.dc_viewpos_step.X = (float)(zspan / viewport->CenterX);
static TriLight lightbuffer[64 * 1024];
static DrawerLight lightbuffer[64 * 1024];
static int nextlightindex = 0;
// Plane normal

View file

@ -43,7 +43,6 @@
#include "textures/textures.h"
#include "r_data/voxels.h"
#include "drawers/r_draw_rgba.h"
#include "drawers/r_drawers.h"
EXTERN_CVAR(Bool, r_blendmethod)

View file

@ -47,7 +47,6 @@
#include "textures/textures.h"
#include "r_data/voxels.h"
#include "drawers/r_draw_rgba.h"
#include "drawers/r_drawers.h"
#include "polyrenderer/poly_renderer.h"
#include "p_setup.h"

View file

@ -13,7 +13,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
namespace swrenderer
{
@ -21,6 +20,13 @@ namespace swrenderer
class DrawerArgs;
struct ShadeConstants;
struct DrawerLight
{
uint32_t color;
float x, y, z;
float radius;
};
class DrawerArgs
{
public:

View file

@ -5,7 +5,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
namespace swrenderer
{

View file

@ -5,7 +5,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
namespace swrenderer
{
@ -54,7 +53,7 @@ namespace swrenderer
FVector3 dc_normal;
FVector3 dc_viewpos;
FVector3 dc_viewpos_step;
TriLight *dc_lights = nullptr;
DrawerLight *dc_lights = nullptr;
int dc_num_lights = 0;
private:

View file

@ -5,7 +5,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
namespace swrenderer
{

View file

@ -5,7 +5,6 @@
struct FSWColormap;
struct FLightNode;
struct TriLight;
namespace swrenderer
{
@ -54,7 +53,7 @@ namespace swrenderer
FVector3 dc_normal;
FVector3 dc_viewpos;
FVector3 dc_viewpos_step;
TriLight *dc_lights = nullptr;
DrawerLight *dc_lights = nullptr;
int dc_num_lights = 0;
private: