- moved renderstyle and colortables code to 'common'.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:02:14 +02:00
parent f8e9cb8fbc
commit 3e285d2261
18 changed files with 128 additions and 87 deletions

View file

@ -1060,7 +1060,6 @@ set (PCH_SOURCES
r_data/sprites.cpp
r_data/portalgroups.cpp
r_data/voxels.cpp
r_data/renderstyle.cpp
r_data/r_canvastexture.cpp
r_data/r_interpolate.cpp
r_data/r_vanillatrans.cpp
@ -1149,6 +1148,8 @@ set (PCH_SOURCES
common/engine/palettecontainer.cpp
common/engine/stringtable.cpp
common/engine/i_interface.cpp
common/engine/renderstyle.cpp
common/engine/v_colortables.cpp
utility/m_random.cpp
utility/nodebuilder/nodebuild.cpp

View file

@ -35,7 +35,6 @@
#include "templates.h"
#include "renderstyle.h"
#include "c_cvars.h"
#include "serializer.h"
CVAR (Bool, r_drawtrans, true, 0)
CVAR (Int, r_drawfuzz, 1, CVAR_ARCHIVE)
@ -158,8 +157,3 @@ void FRenderStyle::CheckFuzz()
BlendOp = STYLEOP_Fuzz;
}
}
FSerializer &Serialize(FSerializer &arc, const char *key, FRenderStyle &style, FRenderStyle *def)
{
return arc.Array(key, &style.BlendOp, def ? &def->BlendOp : nullptr, 4);
}

View file

@ -0,0 +1,103 @@
/*
** v_colortables.cpp
** Various color blending tables
**
**---------------------------------------------------------------------------
** Copyright 1998-2006 Randy Heit
** All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** 1. Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** 2. Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in the
** documentation and/or other materials provided with the distribution.
** 3. The name of the author may not be used to endorse or promote products
** derived from this software without specific prior written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**---------------------------------------------------------------------------
**
*/
#include "v_colortables.h"
#include "colormatcher.h"
uint32_t Col2RGB8[65][256];
uint32_t *Col2RGB8_LessPrecision[65];
uint32_t Col2RGB8_Inverse[65][256];
uint32_t Col2RGB8_2[63][256]; // this array's second dimension is called up by pointer as Col2RGB8_LessPrecision[] elsewhere.
ColorTable32k RGB32k;
ColorTable256k RGB256k;
//==========================================================================
//
// BuildTransTable
//
// Build the tables necessary for blending - used by software rendering and
// texture composition
//
//==========================================================================
void BuildTransTable (const PalEntry *palette)
{
int r, g, b;
// create the RGB555 lookup table
for (r = 0; r < 32; r++)
for (g = 0; g < 32; g++)
for (b = 0; b < 32; b++)
RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2));
// create the RGB666 lookup table
for (r = 0; r < 64; r++)
for (g = 0; g < 64; g++)
for (b = 0; b < 64; b++)
RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4));
int x, y;
// create the swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)
Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) |
((palette[y].g*x)>>4) |
(((palette[y].b*x)>>4)<<10);
// create the swizzled palette with the lsb of red and blue forced to 0
// (for green, a 1 is okay since it never gets added into)
for (x = 1; x < 64; x++)
{
Col2RGB8_LessPrecision[x] = Col2RGB8_2[x-1];
for (y = 0; y < 256; y++)
{
Col2RGB8_2[x-1][y] = Col2RGB8[x][y] & 0x3feffbff;
}
}
Col2RGB8_LessPrecision[0] = Col2RGB8[0];
Col2RGB8_LessPrecision[64] = Col2RGB8[64];
// create the inverse swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)
{
Col2RGB8_Inverse[x][y] = (((((255-palette[y].r)*x)>>4)<<20) |
(((255-palette[y].g)*x)>>4) |
((((255-palette[y].b)*x)>>4)<<10)) & 0x3feffbff;
}
}

View file

@ -1,5 +1,8 @@
#pragma once
#include <stdint.h>
#include "palentry.h"
// extracted from v_video.h because this caused circular dependencies between v_video.h and textures.h
// Translucency tables
@ -50,3 +53,5 @@ extern uint32_t Col2RGB8_Inverse[65][256];
// ------10000000001000000000100000 = 0x40100400 >> 5
// --11111-----11111-----11111----- = 0x40100400 - (0x40100400 >> 5) aka "white"
// --111111111111111111111111111111 = 0x3FFFFFFF
void BuildTransTable (const PalEntry *palette);

View file

@ -38,7 +38,7 @@
#include "dobject.h"
#include "v_collection.h"
#include "v_text.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
class player_t;
struct FRemapTable;

View file

@ -37,7 +37,7 @@
#include <string.h>
#include "doomtype.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
class FScanner;
class FDecalTemplate;

View file

