diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a37649086e..885e31356d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -807,6 +807,7 @@ file( GLOB HEADER_FILES swrenderer/line/*.h swrenderer/plane/*.h swrenderer/things/*.h + swrenderer/viewport/*.h polyrenderer/*.h polyrenderer/math/*.h polyrenderer/drawers/*.h @@ -850,7 +851,6 @@ set( FASTMATH_PCH_SOURCES swrenderer/drawers/r_draw.cpp swrenderer/drawers/r_draw_pal.cpp swrenderer/drawers/r_draw_rgba.cpp - swrenderer/drawers/r_drawerargs.cpp swrenderer/drawers/r_drawers.cpp swrenderer/drawers/r_thread.cpp swrenderer/scene/r_3dfloors.cpp @@ -859,7 +859,12 @@ set( FASTMATH_PCH_SOURCES swrenderer/scene/r_portal.cpp swrenderer/scene/r_scene.cpp swrenderer/scene/r_translucent_pass.cpp - swrenderer/scene/r_viewport.cpp + swrenderer/viewport/r_drawerargs.cpp + swrenderer/viewport/r_skydrawer.cpp + swrenderer/viewport/r_spandrawer.cpp + swrenderer/viewport/r_spritedrawer.cpp + swrenderer/viewport/r_viewport.cpp + swrenderer/viewport/r_walldrawer.cpp swrenderer/line/r_line.cpp swrenderer/line/r_walldraw.cpp swrenderer/line/r_wallsetup.cpp @@ -1506,6 +1511,7 @@ source_group("Software Renderer\\Segments" REGULAR_EXPRESSION "^${CMAKE_CURRENT_ source_group("Software Renderer\\Line" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/line/.+") source_group("Software Renderer\\Plane" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/plane/.+") source_group("Software Renderer\\Things" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/things/.+") +source_group("Software Renderer\\Viewport" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/swrenderer/viewport/.+") source_group("Poly Renderer" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/.+") source_group("Poly Renderer\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/math/.+") source_group("Poly Renderer\\Drawers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/polyrenderer/drawers/.+") diff --git a/src/polyrenderer/math/tri_matrix.cpp b/src/polyrenderer/math/tri_matrix.cpp index cd6109539b..daa549587a 100644 --- a/src/polyrenderer/math/tri_matrix.cpp +++ b/src/polyrenderer/math/tri_matrix.cpp @@ -37,7 +37,7 @@ #include "tri_matrix.h" #include "polyrenderer/drawers/poly_triangle.h" #include "swrenderer/drawers/r_draw_rgba.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" TriMatrix TriMatrix::null() { diff --git a/src/polyrenderer/poly_renderer.cpp b/src/polyrenderer/poly_renderer.cpp index f8bcedc7c1..f8b27bd983 100644 --- a/src/polyrenderer/poly_renderer.cpp +++ b/src/polyrenderer/poly_renderer.cpp @@ -33,9 +33,9 @@ #include "po_man.h" #include "st_stuff.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/drawers/r_draw_rgba.h" +#include "swrenderer/viewport/r_viewport.h" EXTERN_CVAR(Bool, r_shadercolormaps) EXTERN_CVAR(Int, screenblocks) diff --git a/src/swrenderer/drawers/r_draw.cpp b/src/swrenderer/drawers/r_draw.cpp index 890b394df0..d7b4237ce9 100644 --- a/src/swrenderer/drawers/r_draw.cpp +++ b/src/swrenderer/drawers/r_draw.cpp @@ -50,7 +50,6 @@ #include "r_draw_rgba.h" #include "r_draw_pal.h" #include "r_thread.h" -#include "r_drawerargs.h" #include "swrenderer/scene/r_light.h" CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG); diff --git a/src/swrenderer/drawers/r_draw_pal.cpp b/src/swrenderer/drawers/r_draw_pal.cpp index 856c5b7b77..fad7c24362 100644 --- a/src/swrenderer/drawers/r_draw_pal.cpp +++ b/src/swrenderer/drawers/r_draw_pal.cpp @@ -47,7 +47,7 @@ #include "r_draw.h" #include "v_video.h" #include "r_draw_pal.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/scene/r_light.h" // [SP] r_blendmethod - false = rgb555 matching (ZDoom classic), true = rgb666 (refactored) diff --git a/src/swrenderer/drawers/r_draw_pal.h b/src/swrenderer/drawers/r_draw_pal.h index f28007e73a..cf955c607c 100644 --- a/src/swrenderer/drawers/r_draw_pal.h +++ b/src/swrenderer/drawers/r_draw_pal.h @@ -4,7 +4,10 @@ #include "r_draw.h" #include "v_palette.h" #include "r_thread.h" -#include "r_drawerargs.h" +#include "swrenderer/viewport/r_skydrawer.h" +#include "swrenderer/viewport/r_spandrawer.h" +#include "swrenderer/viewport/r_walldrawer.h" +#include "swrenderer/viewport/r_spritedrawer.h" namespace swrenderer { diff --git a/src/swrenderer/drawers/r_draw_rgba.cpp b/src/swrenderer/drawers/r_draw_rgba.cpp index 9806c6d8c2..0b9af6b5e7 100644 --- a/src/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/swrenderer/drawers/r_draw_rgba.cpp @@ -38,7 +38,7 @@ #include "r_draw_rgba.h" #include "r_drawers.h" #include "gl/data/gl_matrix.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "gi.h" diff --git a/src/swrenderer/drawers/r_draw_rgba.h b/src/swrenderer/drawers/r_draw_rgba.h index 33c9ebcabf..6ba67f5c1d 100644 --- a/src/swrenderer/drawers/r_draw_rgba.h +++ b/src/swrenderer/drawers/r_draw_rgba.h @@ -26,7 +26,10 @@ #include "v_palette.h" #include "r_thread.h" #include "r_drawers.h" -#include "r_drawerargs.h" +#include "swrenderer/viewport/r_skydrawer.h" +#include "swrenderer/viewport/r_spandrawer.h" +#include "swrenderer/viewport/r_walldrawer.h" +#include "swrenderer/viewport/r_spritedrawer.h" #ifdef __arm__ #define NO_SSE diff --git a/src/swrenderer/drawers/r_drawerargs.h b/src/swrenderer/drawers/r_drawerargs.h deleted file mode 100644 index 481792edc7..0000000000 --- a/src/swrenderer/drawers/r_drawerargs.h +++ /dev/null @@ -1,317 +0,0 @@ - -#pragma once - -#include "templates.h" -#include "doomtype.h" -#include "doomdef.h" -#include "r_defs.h" -#include "r_draw.h" -#include "v_video.h" -#include "r_data/colormaps.h" -#include "r_data/r_translate.h" -#include "swrenderer/scene/r_light.h" - -struct FSWColormap; -struct FLightNode; -struct TriLight; - -namespace swrenderer -{ - class SWPixelFormatDrawers; - class DrawerArgs; - struct ShadeConstants; - - class DrawerArgs - { - public: - void SetLight(FSWColormap *base_colormap, float light, int shade); - void SetTranslationMap(lighttable_t *translation); - - uint8_t *Colormap() const; - uint8_t *TranslationMap() const { return mTranslation; } - - ShadeConstants ColormapConstants() const; - fixed_t Light() const { return LIGHTSCALE(mLight, mShade); } - - protected: - static SWPixelFormatDrawers *Drawers(); - - private: - FSWColormap *mBaseColormap = nullptr; - float mLight = 0.0f; - int mShade = 0; - uint8_t *mTranslation = nullptr; - }; - - class SkyDrawerArgs : public DrawerArgs - { - public: - void SetDest(int x, int y); - void SetCount(int count) { dc_count = count; } - void SetFrontTexture(FTexture *texture, uint32_t column); - void SetBackTexture(FTexture *texture, uint32_t column); - void SetTextureVPos(uint32_t texturefrac) { dc_texturefrac = texturefrac; } - void SetTextureVStep(uint32_t iscale) { dc_iscale = iscale; } - void SetSolidTop(uint32_t color) { solid_top = color; } - void SetSolidBottom(uint32_t color) { solid_bottom = color; } - void SetFadeSky(bool enable) { fadeSky = enable; } - - uint8_t *Dest() const { return dc_dest; } - int DestY() const { return dc_dest_y; } - int Count() const { return dc_count; } - - uint32_t TextureVPos() const { return dc_texturefrac; } - uint32_t TextureVStep() const { return dc_iscale; } - - uint32_t SolidTopColor() const { return solid_top; } - uint32_t SolidBottomColor() const { return solid_bottom; } - bool FadeSky() const { return fadeSky; } - - const uint8_t *FrontTexturePixels() const { return dc_source; } - const uint8_t *BackTexturePixels() const { return dc_source2; } - int FrontTextureHeight() const { return dc_sourceheight; } - int BackTextureHeight() const { return dc_sourceheight2; } - - void DrawSingleSkyColumn(); - void DrawDoubleSkyColumn(); - - private: - uint8_t *dc_dest = nullptr; - int dc_dest_y = 0; - int dc_count = 0; - const uint8_t *dc_source; - const uint8_t *dc_source2; - uint32_t dc_sourceheight; - uint32_t dc_sourceheight2; - uint32_t dc_texturefrac; - uint32_t dc_iscale; - uint32_t solid_top; - uint32_t solid_bottom; - bool fadeSky; - }; - - class SpanDrawerArgs : public DrawerArgs - { - public: - SpanDrawerArgs(); - - void SetStyle(bool masked, bool additive, fixed_t alpha); - void SetDestY(int y) { ds_y = y; } - void SetDestX1(int x) { ds_x1 = x; } - void SetDestX2(int x) { ds_x2 = x; } - void SetTexture(FTexture *tex); - void SetTextureLOD(double lod) { ds_lod = lod; } - void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; } - void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; } - void SetTextureUStep(dsfixed_t xstep) { ds_xstep = xstep; } - void SetTextureVStep(dsfixed_t vstep) { ds_ystep = vstep; } - void SetSolidColor(int colorIndex) { ds_color = colorIndex; } - - void DrawSpan(); - void 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, FDynamicColormap *basecolormap); - void DrawColoredSpan(int y, int x1, int x2); - void DrawFogBoundaryLine(int y, int x1, int x2); - - uint32_t *SrcBlend() const { return dc_srcblend; } - uint32_t *DestBlend() const { return dc_destblend; } - fixed_t SrcAlpha() const { return dc_srcalpha; } - fixed_t DestAlpha() const { return dc_destalpha; } - int DestY() const { return ds_y; } - int DestX1() const { return ds_x1; } - int DestX2() const { return ds_x2; } - dsfixed_t TextureUPos() const { return ds_xfrac; } - dsfixed_t TextureVPos() const { return ds_yfrac; } - dsfixed_t TextureUStep() const { return ds_xstep; } - dsfixed_t TextureVStep() const { return ds_ystep; } - int SolidColor() const { return ds_color; } - int TextureWidthBits() const { return ds_xbits; } - int TextureHeightBits() const { return ds_ybits; } - const uint8_t *TexturePixels() const { return ds_source; } - bool MipmappedTexture() const { return ds_source_mipmapped; } - double TextureLOD() const { return ds_lod; } - - FVector3 dc_normal; - FVector3 dc_viewpos; - FVector3 dc_viewpos_step; - TriLight *dc_lights = nullptr; - int dc_num_lights = 0; - - private: - typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args); - SpanDrawerFunc spanfunc; - - int ds_y; - int ds_x1; - int ds_x2; - int ds_xbits; - int ds_ybits; - const uint8_t *ds_source; - bool ds_source_mipmapped; - dsfixed_t ds_xfrac; - dsfixed_t ds_yfrac; - dsfixed_t ds_xstep; - dsfixed_t ds_ystep; - uint32_t *dc_srcblend; - uint32_t *dc_destblend; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - int ds_color = 0; - double ds_lod; - }; - - class WallDrawerArgs : public DrawerArgs - { - public: - void SetStyle(bool masked, bool additive, fixed_t alpha); - void SetDest(int x, int y); - void SetCount(int count) { dc_count = count; } - void SetTexture(const uint8_t *pixels, const uint8_t *pixels2, int height) - { - dc_source = pixels; - dc_source2 = pixels2; - dc_textureheight = height; - } - void SetTextureFracBits(int bits) { dc_wall_fracbits = bits; } - void SetTextureUPos(uint32_t pos) { dc_texturefracx = pos; } - void SetTextureVPos(fixed_t pos) { dc_texturefrac = pos; } - void SetTextureVStep(fixed_t step) { dc_iscale = step; } - - bool IsMaskedDrawer() const; - - void DrawColumn(); - - uint8_t *Dest() const { return dc_dest; } - int DestY() const { return dc_dest_y; } - int Count() const { return dc_count; } - - uint32_t *SrcBlend() const { return dc_srcblend; } - uint32_t *DestBlend() const { return dc_destblend; } - fixed_t SrcAlpha() const { return dc_srcalpha; } - fixed_t DestAlpha() const { return dc_destalpha; } - - uint32_t TextureUPos() const { return dc_texturefracx; } - fixed_t TextureVPos() const { return dc_texturefrac; } - fixed_t TextureVStep() const { return dc_iscale; } - - const uint8_t *TexturePixels() const { return dc_source; } - const uint8_t *TexturePixels2() const { return dc_source2; } - uint32_t TextureHeight() const { return dc_textureheight; } - - int TextureFracBits() const { return dc_wall_fracbits; } - - FVector3 dc_normal; - FVector3 dc_viewpos; - FVector3 dc_viewpos_step; - TriLight *dc_lights = nullptr; - int dc_num_lights = 0; - - private: - uint8_t *dc_dest = nullptr; - int dc_dest_y = 0; - int dc_count; - - fixed_t dc_iscale; - fixed_t dc_texturefrac; - uint32_t dc_texturefracx; - uint32_t dc_textureheight; - const uint8_t *dc_source; - const uint8_t *dc_source2; - int dc_wall_fracbits; - - uint32_t *dc_srcblend; - uint32_t *dc_destblend; - fixed_t dc_srcalpha; - fixed_t dc_destalpha; - - typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args); - WallDrawerFunc wallfunc = nullptr; - }; - - class SpriteDrawerArgs : public DrawerArgs - { - public: - SpriteDrawerArgs(); - - bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); - bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); - void SetDest(int x, int y); - void SetCount(int count) { dc_count = count; } - void SetSolidColor(int color) { dc_color = color; } - - void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false); - void FillColumn(); - - uint8_t *Dest() const { return dc_dest; } - int DestY() const { return dc_dest_y; } - int Count() const { return dc_count; } - - int FuzzX() const { return dc_x; } - int FuzzY1() const { return dc_yl; } - int FuzzY2() const { return dc_yh; } - - uint32_t TextureUPos() const { return dc_texturefracx; } - fixed_t TextureVPos() const { return dc_texturefrac; } - fixed_t TextureVStep() const { return dc_iscale; } - - int SolidColor() const { return dc_color; } - uint32_t SrcColorIndex() const { return dc_srccolor; } - uint32_t SrcColorBgra() const { return dc_srccolor_bgra; } - - const uint8_t *TexturePixels() const { return dc_source; } - const uint8_t *TexturePixels2() const { return dc_source2; } - uint32_t TextureHeight() const { return dc_textureheight; } - - uint32_t *SrcBlend() const { return dc_srcblend; } - uint32_t *DestBlend() const { return dc_destblend; } - fixed_t SrcAlpha() const { return dc_srcalpha; } - fixed_t DestAlpha() const { return dc_destalpha; } - - private: - bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); - static fixed_t GetAlpha(int type, fixed_t alpha); - void DrawMaskedColumnBgra(int x, fixed_t iscale, FTexture *tex, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked); - - uint8_t *dc_dest = nullptr; - int dc_dest_y = 0; - int dc_count = 0; - - fixed_t dc_iscale; - fixed_t dc_texturefrac; - uint32_t dc_texturefracx; - - uint32_t dc_textureheight = 0; - const uint8_t *dc_source = nullptr; - const uint8_t *dc_source2 = nullptr; - bool drawer_needs_pal_input = false; - - uint32_t *dc_srcblend = nullptr; - uint32_t *dc_destblend = nullptr; - fixed_t dc_srcalpha = OPAQUE; - fixed_t dc_destalpha = 0; - - int dc_x = 0; - int dc_yl = 0; - int dc_yh = 0; - - int dc_color = 0; - uint32_t dc_srccolor = 0; - uint32_t dc_srccolor_bgra = 0; - - typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args); - SpriteDrawerFunc colfunc; - }; - - 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; - }; -} diff --git a/src/swrenderer/line/r_fogboundary.h b/src/swrenderer/line/r_fogboundary.h index 4213cb146d..487e773851 100644 --- a/src/swrenderer/line/r_fogboundary.h +++ b/src/swrenderer/line/r_fogboundary.h @@ -13,7 +13,7 @@ #pragma once -#include "swrenderer/drawers/r_draw.h" +#include "swrenderer/viewport/r_spandrawer.h" namespace swrenderer { diff --git a/src/swrenderer/line/r_renderdrawsegment.cpp b/src/swrenderer/line/r_renderdrawsegment.cpp index ea1db392e1..281a8e2c29 100644 --- a/src/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/swrenderer/line/r_renderdrawsegment.cpp @@ -40,7 +40,8 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/things/r_visiblesprite.h" #include "swrenderer/scene/r_light.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" +#include "swrenderer/viewport/r_spritedrawer.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); diff --git a/src/swrenderer/line/r_walldraw.cpp b/src/swrenderer/line/r_walldraw.cpp index 8da0c4cb2f..700f170819 100644 --- a/src/swrenderer/line/r_walldraw.cpp +++ b/src/swrenderer/line/r_walldraw.cpp @@ -36,8 +36,8 @@ #include "swrenderer/scene/r_3dfloors.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/line/r_walldraw.h" #include "swrenderer/line/r_wallsetup.h" diff --git a/src/swrenderer/line/r_walldraw.h b/src/swrenderer/line/r_walldraw.h index 76e3bccd68..bc5b2b3e9f 100644 --- a/src/swrenderer/line/r_walldraw.h +++ b/src/swrenderer/line/r_walldraw.h @@ -13,7 +13,7 @@ #pragma once -#include "swrenderer/drawers/r_drawerargs.h" +#include "swrenderer/viewport/r_walldrawer.h" #include "r_line.h" class FTexture; diff --git a/src/swrenderer/line/r_wallsetup.cpp b/src/swrenderer/line/r_wallsetup.cpp index 33388586f0..94c3a7aa44 100644 --- a/src/swrenderer/line/r_wallsetup.cpp +++ b/src/swrenderer/line/r_wallsetup.cpp @@ -22,8 +22,8 @@ #include "swrenderer/r_memory.h" #include "swrenderer/line/r_line.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" namespace swrenderer { diff --git a/src/swrenderer/plane/r_flatplane.cpp b/src/swrenderer/plane/r_flatplane.cpp index 12cdc27fc5..49a96797f2 100644 --- a/src/swrenderer/plane/r_flatplane.cpp +++ b/src/swrenderer/plane/r_flatplane.cpp @@ -37,9 +37,9 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/plane/r_visibleplane.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" namespace swrenderer diff --git a/src/swrenderer/plane/r_flatplane.h b/src/swrenderer/plane/r_flatplane.h index 385305cd09..c164ba8623 100644 --- a/src/swrenderer/plane/r_flatplane.h +++ b/src/swrenderer/plane/r_flatplane.h @@ -14,7 +14,7 @@ #pragma once #include "r_planerenderer.h" -#include "swrenderer/drawers/r_drawerargs.h" +#include "swrenderer/viewport/r_spandrawer.h" namespace swrenderer { diff --git a/src/swrenderer/plane/r_skyplane.cpp b/src/swrenderer/plane/r_skyplane.cpp index 882df107ff..b4780065f4 100644 --- a/src/swrenderer/plane/r_skyplane.cpp +++ b/src/swrenderer/plane/r_skyplane.cpp @@ -39,8 +39,8 @@ #include "swrenderer/line/r_walldraw.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" #include "g_levellocals.h" diff --git a/src/swrenderer/plane/r_skyplane.h b/src/swrenderer/plane/r_skyplane.h index 03a62d27e6..a1f8a45501 100644 --- a/src/swrenderer/plane/r_skyplane.h +++ b/src/swrenderer/plane/r_skyplane.h @@ -14,7 +14,7 @@ #pragma once #include "r_visibleplane.h" -#include "swrenderer/drawers/r_drawerargs.h" +#include "swrenderer/viewport/r_skydrawer.h" namespace swrenderer { diff --git a/src/swrenderer/plane/r_slopeplane.cpp b/src/swrenderer/plane/r_slopeplane.cpp index f175c9b344..ee56e5da2e 100644 --- a/src/swrenderer/plane/r_slopeplane.cpp +++ b/src/swrenderer/plane/r_slopeplane.cpp @@ -37,8 +37,8 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" #include "swrenderer/plane/r_visibleplane.h" diff --git a/src/swrenderer/plane/r_slopeplane.h b/src/swrenderer/plane/r_slopeplane.h index ccdfb316d2..b06f525a20 100644 --- a/src/swrenderer/plane/r_slopeplane.h +++ b/src/swrenderer/plane/r_slopeplane.h @@ -14,7 +14,7 @@ #pragma once #include "r_planerenderer.h" -#include "swrenderer/drawers/r_drawerargs.h" +#include "swrenderer/viewport/r_spandrawer.h" namespace swrenderer { diff --git a/src/swrenderer/plane/r_visibleplanelist.cpp b/src/swrenderer/plane/r_visibleplanelist.cpp index 97378c1aec..03eb386f6f 100644 --- a/src/swrenderer/plane/r_visibleplanelist.cpp +++ b/src/swrenderer/plane/r_visibleplanelist.cpp @@ -33,7 +33,6 @@ #include "swrenderer/scene/r_3dfloors.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/plane/r_flatplane.h" #include "swrenderer/plane/r_slopeplane.h" @@ -41,6 +40,7 @@ #include "swrenderer/plane/r_visibleplane.h" #include "swrenderer/plane/r_visibleplanelist.h" #include "swrenderer/drawers/r_draw.h" +#include "swrenderer/viewport/r_viewport.h" namespace swrenderer { diff --git a/src/swrenderer/r_swrenderer.cpp b/src/swrenderer/r_swrenderer.cpp index a83289006f..b334df7961 100644 --- a/src/swrenderer/r_swrenderer.cpp +++ b/src/swrenderer/r_swrenderer.cpp @@ -33,10 +33,9 @@ */ #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/things/r_playersprite.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "v_palette.h" #include "v_video.h" diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index 076f8c9b00..633e34acba 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -31,7 +31,7 @@ #include "r_utility.h" #include "d_player.h" #include "swrenderer/scene/r_light.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" CVAR(Bool, r_shadercolormaps, true, CVAR_ARCHIVE) EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) diff --git a/src/swrenderer/scene/r_light.h b/src/swrenderer/scene/r_light.h index 099700980d..6059028a6f 100644 --- a/src/swrenderer/scene/r_light.h +++ b/src/swrenderer/scene/r_light.h @@ -18,7 +18,7 @@ #include "v_palette.h" #include "r_data/colormaps.h" #include "r_utility.h" -#include "r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" // Lighting. // diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 46facc5e53..ebd0d9ba87 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -42,8 +42,8 @@ #include "swrenderer/segments/r_clipsegment.h" #include "swrenderer/line/r_wallsetup.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" #include "r_3dfloors.h" #include "r_portal.h" #include "a_sharedglobal.h" diff --git a/src/swrenderer/scene/r_portal.cpp b/src/swrenderer/scene/r_portal.cpp index b74337bf04..dfa7a1bd1d 100644 --- a/src/swrenderer/scene/r_portal.cpp +++ b/src/swrenderer/scene/r_portal.cpp @@ -54,8 +54,8 @@ #include "swrenderer/scene/r_opaque_pass.h" #include "swrenderer/scene/r_translucent_pass.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" CVAR(Int, r_portal_recursions, 4, CVAR_ARCHIVE) diff --git a/src/swrenderer/scene/r_scene.cpp b/src/swrenderer/scene/r_scene.cpp index 84bcaee2bb..8fbe1efb2a 100644 --- a/src/swrenderer/scene/r_scene.cpp +++ b/src/swrenderer/scene/r_scene.cpp @@ -33,7 +33,6 @@ #include "st_stuff.h" #include "r_data/r_interpolate.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/scene/r_3dfloors.h" #include "swrenderer/scene/r_opaque_pass.h" @@ -43,6 +42,7 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/segments/r_portalsegment.h" #include "swrenderer/plane/r_visibleplanelist.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/drawers/r_draw.h" #include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/drawers/r_thread.h" diff --git a/src/swrenderer/scene/r_translucent_pass.cpp b/src/swrenderer/scene/r_translucent_pass.cpp index 67b0600955..b8d64c141e 100644 --- a/src/swrenderer/scene/r_translucent_pass.cpp +++ b/src/swrenderer/scene/r_translucent_pass.cpp @@ -32,11 +32,11 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_translucent_pass.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/plane/r_visibleplane.h" #include "swrenderer/plane/r_visibleplanelist.h" #include "swrenderer/line/r_renderdrawsegment.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" EXTERN_CVAR(Int, r_drawfuzz) diff --git a/src/swrenderer/segments/r_drawsegment.cpp b/src/swrenderer/segments/r_drawsegment.cpp index a9e1479024..8ff4e658fa 100644 --- a/src/swrenderer/segments/r_drawsegment.cpp +++ b/src/swrenderer/segments/r_drawsegment.cpp @@ -39,7 +39,7 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/things/r_visiblesprite.h" #include "swrenderer/scene/r_light.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" namespace swrenderer { diff --git a/src/swrenderer/things/r_decal.cpp b/src/swrenderer/things/r_decal.cpp index c902f20a1d..f1966f60a3 100644 --- a/src/swrenderer/things/r_decal.cpp +++ b/src/swrenderer/things/r_decal.cpp @@ -38,9 +38,10 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/things/r_wallsprite.h" +#include "swrenderer/viewport/r_viewport.h" +#include "swrenderer/viewport/r_spritedrawer.h" #include "swrenderer/r_memory.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); diff --git a/src/swrenderer/things/r_particle.cpp b/src/swrenderer/things/r_particle.cpp index 8ee6df916f..dd078430be 100644 --- a/src/swrenderer/things/r_particle.cpp +++ b/src/swrenderer/things/r_particle.cpp @@ -47,11 +47,11 @@ #include "swrenderer/scene/r_3dfloors.h" #include "swrenderer/scene/r_translucent_pass.h" #include "swrenderer/scene/r_portal.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/line/r_renderdrawsegment.h" #include "swrenderer/things/r_particle.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/drawers/r_draw_pal.h" #include "swrenderer/r_memory.h" diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 71f57960a8..4df08a2623 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -51,9 +51,9 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/things/r_sprite.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" #include "g_levellocals.h" diff --git a/src/swrenderer/things/r_sprite.cpp b/src/swrenderer/things/r_sprite.cpp index b83089b9e3..9130572640 100644 --- a/src/swrenderer/things/r_sprite.cpp +++ b/src/swrenderer/things/r_sprite.cpp @@ -51,9 +51,9 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/things/r_sprite.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor) diff --git a/src/swrenderer/things/r_visiblesprite.cpp b/src/swrenderer/things/r_visiblesprite.cpp index 1b5a3b447d..cdb4da2d01 100644 --- a/src/swrenderer/things/r_visiblesprite.cpp +++ b/src/swrenderer/things/r_visiblesprite.cpp @@ -33,7 +33,7 @@ #include "swrenderer/plane/r_visibleplane.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_light.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index 0f3c8800f3..945faa073c 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -52,10 +52,10 @@ #include "swrenderer/segments/r_drawsegment.h" #include "swrenderer/scene/r_portal.h" #include "swrenderer/scene/r_scene.h" -#include "swrenderer/scene/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/line/r_wallsetup.h" #include "swrenderer/line/r_walldraw.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/r_memory.h" EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor); diff --git a/src/swrenderer/viewport/r_drawerargs.cpp b/src/swrenderer/viewport/r_drawerargs.cpp new file mode 100644 index 0000000000..d54afad6bf --- /dev/null +++ b/src/swrenderer/viewport/r_drawerargs.cpp @@ -0,0 +1,94 @@ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// + +#include +#include "r_drawerargs.h" +#include "swrenderer/drawers/r_draw_pal.h" +#include "swrenderer/drawers/r_draw_rgba.h" + +namespace swrenderer +{ + SWPixelFormatDrawers *DrawerArgs::Drawers() + { + if (RenderViewport::Instance()->RenderTarget->IsBgra()) + { + static SWTruecolorDrawers tc_drawers; + return &tc_drawers; + } + else + { + static SWPalDrawers pal_drawers; + return &pal_drawers; + } + } + + void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade) + { + mBaseColormap = base_colormap; + mTranslation = nullptr; + mLight = light; + mShade = shade; + } + + void DrawerArgs::SetTranslationMap(lighttable_t *translation) + { + mTranslation = translation; + } + + uint8_t *DrawerArgs::Colormap() const + { + if (mBaseColormap) + { + if (RenderViewport::Instance()->RenderTarget->IsBgra()) + return mBaseColormap->Maps; + else + return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT); + } + else + { + return mTranslation; + } + } + + ShadeConstants DrawerArgs::ColormapConstants() const + { + ShadeConstants shadeConstants; + if (mBaseColormap) + { + shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255; + shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255; + shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255; + shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255; + shadeConstants.fade_red = mBaseColormap->Fade.r; + shadeConstants.fade_green = mBaseColormap->Fade.g; + shadeConstants.fade_blue = mBaseColormap->Fade.b; + shadeConstants.fade_alpha = mBaseColormap->Fade.a; + shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256; + shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0); + } + else + { + shadeConstants.light_red = 256; + shadeConstants.light_green = 256; + shadeConstants.light_blue = 256; + shadeConstants.light_alpha = 256; + shadeConstants.fade_red = 0; + shadeConstants.fade_green = 0; + shadeConstants.fade_blue = 0; + shadeConstants.fade_alpha = 256; + shadeConstants.desaturate = 0; + shadeConstants.simple_shade = true; + } + return shadeConstants; + } +} diff --git a/src/swrenderer/viewport/r_drawerargs.h b/src/swrenderer/viewport/r_drawerargs.h new file mode 100644 index 0000000000..d36bc61a5b --- /dev/null +++ b/src/swrenderer/viewport/r_drawerargs.h @@ -0,0 +1,59 @@ + +#pragma once + +#include "templates.h" +#include "doomtype.h" +#include "doomdef.h" +#include "r_defs.h" +#include "swrenderer/drawers/r_draw.h" +#include "v_video.h" +#include "r_data/colormaps.h" +#include "r_data/r_translate.h" +#include "swrenderer/scene/r_light.h" + +struct FSWColormap; +struct FLightNode; +struct TriLight; + +namespace swrenderer +{ + class SWPixelFormatDrawers; + class DrawerArgs; + struct ShadeConstants; + + class DrawerArgs + { + public: + void SetLight(FSWColormap *base_colormap, float light, int shade); + void SetTranslationMap(lighttable_t *translation); + + uint8_t *Colormap() const; + uint8_t *TranslationMap() const { return mTranslation; } + + ShadeConstants ColormapConstants() const; + fixed_t Light() const { return LIGHTSCALE(mLight, mShade); } + + protected: + static SWPixelFormatDrawers *Drawers(); + + private: + FSWColormap *mBaseColormap = nullptr; + float mLight = 0.0f; + int mShade = 0; + uint8_t *mTranslation = nullptr; + }; + + 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; + }; +} diff --git a/src/swrenderer/viewport/r_skydrawer.cpp b/src/swrenderer/viewport/r_skydrawer.cpp new file mode 100644 index 0000000000..922324f641 --- /dev/null +++ b/src/swrenderer/viewport/r_skydrawer.cpp @@ -0,0 +1,68 @@ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// + +#include +#include "r_skydrawer.h" + +namespace swrenderer +{ + void SkyDrawerArgs::DrawSingleSkyColumn() + { + Drawers()->DrawSingleSkyColumn(*this); + } + + void SkyDrawerArgs::DrawDoubleSkyColumn() + { + Drawers()->DrawDoubleSkyColumn(*this); + } + + void SkyDrawerArgs::SetDest(int x, int y) + { + auto viewport = RenderViewport::Instance(); + dc_dest = viewport->GetDest(x, y); + dc_dest_y = y; + } + + void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column) + { + if (RenderViewport::Instance()->RenderTarget->IsBgra()) + { + dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr); + dc_sourceheight = texture->GetHeight(); + } + else + { + dc_source = texture->GetColumn(column, nullptr); + dc_sourceheight = texture->GetHeight(); + } + } + + void SkyDrawerArgs::SetBackTexture(FTexture *texture, uint32_t column) + { + if (texture == nullptr) + { + dc_source2 = nullptr; + dc_sourceheight2 = 1; + } + else if (RenderViewport::Instance()->RenderTarget->IsBgra()) + { + dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr); + dc_sourceheight2 = texture->GetHeight(); + } + else + { + dc_source2 = texture->GetColumn(column, nullptr); + dc_sourceheight2 = texture->GetHeight(); + } + } +} diff --git a/src/swrenderer/viewport/r_skydrawer.h b/src/swrenderer/viewport/r_skydrawer.h new file mode 100644 index 0000000000..8321b4e040 --- /dev/null +++ b/src/swrenderer/viewport/r_skydrawer.h @@ -0,0 +1,58 @@ + +#pragma once + +#include "r_drawerargs.h" + +struct FSWColormap; +struct FLightNode; +struct TriLight; + +namespace swrenderer +{ + class SkyDrawerArgs : public DrawerArgs + { + public: + void SetDest(int x, int y); + void SetCount(int count) { dc_count = count; } + void SetFrontTexture(FTexture *texture, uint32_t column); + void SetBackTexture(FTexture *texture, uint32_t column); + void SetTextureVPos(uint32_t texturefrac) { dc_texturefrac = texturefrac; } + void SetTextureVStep(uint32_t iscale) { dc_iscale = iscale; } + void SetSolidTop(uint32_t color) { solid_top = color; } + void SetSolidBottom(uint32_t color) { solid_bottom = color; } + void SetFadeSky(bool enable) { fadeSky = enable; } + + uint8_t *Dest() const { return dc_dest; } + int DestY() const { return dc_dest_y; } + int Count() const { return dc_count; } + + uint32_t TextureVPos() const { return dc_texturefrac; } + uint32_t TextureVStep() const { return dc_iscale; } + + uint32_t SolidTopColor() const { return solid_top; } + uint32_t SolidBottomColor() const { return solid_bottom; } + bool FadeSky() const { return fadeSky; } + + const uint8_t *FrontTexturePixels() const { return dc_source; } + const uint8_t *BackTexturePixels() const { return dc_source2; } + int FrontTextureHeight() const { return dc_sourceheight; } + int BackTextureHeight() const { return dc_sourceheight2; } + + void DrawSingleSkyColumn(); + void DrawDoubleSkyColumn(); + + private: + uint8_t *dc_dest = nullptr; + int dc_dest_y = 0; + int dc_count = 0; + const uint8_t *dc_source; + const uint8_t *dc_source2; + uint32_t dc_sourceheight; + uint32_t dc_sourceheight2; + uint32_t dc_texturefrac; + uint32_t dc_iscale; + uint32_t solid_top; + uint32_t solid_bottom; + bool fadeSky; + }; +} diff --git a/src/swrenderer/viewport/r_spandrawer.cpp b/src/swrenderer/viewport/r_spandrawer.cpp new file mode 100644 index 0000000000..7d14886271 --- /dev/null +++ b/src/swrenderer/viewport/r_spandrawer.cpp @@ -0,0 +1,118 @@ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// + +#include +#include "r_spandrawer.h" + +namespace swrenderer +{ + SpanDrawerArgs::SpanDrawerArgs() + { + spanfunc = &SWPixelFormatDrawers::DrawSpan; + } + + void SpanDrawerArgs::SetTexture(FTexture *tex) + { + tex->GetWidth(); + ds_xbits = tex->WidthBits; + ds_ybits = tex->HeightBits; + if ((1 << ds_xbits) > tex->GetWidth()) + { + ds_xbits--; + } + if ((1 << ds_ybits) > tex->GetHeight()) + { + ds_ybits--; + } + + auto viewport = RenderViewport::Instance(); + ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); + ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; + } + + void SpanDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha) + { + if (masked) + { + if (alpha < OPAQUE || additive) + { + if (!additive) + { + spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedTranslucent; + dc_srcblend = Col2RGB8[alpha >> 10]; + dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + else + { + spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; + } + } + else + { + spanfunc = &SWPixelFormatDrawers::DrawSpanMasked; + } + } + else + { + if (alpha < OPAQUE || additive) + { + if (!additive) + { + spanfunc = &SWPixelFormatDrawers::DrawSpanTranslucent; + dc_srcblend = Col2RGB8[alpha >> 10]; + dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + else + { + spanfunc = &SWPixelFormatDrawers::DrawSpanAddClamp; + dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; + } + } + else + { + spanfunc = &SWPixelFormatDrawers::DrawSpan; + } + } + } + + void SpanDrawerArgs::DrawSpan() + { + (Drawers()->*spanfunc)(*this); + } + + void SpanDrawerArgs::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, FDynamicColormap *basecolormap) + { + Drawers()->DrawTiltedSpan(*this, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap); + } + + void SpanDrawerArgs::DrawFogBoundaryLine(int y, int x1, int x2) + { + Drawers()->DrawFogBoundaryLine(*this, y, x1, x2); + } + + void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2) + { + Drawers()->DrawColoredSpan(*this, y, x1, x2); + } +} diff --git a/src/swrenderer/viewport/r_spandrawer.h b/src/swrenderer/viewport/r_spandrawer.h new file mode 100644 index 0000000000..dcb348f201 --- /dev/null +++ b/src/swrenderer/viewport/r_spandrawer.h @@ -0,0 +1,80 @@ + +#pragma once + +#include "r_drawerargs.h" + +struct FSWColormap; +struct FLightNode; +struct TriLight; + +namespace swrenderer +{ + class SpanDrawerArgs : public DrawerArgs + { + public: + SpanDrawerArgs(); + + void SetStyle(bool masked, bool additive, fixed_t alpha); + void SetDestY(int y) { ds_y = y; } + void SetDestX1(int x) { ds_x1 = x; } + void SetDestX2(int x) { ds_x2 = x; } + void SetTexture(FTexture *tex); + void SetTextureLOD(double lod) { ds_lod = lod; } + void SetTextureUPos(dsfixed_t xfrac) { ds_xfrac = xfrac; } + void SetTextureVPos(dsfixed_t yfrac) { ds_yfrac = yfrac; } + void SetTextureUStep(dsfixed_t xstep) { ds_xstep = xstep; } + void SetTextureVStep(dsfixed_t vstep) { ds_ystep = vstep; } + void SetSolidColor(int colorIndex) { ds_color = colorIndex; } + + void DrawSpan(); + void 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, FDynamicColormap *basecolormap); + void DrawColoredSpan(int y, int x1, int x2); + void DrawFogBoundaryLine(int y, int x1, int x2); + + uint32_t *SrcBlend() const { return dc_srcblend; } + uint32_t *DestBlend() const { return dc_destblend; } + fixed_t SrcAlpha() const { return dc_srcalpha; } + fixed_t DestAlpha() const { return dc_destalpha; } + int DestY() const { return ds_y; } + int DestX1() const { return ds_x1; } + int DestX2() const { return ds_x2; } + dsfixed_t TextureUPos() const { return ds_xfrac; } + dsfixed_t TextureVPos() const { return ds_yfrac; } + dsfixed_t TextureUStep() const { return ds_xstep; } + dsfixed_t TextureVStep() const { return ds_ystep; } + int SolidColor() const { return ds_color; } + int TextureWidthBits() const { return ds_xbits; } + int TextureHeightBits() const { return ds_ybits; } + const uint8_t *TexturePixels() const { return ds_source; } + bool MipmappedTexture() const { return ds_source_mipmapped; } + double TextureLOD() const { return ds_lod; } + + FVector3 dc_normal; + FVector3 dc_viewpos; + FVector3 dc_viewpos_step; + TriLight *dc_lights = nullptr; + int dc_num_lights = 0; + + private: + typedef void(SWPixelFormatDrawers::*SpanDrawerFunc)(const SpanDrawerArgs &args); + SpanDrawerFunc spanfunc; + + int ds_y; + int ds_x1; + int ds_x2; + int ds_xbits; + int ds_ybits; + const uint8_t *ds_source; + bool ds_source_mipmapped; + dsfixed_t ds_xfrac; + dsfixed_t ds_yfrac; + dsfixed_t ds_xstep; + dsfixed_t ds_ystep; + uint32_t *dc_srcblend; + uint32_t *dc_destblend; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + int ds_color = 0; + double ds_lod; + }; +} diff --git a/src/swrenderer/drawers/r_drawerargs.cpp b/src/swrenderer/viewport/r_spritedrawer.cpp similarity index 66% rename from src/swrenderer/drawers/r_drawerargs.cpp rename to src/swrenderer/viewport/r_spritedrawer.cpp index 1b9b1556e7..95a494c31f 100644 --- a/src/swrenderer/drawers/r_drawerargs.cpp +++ b/src/swrenderer/viewport/r_spritedrawer.cpp @@ -1,5 +1,5 @@ /* -** r_drawerargs.cpp +** r_spritedrawer.cpp ** **--------------------------------------------------------------------------- ** Copyright 1998-2016 Randy Heit @@ -33,115 +33,15 @@ */ #include -#include "r_drawerargs.h" -#include "r_draw_pal.h" -#include "r_draw_rgba.h" +#include "r_spritedrawer.h" namespace swrenderer { - SWPixelFormatDrawers *DrawerArgs::Drawers() - { - if (RenderViewport::Instance()->RenderTarget->IsBgra()) - { - static SWTruecolorDrawers tc_drawers; - return &tc_drawers; - } - else - { - static SWPalDrawers pal_drawers; - return &pal_drawers; - } - } - SpriteDrawerArgs::SpriteDrawerArgs() { colfunc = &SWPixelFormatDrawers::DrawColumn; } - SpanDrawerArgs::SpanDrawerArgs() - { - spanfunc = &SWPixelFormatDrawers::DrawSpan; - } - - void DrawerArgs::SetLight(FSWColormap *base_colormap, float light, int shade) - { - mBaseColormap = base_colormap; - mTranslation = nullptr; - mLight = light; - mShade = shade; - } - - void DrawerArgs::SetTranslationMap(lighttable_t *translation) - { - mTranslation = translation; - } - - uint8_t *DrawerArgs::Colormap() const - { - if (mBaseColormap) - { - if (RenderViewport::Instance()->RenderTarget->IsBgra()) - return mBaseColormap->Maps; - else - return mBaseColormap->Maps + (GETPALOOKUP(mLight, mShade) << COLORMAPSHIFT); - } - else - { - return mTranslation; - } - } - - ShadeConstants DrawerArgs::ColormapConstants() const - { - ShadeConstants shadeConstants; - if (mBaseColormap) - { - shadeConstants.light_red = mBaseColormap->Color.r * 256 / 255; - shadeConstants.light_green = mBaseColormap->Color.g * 256 / 255; - shadeConstants.light_blue = mBaseColormap->Color.b * 256 / 255; - shadeConstants.light_alpha = mBaseColormap->Color.a * 256 / 255; - shadeConstants.fade_red = mBaseColormap->Fade.r; - shadeConstants.fade_green = mBaseColormap->Fade.g; - shadeConstants.fade_blue = mBaseColormap->Fade.b; - shadeConstants.fade_alpha = mBaseColormap->Fade.a; - shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256; - shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0); - } - else - { - shadeConstants.light_red = 256; - shadeConstants.light_green = 256; - shadeConstants.light_blue = 256; - shadeConstants.light_alpha = 256; - shadeConstants.fade_red = 0; - shadeConstants.fade_green = 0; - shadeConstants.fade_blue = 0; - shadeConstants.fade_alpha = 256; - shadeConstants.desaturate = 0; - shadeConstants.simple_shade = true; - } - return shadeConstants; - } - - void SpanDrawerArgs::SetTexture(FTexture *tex) - { - tex->GetWidth(); - ds_xbits = tex->WidthBits; - ds_ybits = tex->HeightBits; - if ((1 << ds_xbits) > tex->GetWidth()) - { - ds_xbits--; - } - if ((1 << ds_ybits) > tex->GetHeight()) - { - ds_ybits--; - } - - auto viewport = RenderViewport::Instance(); - ds_source = viewport->RenderTarget->IsBgra() ? (const uint8_t*)tex->GetPixelsBgra() : tex->GetPixels(); - ds_source_mipmapped = tex->Mipmapped() && tex->GetWidth() > 1 && tex->GetHeight() > 1; - } - void SpriteDrawerArgs::DrawMaskedColumn(int x, fixed_t iscale, FTexture *tex, fixed_t col, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked) { auto viewport = RenderViewport::Instance(); @@ -588,180 +488,6 @@ namespace swrenderer return SetPatchStyle(style, FLOAT2FIXED(alpha), translation, color, basecolormap, shadedlightshade); } - void WallDrawerArgs::SetDest(int x, int y) - { - auto viewport = RenderViewport::Instance(); - dc_dest = viewport->GetDest(x, y); - dc_dest_y = y; - } - - void WallDrawerArgs::DrawColumn() - { - (Drawers()->*wallfunc)(*this); - } - - void SpanDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha) - { - if (masked) - { - if (alpha < OPAQUE || additive) - { - if (!additive) - { - spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedTranslucent; - dc_srcblend = Col2RGB8[alpha >> 10]; - dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - else - { - spanfunc = &SWPixelFormatDrawers::DrawSpanMaskedAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; - dc_srcalpha = alpha; - dc_destalpha = FRACUNIT; - } - } - else - { - spanfunc = &SWPixelFormatDrawers::DrawSpanMasked; - } - } - else - { - if (alpha < OPAQUE || additive) - { - if (!additive) - { - spanfunc = &SWPixelFormatDrawers::DrawSpanTranslucent; - dc_srcblend = Col2RGB8[alpha >> 10]; - dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - else - { - spanfunc = &SWPixelFormatDrawers::DrawSpanAddClamp; - dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; - dc_srcalpha = alpha; - dc_destalpha = FRACUNIT; - } - } - else - { - spanfunc = &SWPixelFormatDrawers::DrawSpan; - } - } - } - - void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha) - { - if (alpha < OPAQUE || additive) - { - if (!additive) - { - wallfunc = &SWPixelFormatDrawers::DrawWallAddColumn; - dc_srcblend = Col2RGB8[alpha >> 10]; - dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; - dc_srcalpha = alpha; - dc_destalpha = OPAQUE - alpha; - } - else - { - wallfunc = &SWPixelFormatDrawers::DrawWallAddClampColumn; - dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; - dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; - dc_srcalpha = alpha; - dc_destalpha = FRACUNIT; - } - } - else if (masked) - { - wallfunc = &SWPixelFormatDrawers::DrawWallMaskedColumn; - } - else - { - wallfunc = &SWPixelFormatDrawers::DrawWallColumn; - } - } - - bool WallDrawerArgs::IsMaskedDrawer() const - { - return wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn; - } - - void SpanDrawerArgs::DrawSpan() - { - (Drawers()->*spanfunc)(*this); - } - - void SpanDrawerArgs::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, FDynamicColormap *basecolormap) - { - Drawers()->DrawTiltedSpan(*this, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap); - } - - void SpanDrawerArgs::DrawFogBoundaryLine(int y, int x1, int x2) - { - Drawers()->DrawFogBoundaryLine(*this, y, x1, x2); - } - - void SpanDrawerArgs::DrawColoredSpan(int y, int x1, int x2) - { - Drawers()->DrawColoredSpan(*this, y, x1, x2); - } - - void SkyDrawerArgs::DrawSingleSkyColumn() - { - Drawers()->DrawSingleSkyColumn(*this); - } - - void SkyDrawerArgs::DrawDoubleSkyColumn() - { - Drawers()->DrawDoubleSkyColumn(*this); - } - - void SkyDrawerArgs::SetDest(int x, int y) - { - auto viewport = RenderViewport::Instance(); - dc_dest = viewport->GetDest(x, y); - dc_dest_y = y; - } - - void SkyDrawerArgs::SetFrontTexture(FTexture *texture, uint32_t column) - { - if (RenderViewport::Instance()->RenderTarget->IsBgra()) - { - dc_source = (const uint8_t *)texture->GetColumnBgra(column, nullptr); - dc_sourceheight = texture->GetHeight(); - } - else - { - dc_source = texture->GetColumn(column, nullptr); - dc_sourceheight = texture->GetHeight(); - } - } - - void SkyDrawerArgs::SetBackTexture(FTexture *texture, uint32_t column) - { - if (texture == nullptr) - { - dc_source2 = nullptr; - dc_sourceheight2 = 1; - } - else if (RenderViewport::Instance()->RenderTarget->IsBgra()) - { - dc_source2 = (const uint8_t *)texture->GetColumnBgra(column, nullptr); - dc_sourceheight2 = texture->GetHeight(); - } - else - { - dc_source2 = texture->GetColumn(column, nullptr); - dc_sourceheight2 = texture->GetHeight(); - } - } - void SpriteDrawerArgs::FillColumn() { Drawers()->FillColumn(*this); diff --git a/src/swrenderer/viewport/r_spritedrawer.h b/src/swrenderer/viewport/r_spritedrawer.h new file mode 100644 index 0000000000..74c04c9d03 --- /dev/null +++ b/src/swrenderer/viewport/r_spritedrawer.h @@ -0,0 +1,85 @@ + +#pragma once + +#include "r_drawerargs.h" + +struct FSWColormap; +struct FLightNode; +struct TriLight; + +namespace swrenderer +{ + class SpriteDrawerArgs : public DrawerArgs + { + public: + SpriteDrawerArgs(); + + bool SetPatchStyle(FRenderStyle style, fixed_t alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); + bool SetPatchStyle(FRenderStyle style, float alpha, int translation, uint32_t color, FDynamicColormap *&basecolormap, fixed_t shadedlightshade = 0); + void SetDest(int x, int y); + void SetCount(int count) { dc_count = count; } + void SetSolidColor(int color) { dc_color = color; } + + void DrawMaskedColumn(int x, fixed_t iscale, FTexture *texture, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked = false); + void FillColumn(); + + uint8_t *Dest() const { return dc_dest; } + int DestY() const { return dc_dest_y; } + int Count() const { return dc_count; } + + int FuzzX() const { return dc_x; } + int FuzzY1() const { return dc_yl; } + int FuzzY2() const { return dc_yh; } + + uint32_t TextureUPos() const { return dc_texturefracx; } + fixed_t TextureVPos() const { return dc_texturefrac; } + fixed_t TextureVStep() const { return dc_iscale; } + + int SolidColor() const { return dc_color; } + uint32_t SrcColorIndex() const { return dc_srccolor; } + uint32_t SrcColorBgra() const { return dc_srccolor_bgra; } + + const uint8_t *TexturePixels() const { return dc_source; } + const uint8_t *TexturePixels2() const { return dc_source2; } + uint32_t TextureHeight() const { return dc_textureheight; } + + uint32_t *SrcBlend() const { return dc_srcblend; } + uint32_t *DestBlend() const { return dc_destblend; } + fixed_t SrcAlpha() const { return dc_srcalpha; } + fixed_t DestAlpha() const { return dc_destalpha; } + + private: + bool SetBlendFunc(int op, fixed_t fglevel, fixed_t bglevel, int flags); + static fixed_t GetAlpha(int type, fixed_t alpha); + void DrawMaskedColumnBgra(int x, fixed_t iscale, FTexture *tex, fixed_t column, double spryscale, double sprtopscreen, bool sprflipvert, const short *mfloorclip, const short *mceilingclip, bool unmasked); + + uint8_t *dc_dest = nullptr; + int dc_dest_y = 0; + int dc_count = 0; + + fixed_t dc_iscale; + fixed_t dc_texturefrac; + uint32_t dc_texturefracx; + + uint32_t dc_textureheight = 0; + const uint8_t *dc_source = nullptr; + const uint8_t *dc_source2 = nullptr; + bool drawer_needs_pal_input = false; + + uint32_t *dc_srcblend = nullptr; + uint32_t *dc_destblend = nullptr; + fixed_t dc_srcalpha = OPAQUE; + fixed_t dc_destalpha = 0; + + int dc_x = 0; + int dc_yl = 0; + int dc_yh = 0; + + int dc_color = 0; + uint32_t dc_srccolor = 0; + uint32_t dc_srccolor_bgra = 0; + + typedef void(SWPixelFormatDrawers::*SpriteDrawerFunc)(const SpriteDrawerArgs &args); + SpriteDrawerFunc colfunc; + }; +} diff --git a/src/swrenderer/scene/r_viewport.cpp b/src/swrenderer/viewport/r_viewport.cpp similarity index 99% rename from src/swrenderer/scene/r_viewport.cpp rename to src/swrenderer/viewport/r_viewport.cpp index 24413b3c55..62edf110e1 100644 --- a/src/swrenderer/scene/r_viewport.cpp +++ b/src/swrenderer/viewport/r_viewport.cpp @@ -28,7 +28,7 @@ #include "d_net.h" #include "g_level.h" #include "r_utility.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #include "swrenderer/scene/r_light.h" #include "swrenderer/drawers/r_draw.h" #include "swrenderer/things/r_playersprite.h" diff --git a/src/swrenderer/scene/r_viewport.h b/src/swrenderer/viewport/r_viewport.h similarity index 100% rename from src/swrenderer/scene/r_viewport.h rename to src/swrenderer/viewport/r_viewport.h diff --git a/src/swrenderer/viewport/r_walldrawer.cpp b/src/swrenderer/viewport/r_walldrawer.cpp new file mode 100644 index 0000000000..c30f86ffb6 --- /dev/null +++ b/src/swrenderer/viewport/r_walldrawer.cpp @@ -0,0 +1,66 @@ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// + +#include +#include "r_walldrawer.h" + +namespace swrenderer +{ + void WallDrawerArgs::SetDest(int x, int y) + { + auto viewport = RenderViewport::Instance(); + dc_dest = viewport->GetDest(x, y); + dc_dest_y = y; + } + + void WallDrawerArgs::DrawColumn() + { + (Drawers()->*wallfunc)(*this); + } + + void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha) + { + if (alpha < OPAQUE || additive) + { + if (!additive) + { + wallfunc = &SWPixelFormatDrawers::DrawWallAddColumn; + dc_srcblend = Col2RGB8[alpha >> 10]; + dc_destblend = Col2RGB8[(OPAQUE - alpha) >> 10]; + dc_srcalpha = alpha; + dc_destalpha = OPAQUE - alpha; + } + else + { + wallfunc = &SWPixelFormatDrawers::DrawWallAddClampColumn; + dc_srcblend = Col2RGB8_LessPrecision[alpha >> 10]; + dc_destblend = Col2RGB8_LessPrecision[FRACUNIT >> 10]; + dc_srcalpha = alpha; + dc_destalpha = FRACUNIT; + } + } + else if (masked) + { + wallfunc = &SWPixelFormatDrawers::DrawWallMaskedColumn; + } + else + { + wallfunc = &SWPixelFormatDrawers::DrawWallColumn; + } + } + + bool WallDrawerArgs::IsMaskedDrawer() const + { + return wallfunc == &SWPixelFormatDrawers::DrawWallMaskedColumn; + } +} diff --git a/src/swrenderer/viewport/r_walldrawer.h b/src/swrenderer/viewport/r_walldrawer.h new file mode 100644 index 0000000000..678463b131 --- /dev/null +++ b/src/swrenderer/viewport/r_walldrawer.h @@ -0,0 +1,79 @@ + +#pragma once + +#include "r_drawerargs.h" + +struct FSWColormap; +struct FLightNode; +struct TriLight; + +namespace swrenderer +{ + class WallDrawerArgs : public DrawerArgs + { + public: + void SetStyle(bool masked, bool additive, fixed_t alpha); + void SetDest(int x, int y); + void SetCount(int count) { dc_count = count; } + void SetTexture(const uint8_t *pixels, const uint8_t *pixels2, int height) + { + dc_source = pixels; + dc_source2 = pixels2; + dc_textureheight = height; + } + void SetTextureFracBits(int bits) { dc_wall_fracbits = bits; } + void SetTextureUPos(uint32_t pos) { dc_texturefracx = pos; } + void SetTextureVPos(fixed_t pos) { dc_texturefrac = pos; } + void SetTextureVStep(fixed_t step) { dc_iscale = step; } + + bool IsMaskedDrawer() const; + + void DrawColumn(); + + uint8_t *Dest() const { return dc_dest; } + int DestY() const { return dc_dest_y; } + int Count() const { return dc_count; } + + uint32_t *SrcBlend() const { return dc_srcblend; } + uint32_t *DestBlend() const { return dc_destblend; } + fixed_t SrcAlpha() const { return dc_srcalpha; } + fixed_t DestAlpha() const { return dc_destalpha; } + + uint32_t TextureUPos() const { return dc_texturefracx; } + fixed_t TextureVPos() const { return dc_texturefrac; } + fixed_t TextureVStep() const { return dc_iscale; } + + const uint8_t *TexturePixels() const { return dc_source; } + const uint8_t *TexturePixels2() const { return dc_source2; } + uint32_t TextureHeight() const { return dc_textureheight; } + + int TextureFracBits() const { return dc_wall_fracbits; } + + FVector3 dc_normal; + FVector3 dc_viewpos; + FVector3 dc_viewpos_step; + TriLight *dc_lights = nullptr; + int dc_num_lights = 0; + + private: + uint8_t *dc_dest = nullptr; + int dc_dest_y = 0; + int dc_count; + + fixed_t dc_iscale; + fixed_t dc_texturefrac; + uint32_t dc_texturefracx; + uint32_t dc_textureheight; + const uint8_t *dc_source; + const uint8_t *dc_source2; + int dc_wall_fracbits; + + uint32_t *dc_srcblend; + uint32_t *dc_destblend; + fixed_t dc_srcalpha; + fixed_t dc_destalpha; + + typedef void(SWPixelFormatDrawers::*WallDrawerFunc)(const WallDrawerArgs &args); + WallDrawerFunc wallfunc = nullptr; + }; +} diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 5fdd5c6904..eeca598fef 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -46,7 +46,7 @@ #include "swrenderer/drawers/r_draw.h" #include "swrenderer/drawers/r_draw_rgba.h" #include "swrenderer/scene/r_light.h" -#include "swrenderer/scene/r_viewport.h" +#include "swrenderer/viewport/r_viewport.h" #endif #include "r_data/r_translate.h" #include "doomstat.h"