@ -38,17 +38,11 @@
#include "basics.h"
#include "vectors.h"
#include "colormatcher.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "textureid.h"
#include <vector>
#include "hwrenderer/textures/hw_texcontainer.h"
/*
#include "v_palette.h"
#include "r_data/v_colortables.h"
#include "r_data/r_translate.h"
*/
// 15 because 0th texture is our texture
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15

View file

@ -41,7 +41,7 @@
#include "doomdef.h"
#include "textures/textures.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "s_sound.h"
#include "memarena.h"
#include "g_level.h"

View file

@ -30,7 +30,7 @@
#ifndef __P_PSPR_H__
#define __P_PSPR_H__
#include "r_data/renderstyle.h"
#include "renderstyle.h"
// Basic data types.
// Needs fixed point, and BAM angles.

View file

@ -50,13 +50,6 @@
#include "g_levellocals.h"
#include "m_png.h"
uint32_t Col2RGB8[65][256];
uint32_t *Col2RGB8_LessPrecision[65];
uint32_t Col2RGB8_Inverse[65][256];
uint32_t Col2RGB8_2[63][256]; // this array's second dimension is called up by pointer as Col2RGB8_LessPrecision[] elsewhere.
ColorTable32k RGB32k;
ColorTable256k RGB256k;
/* Current color blending values */
int BlendR, BlendG, BlendB, BlendA;
@ -94,61 +87,6 @@ CCMD (bumpgamma)
}
//==========================================================================
//
// BuildTransTable
//
// Build the tables necessary for blending
//
//==========================================================================
static void BuildTransTable (const PalEntry *palette)
{
int r, g, b;
// create the RGB555 lookup table
for (r = 0; r < 32; r++)
for (g = 0; g < 32; g++)
for (b = 0; b < 32; b++)
RGB32k.RGB[r][g][b] = ColorMatcher.Pick ((r<<3)|(r>>2), (g<<3)|(g>>2), (b<<3)|(b>>2));
// create the RGB666 lookup table
for (r = 0; r < 64; r++)
for (g = 0; g < 64; g++)
for (b = 0; b < 64; b++)
RGB256k.RGB[r][g][b] = ColorMatcher.Pick ((r<<2)|(r>>4), (g<<2)|(g>>4), (b<<2)|(b>>4));
int x, y;
// create the swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)
Col2RGB8[x][y] = (((palette[y].r*x)>>4)<<20) |
((palette[y].g*x)>>4) |
(((palette[y].b*x)>>4)<<10);
// create the swizzled palette with the lsb of red and blue forced to 0
// (for green, a 1 is okay since it never gets added into)
for (x = 1; x < 64; x++)
{
Col2RGB8_LessPrecision[x] = Col2RGB8_2[x-1];
for (y = 0; y < 256; y++)
{
Col2RGB8_2[x-1][y] = Col2RGB8[x][y] & 0x3feffbff;
}
}
Col2RGB8_LessPrecision[0] = Col2RGB8[0];
Col2RGB8_LessPrecision[64] = Col2RGB8[64];
// create the inverse swizzled palette
for (x = 0; x < 65; x++)
for (y = 0; y < 256; y++)
{
Col2RGB8_Inverse[x][y] = (((((255-palette[y].r)*x)>>4)<<20) |
(((255-palette[y].g)*x)>>4) |
((((255-palette[y].b)*x)>>4)<<10)) & 0x3feffbff;
}
}
void InitPalette ()
{

View file

@ -4,7 +4,7 @@
#include "tarray.h"
#include "textures.h"
#include "v_palette.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "r_data/colormaps.h"
struct DrawParms;

View file

@ -5,7 +5,7 @@
//
//==========================================================================
#include "r_defs.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "textures/textures.h"
#include "r_data/colormaps.h"

View file

@ -24,7 +24,7 @@
#include <cstdint>
#include <vector>
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "rendering/swrenderer/drawers/r_draw.h"
class FString;

View file

@ -41,9 +41,9 @@
#include "doomdef.h"
#include "m_png.h"
#include "dobject.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "c_cvars.h"
#include "r_data/v_colortables.h"
#include "v_colortables.h"
#include "v_2ddrawer.h"
#include "hwrenderer/dynlights/hw_shadowmap.h"

View file

@ -2,7 +2,7 @@
#pragma once
#include "vulkan/system/vk_objects.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include "hwrenderer/data/buffers.h"
#include "hwrenderer/scene/hw_renderstate.h"
#include <string.h>

View file

@ -22,7 +22,7 @@
#include "vk_builders.h"
#include "engineerrors.h"
#include "r_data/renderstyle.h"
#include "renderstyle.h"
#include <ShaderLang.h>
#include <GlslangToSpv.h>

View file

@ -2302,3 +2302,9 @@ FSerializer &Serialize(FSerializer &arc, const char *key, NumericValue &value, N
}
return arc;
}
#include "renderstyle.h"
FSerializer& Serialize(FSerializer& arc, const char* key, FRenderStyle& style, FRenderStyle* def)
{
return arc.Array(key, &style.BlendOp, def ? &def->BlendOp : nullptr, 4);
}