2006-02-24 04:48:15 +00:00
|
|
|
// Emacs style mode select -*- C++ -*-
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// $Id:$
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// $Log:$
|
|
|
|
//
|
|
|
|
// DESCRIPTION:
|
|
|
|
// Rendering main loop and setup functions,
|
|
|
|
// utility functions (BSP, geometry, trigonometry).
|
|
|
|
// See tables.c, too.
|
|
|
|
//
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// HEADER FILES ------------------------------------------------------------
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "templates.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "d_net.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "m_bbox.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "r_local.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "st_stuff.h"
|
|
|
|
#include "c_cvars.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "stats.h"
|
|
|
|
#include "i_video.h"
|
|
|
|
#include "i_system.h"
|
2006-07-01 00:21:36 +00:00
|
|
|
#include "a_sharedglobal.h"
|
2007-12-26 16:06:03 +00:00
|
|
|
#include "r_translate.h"
|
2008-03-18 18:18:18 +00:00
|
|
|
#include "p_3dmidtex.h"
|
2008-06-04 17:53:15 +00:00
|
|
|
#include "r_interpolate.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
#include "r_bsp.h"
|
|
|
|
#include "r_plane.h"
|
|
|
|
#include "v_palette.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// MACROS ------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#define TEST_X 32343794
|
|
|
|
#define TEST_Y 111387517
|
|
|
|
#define TEST_Z 2164524
|
|
|
|
#define TEST_ANGLE 2468347904
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// TYPES -------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct InterpolationViewer
|
|
|
|
{
|
|
|
|
AActor *ViewActor;
|
|
|
|
int otic;
|
|
|
|
fixed_t oviewx, oviewy, oviewz;
|
|
|
|
fixed_t nviewx, nviewy, nviewz;
|
|
|
|
int oviewpitch, nviewpitch;
|
|
|
|
angle_t oviewangle, nviewangle;
|
|
|
|
};
|
|
|
|
|
|
|
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
|
|
|
|
|
|
|
void R_SpanInitData ();
|
|
|
|
void RP_RenderBSPNode (void *node);
|
|
|
|
bool RP_SetupFrame (bool backside);
|
|
|
|
|
|
|
|
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
|
|
|
|
|
|
|
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
static void R_Shutdown();
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
|
|
|
|
|
|
|
extern bool DrawFSHUD; // [RH] Defined in d_main.cpp
|
|
|
|
extern short *openings;
|
|
|
|
extern bool r_fakingunderwater;
|
|
|
|
extern "C" int fuzzviewheight;
|
|
|
|
EXTERN_CVAR (Bool, r_particles)
|
|
|
|
EXTERN_CVAR (Bool, cl_capfps)
|
|
|
|
|
|
|
|
// PRIVATE DATA DECLARATIONS -----------------------------------------------
|
|
|
|
|
|
|
|
static float CurrentVisibility = 8.f;
|
|
|
|
static fixed_t MaxVisForWall;
|
|
|
|
static fixed_t MaxVisForFloor;
|
|
|
|
static FRandom pr_torchflicker ("TorchFlicker");
|
|
|
|
static TArray<InterpolationViewer> PastViewers;
|
|
|
|
static int centerxwide;
|
|
|
|
static bool polyclipped;
|
|
|
|
static bool r_showviewer;
|
2006-06-18 15:49:00 +00:00
|
|
|
bool r_dontmaplines;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
|
|
|
|
|
|
|
CVAR (String, r_viewsize, "", CVAR_NOSET)
|
|
|
|
CVAR (Int, r_polymost, 0, 0)
|
2006-04-30 21:49:18 +00:00
|
|
|
CVAR (Bool, r_deathcamera, false, CVAR_ARCHIVE)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
fixed_t r_BaseVisibility;
|
|
|
|
fixed_t r_WallVisibility;
|
|
|
|
fixed_t r_FloorVisibility;
|
|
|
|
float r_TiltVisibility;
|
|
|
|
fixed_t r_SpriteVisibility;
|
|
|
|
fixed_t r_ParticleVisibility;
|
|
|
|
fixed_t r_SkyVisibility;
|
|
|
|
|
|
|
|
fixed_t r_TicFrac; // [RH] Fractional tic to render
|
|
|
|
DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms)
|
|
|
|
bool r_NoInterpolate;
|
|
|
|
|
|
|
|
angle_t LocalViewAngle;
|
|
|
|
int LocalViewPitch;
|
|
|
|
bool LocalKeyboardTurner;
|
|
|
|
|
|
|
|
float LastFOV;
|
|
|
|
int WidescreenRatio;
|
|
|
|
|
|
|
|
fixed_t GlobVis;
|
|
|
|
fixed_t FocalTangent;
|
|
|
|
fixed_t FocalLengthX;
|
|
|
|
fixed_t FocalLengthY;
|
|
|
|
float FocalLengthXfloat;
|
|
|
|
int viewangleoffset;
|
|
|
|
int validcount = 1; // increment every time a check is made
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
FDynamicColormap*basecolormap; // [RH] colormap currently drawing with
|
2006-02-24 04:48:15 +00:00
|
|
|
int fixedlightlev;
|
|
|
|
lighttable_t *fixedcolormap;
|
2009-09-22 04:21:27 +00:00
|
|
|
FSpecialColormap *realfixedcolormap;
|
2006-02-24 04:48:15 +00:00
|
|
|
float WallTMapScale;
|
|
|
|
float WallTMapScale2;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
int centerx;
|
|
|
|
int centery;
|
|
|
|
}
|
|
|
|
|
|
|
|
DCanvas *RenderTarget; // [RH] canvas to render to
|
|
|
|
bool bRenderingToCanvas; // [RH] True if rendering to a special canvas
|
|
|
|
fixed_t globaluclip, globaldclip;
|
|
|
|
fixed_t centerxfrac;
|
|
|
|
fixed_t centeryfrac;
|
|
|
|
fixed_t yaspectmul;
|
|
|
|
float iyaspectmulfloat;
|
|
|
|
fixed_t InvZtoScale;
|
|
|
|
|
|
|
|
// just for profiling purposes
|
|
|
|
int framecount;
|
|
|
|
int linecount;
|
|
|
|
int loopcount;
|
|
|
|
|
|
|
|
fixed_t viewx;
|
|
|
|
fixed_t viewy;
|
|
|
|
fixed_t viewz;
|
|
|
|
int viewpitch;
|
|
|
|
int otic;
|
|
|
|
|
|
|
|
angle_t viewangle;
|
|
|
|
sector_t *viewsector;
|
|
|
|
|
|
|
|
fixed_t viewcos, viewtancos;
|
|
|
|
fixed_t viewsin, viewtansin;
|
|
|
|
|
|
|
|
AActor *camera; // [RH] camera to draw from. doesn't have to be a player
|
|
|
|
|
|
|
|
int r_Yaspect = 200; // Why did I make this a variable? It's never set anywhere.
|
|
|
|
|
|
|
|
//
|
|
|
|
// precalculated math tables
|
|
|
|
//
|
|
|
|
int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
|
|
|
|
|
|
|
|
// The xtoviewangleangle[] table maps a screen pixel
|
|
|
|
// to the lowest viewangle that maps back to x ranges
|
|
|
|
// from clipangle to -clipangle.
|
|
|
|
angle_t xtoviewangle[MAXWIDTH+1];
|
|
|
|
|
|
|
|
int extralight; // bumped light from gun blasts
|
|
|
|
bool foggy; // [RH] ignore extralight and fullbright?
|
|
|
|
int r_actualextralight;
|
|
|
|
|
|
|
|
bool setsizeneeded;
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
int setblocks;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
fixed_t freelookviewheight;
|
|
|
|
|
|
|
|
unsigned int R_OldBlend = ~0;
|
|
|
|
|
|
|
|
void (*colfunc) (void);
|
|
|
|
void (*basecolfunc) (void);
|
|
|
|
void (*fuzzcolfunc) (void);
|
|
|
|
void (*transcolfunc) (void);
|
|
|
|
void (*spanfunc) (void);
|
|
|
|
|
|
|
|
void (*hcolfunc_pre) (void);
|
|
|
|
void (*hcolfunc_post1) (int hx, int sx, int yl, int yh);
|
|
|
|
void (*hcolfunc_post2) (int hx, int sx, int yl, int yh);
|
2008-02-27 03:11:35 +00:00
|
|
|
void (STACK_ARGS *hcolfunc_post4) (int sx, int yl, int yh);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles;
|
|
|
|
|
2006-05-19 05:14:37 +00:00
|
|
|
FCanvasTextureInfo *FCanvasTextureInfo::List;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
|
|
|
|
|
|
|
static int lastcenteryfrac;
|
|
|
|
static bool NoInterpolateView;
|
|
|
|
|
|
|
|
// CODE --------------------------------------------------------------------
|
|
|
|
|
2009-09-08 23:48:34 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// SlopeDiv
|
|
|
|
//
|
|
|
|
// Utility function, called by R_PointToAngle.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
angle_t SlopeDiv (unsigned int num, unsigned den)
|
|
|
|
{
|
|
|
|
unsigned int ans;
|
|
|
|
|
|
|
|
if (den < 512)
|
|
|
|
return (ANG45 - 1); //tantoangle[SLOPERANGE]
|
|
|
|
|
|
|
|
ans = (num << 3) / (den >> 8);
|
|
|
|
|
|
|
|
return ans <= SLOPERANGE ? tantoangle[ans] : (ANG45 - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PointToAngle
|
|
|
|
//
|
|
|
|
// To get a global angle from cartesian coordinates, the coordinates are
|
|
|
|
// flipped until they are in the first octant of the coordinate system,
|
|
|
|
// then the y (<=x) is scaled and divided by x to get a tangent (slope)
|
|
|
|
// value which is looked up in the tantoangle[] table.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x, fixed_t y)
|
|
|
|
{
|
|
|
|
x -= x1;
|
|
|
|
y -= y1;
|
|
|
|
|
|
|
|
if ((x | y) == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x >= 0)
|
|
|
|
{
|
|
|
|
if (y >= 0)
|
|
|
|
{
|
|
|
|
if (x > y)
|
|
|
|
{ // octant 0
|
2009-09-08 23:48:34 +00:00
|
|
|
return SlopeDiv(y, x);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // octant 1
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG90 - 1 - SlopeDiv(x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // y < 0
|
|
|
|
{
|
2009-09-08 23:48:34 +00:00
|
|
|
y = -y;
|
|
|
|
if (x > y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // octant 8
|
2009-09-08 23:48:34 +00:00
|
|
|
return 0 - SlopeDiv(y, x);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // octant 7
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG270 + SlopeDiv(x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // x < 0
|
|
|
|
{
|
2009-09-08 23:48:34 +00:00
|
|
|
x = -x;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (y >= 0)
|
|
|
|
{
|
2009-09-08 23:48:34 +00:00
|
|
|
if (x > y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // octant 3
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG180 - 1 - SlopeDiv(y, x);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // octant 2
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG90 + SlopeDiv(x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else // y < 0
|
|
|
|
{
|
2009-09-08 23:48:34 +00:00
|
|
|
y = -y;
|
|
|
|
if (x > y)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // octant 4
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG180 + SlopeDiv(y, x);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // octant 5
|
2009-09-08 23:48:34 +00:00
|
|
|
return ANG270 - 1 - SlopeDiv(x, y);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_InitPointToAngle
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_InitPointToAngle (void)
|
|
|
|
{
|
|
|
|
double f;
|
|
|
|
int i;
|
|
|
|
//
|
|
|
|
// slope (tangent) to angle lookup
|
|
|
|
//
|
|
|
|
for (i = 0; i <= SLOPERANGE; i++)
|
|
|
|
{
|
|
|
|
f = atan2 ((double)i, (double)SLOPERANGE) / (6.28318530718 /* 2*pi */);
|
|
|
|
tantoangle[i] = (angle_t)(0xffffffff*f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PointToDist2
|
|
|
|
//
|
|
|
|
// Returns the distance from (0,0) to some other point. In a
|
|
|
|
// floating point environment, we'd probably be better off using the
|
|
|
|
// Pythagorean Theorem to determine the result.
|
|
|
|
//
|
|
|
|
// killough 5/2/98: simplified
|
|
|
|
// [RH] Simplified further [sin (t + 90 deg) == cos (t)]
|
|
|
|
// Not used. Should it go away?
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
fixed_t R_PointToDist2 (fixed_t dx, fixed_t dy)
|
|
|
|
{
|
|
|
|
dx = abs (dx);
|
|
|
|
dy = abs (dy);
|
|
|
|
|
|
|
|
if ((dx | dy) == 0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dy > dx)
|
|
|
|
{
|
|
|
|
swap (dx, dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FixedDiv (dx, finecosine[tantoangle[FixedDiv (dy, dx) >> DBITS] >> ANGLETOFINESHIFT]);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_InitTables
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_InitTables (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
const double pimul = PI*2/FINEANGLES;
|
|
|
|
|
|
|
|
// viewangle tangent table
|
2008-10-07 18:21:03 +00:00
|
|
|
finetangent[0] = (fixed_t)(FRACUNIT*tan ((0.5-FINEANGLES/4)*pimul)+0.5);
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 1; i < FINEANGLES/2; i++)
|
|
|
|
{
|
2008-10-07 18:21:03 +00:00
|
|
|
finetangent[i] = (fixed_t)(FRACUNIT*tan ((i-FINEANGLES/4)*pimul)+0.5);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// finesine table
|
|
|
|
for (i = 0; i < FINEANGLES/4; i++)
|
|
|
|
{
|
2008-10-07 18:21:03 +00:00
|
|
|
finesine[i] = (fixed_t)(FRACUNIT * sin (i*pimul));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < FINEANGLES/4; i++)
|
|
|
|
{
|
|
|
|
finesine[i+FINEANGLES/4] = finesine[FINEANGLES/4-1-i];
|
|
|
|
}
|
|
|
|
for (i = 0; i < FINEANGLES/2; i++)
|
|
|
|
{
|
|
|
|
finesine[i+FINEANGLES/2] = -finesine[i];
|
|
|
|
}
|
|
|
|
finesine[FINEANGLES/4] = FRACUNIT;
|
|
|
|
finesine[FINEANGLES*3/4] = -FRACUNIT;
|
|
|
|
memcpy (&finesine[FINEANGLES], &finesine[0], sizeof(angle_t)*FINEANGLES/4);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_InitTextureMapping
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_InitTextureMapping ()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
fixed_t slope;
|
|
|
|
int fov = FieldOfView;
|
|
|
|
|
|
|
|
// For widescreen displays, increase the FOV so that the middle part of the
|
|
|
|
// screen that would be visible on a 4:3 display has the requested FOV.
|
|
|
|
if (centerxwide != centerx)
|
|
|
|
{ // centerxwide is what centerx would be if the display was not widescreen
|
|
|
|
fov = int(atan(double(centerx)*tan(double(fov)*M_PI/(FINEANGLES))/double(centerxwide))*(FINEANGLES)/M_PI);
|
|
|
|
if (fov > 170*FINEANGLES/360)
|
|
|
|
fov = 170*FINEANGLES/360;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
default: break;
|
|
|
|
case 1: fov = MIN (fov * 512/433, 170 * FINEANGLES / 360); break; // 16:9
|
|
|
|
case 2: fov = MIN (fov * 512/459, 170 * FINEANGLES / 360); break; // 16:10
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
const int hitan = finetangent[FINEANGLES/4+fov/2];
|
|
|
|
|
|
|
|
// Calc focallength so FieldOfView fineangles covers viewwidth.
|
|
|
|
FocalTangent = hitan;
|
|
|
|
FocalLengthX = FixedDiv (centerxfrac, hitan);
|
|
|
|
FocalLengthY = Scale (centerxfrac, yaspectmul, hitan);
|
|
|
|
FocalLengthXfloat = (float)FocalLengthX / 65536.f;
|
|
|
|
|
|
|
|
// Now generate xtoviewangle for sky texture mapping.
|
|
|
|
// [RH] Do not generate viewangletox, because texture mapping is no
|
|
|
|
// longer done with trig, so it's not needed.
|
|
|
|
const int t = MIN<int> ((FocalLengthX >> FRACBITS) + centerx, viewwidth);
|
|
|
|
const fixed_t slopestep = hitan / centerx;
|
|
|
|
const fixed_t dfocus = FocalLengthX >> DBITS;
|
|
|
|
|
|
|
|
for (i = centerx, slope = 0; i <= t; i++, slope += slopestep)
|
|
|
|
{
|
|
|
|
xtoviewangle[i] = (angle_t)-(signed)tantoangle[slope >> DBITS];
|
|
|
|
}
|
|
|
|
for (; i <= viewwidth; i++)
|
|
|
|
{
|
|
|
|
xtoviewangle[i] = ANG270+tantoangle[dfocus / (i - centerx)];
|
|
|
|
}
|
|
|
|
for (i = 0; i < centerx; i++)
|
|
|
|
{
|
|
|
|
xtoviewangle[i] = (angle_t)(-(signed)xtoviewangle[viewwidth-i-1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetFOV
|
|
|
|
//
|
|
|
|
// Changes the field of view in degrees
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetFOV (float fov)
|
|
|
|
{
|
|
|
|
if (fov < 5.f)
|
|
|
|
fov = 5.f;
|
|
|
|
else if (fov > 170.f)
|
|
|
|
fov = 170.f;
|
|
|
|
if (fov != LastFOV)
|
|
|
|
{
|
|
|
|
LastFOV = fov;
|
|
|
|
FieldOfView = (int)(fov * (float)FINEANGLES / 360.f);
|
|
|
|
setsizeneeded = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_GetFOV
|
|
|
|
//
|
|
|
|
// Returns the current field of view in degrees
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
float R_GetFOV ()
|
|
|
|
{
|
|
|
|
return LastFOV;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetVisibility
|
|
|
|
//
|
|
|
|
// Changes how rapidly things get dark with distance
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetVisibility (float vis)
|
|
|
|
{
|
|
|
|
// Allow negative visibilities, just for novelty's sake
|
|
|
|
//vis = clamp (vis, -204.7f, 204.7f);
|
|
|
|
|
|
|
|
CurrentVisibility = vis;
|
|
|
|
|
|
|
|
if (FocalTangent == 0)
|
|
|
|
{ // If r_visibility is called before the renderer is all set up, don't
|
|
|
|
// divide by zero. This will be called again later, and the proper
|
|
|
|
// values can be initialized then.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
r_BaseVisibility = toint (vis * 65536.f);
|
|
|
|
|
|
|
|
// Prevent overflow on walls
|
|
|
|
if (r_BaseVisibility < 0 && r_BaseVisibility < -MaxVisForWall)
|
|
|
|
r_WallVisibility = -MaxVisForWall;
|
|
|
|
else if (r_BaseVisibility > 0 && r_BaseVisibility > MaxVisForWall)
|
|
|
|
r_WallVisibility = MaxVisForWall;
|
|
|
|
else
|
|
|
|
r_WallVisibility = r_BaseVisibility;
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
r_WallVisibility = FixedMul (Scale (InvZtoScale, SCREENWIDTH*BaseRatioSizes[WidescreenRatio][1],
|
|
|
|
viewwidth*SCREENHEIGHT*3), FixedMul (r_WallVisibility, FocalTangent));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Prevent overflow on floors/ceilings. Note that the calculation of
|
|
|
|
// MaxVisForFloor means that planes less than two units from the player's
|
|
|
|
// view could still overflow, but there is no way to totally eliminate
|
|
|
|
// that while still using fixed point math.
|
|
|
|
if (r_BaseVisibility < 0 && r_BaseVisibility < -MaxVisForFloor)
|
|
|
|
r_FloorVisibility = -MaxVisForFloor;
|
|
|
|
else if (r_BaseVisibility > 0 && r_BaseVisibility > MaxVisForFloor)
|
|
|
|
r_FloorVisibility = MaxVisForFloor;
|
|
|
|
else
|
|
|
|
r_FloorVisibility = r_BaseVisibility;
|
|
|
|
|
|
|
|
r_FloorVisibility = Scale (160*FRACUNIT, r_FloorVisibility, FocalLengthY);
|
|
|
|
|
|
|
|
r_TiltVisibility = vis * (float)FocalTangent * (16.f * 320.f) / (float)viewwidth;
|
|
|
|
r_SpriteVisibility = r_WallVisibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_GetVisibility
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
float R_GetVisibility ()
|
|
|
|
{
|
|
|
|
return CurrentVisibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetViewSize
|
|
|
|
//
|
|
|
|
// Do not really change anything here, because it might be in the middle
|
|
|
|
// of a refresh. The change will take effect next refresh.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetViewSize (int blocks)
|
|
|
|
{
|
|
|
|
setsizeneeded = true;
|
|
|
|
setblocks = blocks;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetWindow
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|
|
|
{
|
|
|
|
int virtheight, virtwidth;
|
|
|
|
|
|
|
|
if (windowSize >= 11)
|
|
|
|
{
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwidth = fullWidth;
|
|
|
|
freelookviewheight = viewheight = fullHeight;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (windowSize == 10)
|
|
|
|
{
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwidth = fullWidth;
|
|
|
|
viewheight = stHeight;
|
2006-02-24 04:48:15 +00:00
|
|
|
freelookviewheight = fullHeight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwidth = ((setblocks*fullWidth)/10) & (~15);
|
|
|
|
viewheight = ((setblocks*stHeight)/10)&~7;
|
2006-02-24 04:48:15 +00:00
|
|
|
freelookviewheight = ((setblocks*fullHeight)/10)&~7;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the screen is approximately 16:9 or 16:10, consider it widescreen.
|
|
|
|
WidescreenRatio = CheckRatio (fullWidth, fullHeight);
|
|
|
|
|
|
|
|
DrawFSHUD = (windowSize == 11);
|
|
|
|
|
|
|
|
fuzzviewheight = viewheight - 2; // Maximum row the fuzzer can draw to
|
|
|
|
halfviewwidth = (viewwidth >> 1) - 1;
|
|
|
|
|
|
|
|
if (!bRenderingToCanvas)
|
|
|
|
{ // Set r_viewsize cvar to reflect the current view size
|
|
|
|
UCVarValue value;
|
|
|
|
char temp[16];
|
|
|
|
|
About a week's worth of changes here. As a heads-up, I wouldn't be
surprised if this doesn't build in Linux right now. The CMakeLists.txt
were checked with MinGW and NMake, but how they fair under Linux is an
unknown to me at this time.
- Converted most sprintf (and all wsprintf) calls to either mysnprintf or
FStrings, depending on the situation.
- Changed the strings in the wbstartstruct to be FStrings.
- Changed myvsnprintf() to output nothing if count is greater than INT_MAX.
This is so that I can use a series of mysnprintf() calls and advance the
pointer for each one. Once the pointer goes beyond the end of the buffer,
the count will go negative, but since it's an unsigned type it will be
seen as excessively huge instead. This should not be a problem, as there's
no reason for ZDoom to be using text buffers larger than 2 GB anywhere.
- Ripped out the disabled bit from FGameConfigFile::MigrateOldConfig().
- Changed CalcMapName() to return an FString instead of a pointer to a static
buffer.
- Changed startmap in d_main.cpp into an FString.
- Changed CheckWarpTransMap() to take an FString& as the first argument.
- Changed d_mapname in g_level.cpp into an FString.
- Changed DoSubstitution() in ct_chat.cpp to place the substitutions in an
FString.
- Fixed: The MAPINFO parser wrote into the string buffer to construct a map
name when given a Hexen map number. This was fine with the old scanner
code, but only a happy coincidence prevents it from crashing with the new
code
- Added the 'B' conversion specifier to StringFormat::VWorker() for printing
binary numbers.
- Added CMake support for building with MinGW, MSYS, and NMake. Linux support
is probably broken until I get around to booting into Linux again. Niceties
provided over the existing Makefiles they're replacing:
* All command-line builds can use the same build system, rather than having
a separate one for MinGW and another for Linux.
* Microsoft's NMake tool is supported as a target.
* Progress meters.
* Parallel makes work from a fresh checkout without needing to be primed
first with a single-threaded make.
* Porting to other architectures should be simplified, whenever that day
comes.
- Replaced the makewad tool with zipdir. This handles the dependency tracking
itself instead of generating an external makefile to do it, since I couldn't
figure out how to generate a makefile with an external tool and include it
with a CMake-generated makefile. Where makewad used a master list of files
to generate the package file, zipdir just zips the entire contents of one or
more directories.
- Added the gdtoa package from netlib's fp library so that ZDoom's printf-style
formatting can be entirely independant of the CRT.
SVN r1082 (trunk)
2008-07-23 04:57:26 +00:00
|
|
|
mysnprintf (temp, countof(temp), "%d x %d", viewwidth, viewheight);
|
2006-02-24 04:48:15 +00:00
|
|
|
value.String = temp;
|
|
|
|
r_viewsize.ForceSet (value, CVAR_String);
|
|
|
|
}
|
|
|
|
|
|
|
|
lastcenteryfrac = 1<<30;
|
|
|
|
centery = viewheight/2;
|
|
|
|
centerx = viewwidth/2;
|
|
|
|
centerxfrac = centerx<<FRACBITS;
|
|
|
|
centeryfrac = centery<<FRACBITS;
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
virtwidth = fullWidth;
|
|
|
|
virtheight = fullHeight;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (WidescreenRatio & 4)
|
|
|
|
{
|
|
|
|
virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48;
|
|
|
|
centerxwide = centerx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
virtwidth = virtwidth * BaseRatioSizes[WidescreenRatio][3] / 48;
|
|
|
|
centerxwide = centerx * BaseRatioSizes[WidescreenRatio][3] / 48;
|
|
|
|
}
|
|
|
|
|
|
|
|
yaspectmul = Scale ((320<<FRACBITS), virtheight, r_Yaspect * virtwidth);
|
|
|
|
iyaspectmulfloat = (float)virtwidth * r_Yaspect / 320.f / (float)virtheight;
|
|
|
|
InvZtoScale = yaspectmul * centerx;
|
|
|
|
|
|
|
|
WallTMapScale = (float)centerx * 32.f;
|
|
|
|
WallTMapScale2 = iyaspectmulfloat * 2.f / (float)centerx;
|
|
|
|
|
|
|
|
// psprite scales
|
|
|
|
pspritexscale = (centerxwide << FRACBITS) / 160;
|
|
|
|
pspriteyscale = FixedMul (pspritexscale, yaspectmul);
|
|
|
|
pspritexiscale = FixedDiv (FRACUNIT, pspritexscale);
|
|
|
|
|
|
|
|
// thing clipping
|
|
|
|
clearbufshort (screenheightarray, viewwidth, (short)viewheight);
|
|
|
|
|
|
|
|
// [RH] Sky height fix for screens not 200 (or 240) pixels tall
|
|
|
|
R_InitSkyMap ();
|
|
|
|
|
|
|
|
R_InitTextureMapping ();
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
MaxVisForWall = FixedMul (Scale (InvZtoScale, SCREENWIDTH*r_Yaspect,
|
|
|
|
viewwidth*SCREENHEIGHT), FocalTangent);
|
2006-02-24 04:48:15 +00:00
|
|
|
MaxVisForWall = FixedDiv (0x7fff0000, MaxVisForWall);
|
|
|
|
MaxVisForFloor = Scale (FixedDiv (0x7fff0000, viewheight<<(FRACBITS-2)), FocalLengthY, 160*FRACUNIT);
|
|
|
|
|
|
|
|
// Reset r_*Visibility vars
|
|
|
|
R_SetVisibility (R_GetVisibility ());
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_ExecuteSetViewSize
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_ExecuteSetViewSize ()
|
|
|
|
{
|
|
|
|
setsizeneeded = false;
|
|
|
|
BorderNeedRefresh = screen->GetPageCount ();
|
|
|
|
|
|
|
|
R_SetWindow (setblocks, SCREENWIDTH, SCREENHEIGHT, ST_Y);
|
|
|
|
|
|
|
|
// Handle resize, e.g. smaller view windows with border and/or status bar.
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwindowx = (screen->GetWidth() - viewwidth) >> 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Same with base row offset.
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwindowy = (viewwidth == screen->GetWidth()) ? 0 : (ST_Y - viewheight) >> 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// CVAR screenblocks
|
|
|
|
//
|
|
|
|
// Selects the size of the visible window
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2009-06-05 21:44:34 +00:00
|
|
|
CUSTOM_CVAR (Int, screenblocks, 10, CVAR_ARCHIVE)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (self > 12)
|
|
|
|
self = 12;
|
|
|
|
else if (self < 3)
|
|
|
|
self = 3;
|
|
|
|
else
|
|
|
|
R_SetViewSize (self);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// CVAR r_columnmethod
|
|
|
|
//
|
|
|
|
// Selects which version of the seg renderers to use.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
CUSTOM_CVAR (Int, r_columnmethod, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
|
|
|
{
|
|
|
|
if (self != 0 && self != 1)
|
|
|
|
{
|
|
|
|
self = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Trigger the change
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
setsizeneeded = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_Init
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
void R_Init ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-05-12 03:14:40 +00:00
|
|
|
atterm (R_Shutdown);
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
R_InitData ();
|
|
|
|
R_InitPointToAngle ();
|
|
|
|
R_InitTables ();
|
|
|
|
// viewwidth / viewheight are set by the defaults
|
|
|
|
|
|
|
|
R_SetViewSize (screenblocks);
|
|
|
|
R_InitPlanes ();
|
|
|
|
R_InitTranslationTables ();
|
|
|
|
R_InitParticles (); // [RH] Setup particle engine
|
Note: I have not tried compiling these recent changes under Linux. I wouldn't
be surprised if it doesn't work.
- Reorganized the network startup loops so now they are event driven. There is
a single function that gets called to drive it, and it uses callbacks to
perform the different stages of the synchronization. This lets me have a nice,
responsive abort button instead of the previous unannounced hit-escape-to-
abort behavior, and I think the rearranged code is slightly easier to
understand too.
- Increased the number of bytes for version info during D_ArbitrateNetStart(),
in preparation for the day when NETGAMEVERSION requires more than one byte.
- I noticed an issue with Vista RC1 and the new fatal error setup. Even after
releasing a DirectDraw or Direct3D interface, the DWM can still use the
last image drawn using them when it composites the window. It doesn't always
do it but it does often enough that it is a real problem. At this point, I
don't know if it's a problem with the release version of Vista or not.
After messing around, I discovered the problem was caused by ~Win32Video()
hiding the window and then having it immediately shown soon after. The DWM
kept an image of the window to do the transition effect with, and then when
it didn't get a chance to do the transition, it didn't properly forget about
its saved image and kept plastering it on top of everything else
underneath.
- Added a network synchronization panel to the window during netgame startup.
- Fixed: PClass::CreateDerivedClass() must initialize StateList to NULL.
Otherwise, classic DECORATE definitions generate a big, fat crash.
- Resurrected the R_Init progress bar, now as a standard Windows control.
- Removed the sound failure dialog. The FMOD setup already defaulted to no
sound if initialization failed, so this only applies when snd_output is set
to "alternate" which now also falls back to no sound. In addition, it wasn't
working right, and I didn't feel like fixing it for the probably 0% of users
it affected.
- Fixed: The edit control used for logging output added text in reverse order
on Win9x.
- Went back to the roots and made graphics initialization one of the last
things to happen during setup. Now the startup text is visible again. More
importantly, the main window is no longer created invisible, which seems
to cause trouble with it not always appearing in the taskbar. The fatal
error dialog is now also embedded in the main window instead of being a
separate modal dialog, so you can play with the log window to see any
problems that might be reported there.
Rather than completely restoring the original startup order, I tried to
keep things as close to the way they were with early graphics startup. In
particular, V_Init() now creates a dummy screen so that things that need
screen dimensions can get them. It gets replaced by the real screen later
in I_InitGraphics(). Will need to check this under Linux to make sure it
didn't cause any problems there.
- Removed the following stubs that just called functions in Video:
- I_StartModeIterator()
- I_NextMode()
- I_DisplayType()
I_FullscreenChanged() was also removed, and a new fullscreen parameter
was added to IVideo::StartModeIterator(), since that's all it controlled.
- Renamed I_InitHardware() back to I_InitGraphics(), since that's all it's
initialized post-1.22.
SVN r416 (trunk)
2006-12-19 04:09:10 +00:00
|
|
|
R_InitColumnDrawers ();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
colfunc = basecolfunc = R_DrawColumn;
|
|
|
|
fuzzcolfunc = R_DrawFuzzColumn;
|
|
|
|
transcolfunc = R_DrawTranslatedColumn;
|
|
|
|
spanfunc = R_DrawSpan;
|
|
|
|
|
|
|
|
// [RH] Horizontal column drawers
|
|
|
|
hcolfunc_pre = R_DrawColumnHoriz;
|
|
|
|
hcolfunc_post1 = rt_map1col;
|
|
|
|
hcolfunc_post4 = rt_map4cols;
|
|
|
|
|
|
|
|
framecount = 0;
|
|
|
|
}
|
|
|
|
|
2006-05-12 03:14:40 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_Shutdown
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static void R_Shutdown ()
|
|
|
|
{
|
|
|
|
R_DeinitParticles();
|
- Discovered that Shader Model 1.4 clamps my constants, so I can't use
palettes smaller than 256 entries with the shader I wrote for it. Is there
a list of gotchas like this listed some where? I'd really like to see it.
Well, when compiled with SM2.0, the PalTex shader seems to be every-so-
slightly faster on my GF7950GT than the SM1.4 version, so I guess it's a
minor win for cards that support it.
- Fixed: ST_Endoom() failed to free the bitmap it used.
- Added the DTA_ColorOverlay attribute to blend a color with the texture
being drawn. For software, this (currently) only works with black. For
hardware, it works with any color. The motiviation for this was so I could
rewrite the status bar calls that passed DIM_MAP to DTA_Translation to
draw darker icons into something that didn't require making a whole new
remap table.
- After having an "OMG! How could I have been so stupid?" moment, I have
removed the off-by-one check from D3DFB. I had thought the off-by-one error
was caused by rounding errors by the shader hardware. Not so. Rather, I
wasn't sampling what I thought I was sampling. A texture that uses palette
index 255 passes the value 1.0 to the shader. The shader needs to adjust the
range of its palette indexes, or it will end up trying to read color 256
from the palette texture when it should be reading color 255. Doh!
- The TranslationToTable() function has been added to map from translation
numbers used by actors to the tables those numbers represent. This function
performs validation for the input and returns NULL if the input value
is invalid.
- Major changes to the way translation tables work: No longer are they each a
256-byte array. Instead, the FRemapTable structure is used to represent each
one. It includes a remap array for the software renderer, a palette array
for a hardware renderer, and a native texture pointer for D3DFB. The
translationtables array itself is now an array of TArrays that point to the
real tables. The DTA_Translation attribute must also be passed a pointer
to a FRemapTable, not a byte array as previously.
- Modified DFrameBuffer::DrawRateStuff() so that it can do its thing properly
for D3DFB's 2D mode. Before, any fullscreen graphics (like help images)
covered it up.
SVN r640 (trunk)
2007-12-26 04:42:15 +00:00
|
|
|
R_DeinitTranslationTables();
|
2006-05-12 03:14:40 +00:00
|
|
|
R_DeinitPlanes();
|
|
|
|
R_DeinitData();
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_PointInSubsector
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
subsector_t *R_PointInSubsector (fixed_t x, fixed_t y)
|
|
|
|
{
|
|
|
|
node_t *node;
|
|
|
|
int side;
|
|
|
|
|
|
|
|
// single subsector is a special case
|
|
|
|
if (numnodes == 0)
|
|
|
|
return subsectors;
|
|
|
|
|
|
|
|
node = nodes + numnodes - 1;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
side = R_PointOnSide (x, y, node);
|
|
|
|
node = (node_t *)node->children[side];
|
|
|
|
}
|
|
|
|
while (!((size_t)node & 1));
|
|
|
|
|
|
|
|
return (subsector_t *)((BYTE *)node - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_InterpolateView
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
//CVAR (Int, tf, 0, 0)
|
|
|
|
EXTERN_CVAR (Bool, cl_noprediction)
|
|
|
|
|
|
|
|
void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *iview)
|
|
|
|
{
|
|
|
|
// frac = tf;
|
|
|
|
if (NoInterpolateView)
|
|
|
|
{
|
|
|
|
NoInterpolateView = false;
|
|
|
|
iview->oviewx = iview->nviewx;
|
|
|
|
iview->oviewy = iview->nviewy;
|
|
|
|
iview->oviewz = iview->nviewz;
|
|
|
|
iview->oviewpitch = iview->nviewpitch;
|
|
|
|
iview->oviewangle = iview->nviewangle;
|
|
|
|
}
|
|
|
|
viewx = iview->oviewx + FixedMul (frac, iview->nviewx - iview->oviewx);
|
|
|
|
viewy = iview->oviewy + FixedMul (frac, iview->nviewy - iview->oviewy);
|
|
|
|
viewz = iview->oviewz + FixedMul (frac, iview->nviewz - iview->oviewz);
|
|
|
|
if (player != NULL &&
|
|
|
|
player - players == consoleplayer &&
|
|
|
|
camera == player->mo &&
|
|
|
|
!demoplayback &&
|
|
|
|
iview->nviewx == camera->x &&
|
|
|
|
iview->nviewy == camera->y &&
|
|
|
|
!(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) &&
|
|
|
|
player->playerstate == PST_LIVE &&
|
|
|
|
player->mo->reactiontime == 0 &&
|
|
|
|
!NoInterpolateView &&
|
|
|
|
!paused &&
|
|
|
|
(!netgame || !cl_noprediction) &&
|
|
|
|
!LocalKeyboardTurner)
|
|
|
|
{
|
|
|
|
viewangle = iview->nviewangle + (LocalViewAngle & 0xFFFF0000);
|
2007-01-22 23:50:09 +00:00
|
|
|
|
|
|
|
fixed_t delta = -(signed)(LocalViewPitch & 0xFFFF0000);
|
|
|
|
|
|
|
|
viewpitch = iview->nviewpitch;
|
|
|
|
if (delta > 0)
|
|
|
|
{
|
|
|
|
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
|
|
|
|
if (viewpitch + delta <= viewpitch)
|
|
|
|
{
|
2009-10-25 15:26:19 +00:00
|
|
|
viewpitch = screen->GetMaxViewPitch(true);
|
2007-01-22 23:50:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-25 15:26:19 +00:00
|
|
|
viewpitch = MIN(viewpitch + delta, screen->GetMaxViewPitch(true));
|
2007-01-22 23:50:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (delta < 0)
|
|
|
|
{
|
|
|
|
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
|
|
|
|
if (viewpitch + delta >= viewpitch)
|
|
|
|
{
|
2009-10-25 15:26:19 +00:00
|
|
|
viewpitch = screen->GetMaxViewPitch(false);
|
2007-01-22 23:50:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-25 15:26:19 +00:00
|
|
|
viewpitch = MAX(viewpitch + delta, screen->GetMaxViewPitch(false));
|
2007-01-22 23:50:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
viewpitch = iview->oviewpitch + FixedMul (frac, iview->nviewpitch - iview->oviewpitch);
|
|
|
|
viewangle = iview->oviewangle + FixedMul (frac, iview->nviewangle - iview->oviewangle);
|
|
|
|
}
|
2006-04-11 08:36:23 +00:00
|
|
|
|
|
|
|
// Due to interpolation this is not necessarily the same as the sector the camera is in.
|
|
|
|
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_ResetViewInterpolation
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_ResetViewInterpolation ()
|
|
|
|
{
|
|
|
|
NoInterpolateView = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetViewAngle
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetViewAngle ()
|
|
|
|
{
|
|
|
|
angle_t ang = viewangle >> ANGLETOFINESHIFT;
|
|
|
|
|
|
|
|
viewsin = finesine[ang];
|
|
|
|
viewcos = finecosine[ang];
|
|
|
|
|
|
|
|
viewtansin = FixedMul (FocalTangent, viewsin);
|
|
|
|
viewtancos = FixedMul (FocalTangent, viewcos);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FindPastViewer
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
static InterpolationViewer *FindPastViewer (AActor *actor)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < PastViewers.Size(); ++i)
|
|
|
|
{
|
|
|
|
if (PastViewers[i].ViewActor == actor)
|
|
|
|
{
|
|
|
|
return &PastViewers[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Not found, so make a new one
|
2006-12-29 03:38:37 +00:00
|
|
|
InterpolationViewer iview = { 0 };
|
2006-02-24 04:48:15 +00:00
|
|
|
iview.ViewActor = actor;
|
|
|
|
iview.otic = -1;
|
|
|
|
return &PastViewers[PastViewers.Push (iview)];
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_FreePastViewers
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_FreePastViewers ()
|
|
|
|
{
|
|
|
|
PastViewers.Clear ();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
2007-02-04 01:12:50 +00:00
|
|
|
//
|
|
|
|
// R_ClearPastViewer
|
|
|
|
//
|
|
|
|
// If the actor changed in a non-interpolatable way, remove it.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_ClearPastViewer (AActor *actor)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < PastViewers.Size(); ++i)
|
|
|
|
{
|
|
|
|
if (PastViewers[i].ViewActor == actor)
|
|
|
|
{
|
|
|
|
// Found it, so remove it.
|
|
|
|
if (i == PastViewers.Size())
|
|
|
|
{
|
|
|
|
PastViewers.Delete (i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PastViewers.Pop (PastViewers[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
// R_CopyStackedViewParameters
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_CopyStackedViewParameters()
|
|
|
|
{
|
|
|
|
stacked_viewx = viewx;
|
|
|
|
stacked_viewy = viewy;
|
|
|
|
stacked_viewz = viewz;
|
|
|
|
stacked_angle = viewangle;
|
|
|
|
stacked_extralight = extralight;
|
|
|
|
stacked_visibility = R_GetVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetupFrame
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_SetupFrame (AActor *actor)
|
|
|
|
{
|
2006-11-26 01:30:34 +00:00
|
|
|
if (actor == NULL)
|
|
|
|
{
|
|
|
|
I_Error ("Tried to render from a NULL actor.");
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
player_t *player = actor->player;
|
|
|
|
unsigned int newblend;
|
|
|
|
InterpolationViewer *iview;
|
|
|
|
|
|
|
|
if (player != NULL && player->mo == actor)
|
|
|
|
{ // [RH] Use camera instead of viewplayer
|
|
|
|
camera = player->camera;
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
camera = player->camera = player->mo;
|
|
|
|
}
|
|
|
|
if (camera == actor)
|
|
|
|
{
|
|
|
|
P_PredictPlayer (player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
camera = actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (camera == NULL)
|
|
|
|
{
|
|
|
|
I_Error ("You lost your body. Bad dehacked work is likely to blame.");
|
|
|
|
}
|
|
|
|
|
|
|
|
iview = FindPastViewer (camera);
|
|
|
|
|
|
|
|
int nowtic = I_GetTime (false);
|
|
|
|
if (iview->otic != -1 && nowtic > iview->otic)
|
|
|
|
{
|
|
|
|
iview->otic = nowtic;
|
|
|
|
iview->oviewx = iview->nviewx;
|
|
|
|
iview->oviewy = iview->nviewy;
|
|
|
|
iview->oviewz = iview->nviewz;
|
|
|
|
iview->oviewpitch = iview->nviewpitch;
|
|
|
|
iview->oviewangle = iview->nviewangle;
|
|
|
|
}
|
|
|
|
|
2007-05-10 22:22:38 +00:00
|
|
|
if (player != NULL && gamestate != GS_TITLELEVEL &&
|
2006-04-30 21:49:18 +00:00
|
|
|
((player->cheats & CF_CHASECAM) || (r_deathcamera && camera->health <= 0)) &&
|
- Updated lempar.c to v1.31.
- Added .txt files to the list of types (wad, zip, and pk3) that can be
loaded without listing them after -file.
- Fonts that are created by the ACS setfont command to wrap a texture now
support animated textures.
- FON2 fonts can now use their full palette for CR_UNTRANSLATED when drawn
with the hardware 2D path instead of being restricted to the game palette.
- Fixed: Toggling vid_vsync would reset the displayed fullscreen gamma to 1
on a Radeon 9000.
- Added back the off-by-one palette handling, but in a much more limited
scope than before. The skipped entry is assumed to always be at 248, and
it is assumed that all Shader Model 1.4 cards suffer from this. That's
because all SM1.4 cards are based on variants of the ATI R200 core, and the
RV250 in a Radeon 9000 craps up like this. I see no reason to assume that
other flavors of the R200 are any different. (Interesting note: With the
Radeon 9000, D3DTADDRESS_CLAMP is an invalid address mode when using the
debug Direct3D 9 runtime, but it works perfectly fine with the retail
Direct3D 9 runtime.) (Insight: The R200 probably uses bytes for all its
math inside pixel shaders. That would explain perfectly why I can't use
constants greater than 1 with PS1.4 and why it can't do an exact mapping to
every entry in the color palette.
- Fixed: The software shaded drawer did not work for 2D, because its selected
"color"map was replaced with the identitymap before being used.
- Fixed: I cannot use Printf to output messages before the framebuffer was
completely setup, meaning that Shader Model 1.4 cards could not change
resolution.
- I have decided to let remap palettes specify variable alpha values for
their colors. D3DFB no longer forces them to 255.
- Updated re2c to version 0.12.3.
- Fixed: A_Wander used threshold as a timer, when it should have used
reactiontime.
- Fixed: A_CustomRailgun would not fire at all for actors without a target
when the aim parameter was disabled.
- Made the warp command work in multiplayer, again courtesy of Karate Chris.
- Fixed: Trying to spawn a bot while not in a game made for a crashing time.
(Patch courtesy of Karate Chris.)
- Removed some floating point math from hu_scores.cpp that somebody's GCC
gave warnings for (not mine, though).
- Fixed: The SBarInfo drawbar command crashed if the sprite image was
unavailable.
- Fixed: FString::operator=(const char *) did not release its old buffer when
being assigned to the null string.
- The scanner no longer has an upper limit on the length of strings it
accepts, though short strings will be faster than long ones.
- Moved all the text scanning functions into a class. Mainly, this means that
multiple script scanner states can be stored without being forced to do so
recursively. I think I might be taking advantage of that in the near
future. Possibly. Maybe.
- Removed some potential buffer overflows from the decal parser.
- Applied Blzut3's SBARINFO update #9:
* Fixed: When using even length values in drawnumber it would cap to a 98
value instead of a 99 as intended.
* The SBarInfo parser can now accept negatives for coordinates. This
doesn't allow much right now, but later I plan to add better fullscreen
hud support in which the negatives will be more useful. This also cleans
up the source a bit since all calls for (x, y) coordinates are with the
function getCoordinates().
- Added support for stencilling actors.
- Added support for non-black colors specified with DTA_ColorOverlay to the
software renderer.
- Fixed: The inverse, gold, red, and green fixed colormaps each allocated
space for 32 different colormaps, even though each only used the first one.
- Added two new blending flags to make reverse subtract blending more useful:
STYLEF_InvertSource and STYLEF_InvertOverlay. These invert the color that
gets blended with the background, since that seems like a good idea for
reverse subtraction. They also work with the other two blending operations.
- Added subtract and reverse subtract blending operations to the renderer.
Since the ERenderStyle enumeration was getting rather unwieldy, I converted
it into a new FRenderStyle structure that lets each parameter of the
blending equation be set separately. This simplified the set up for the
blend quite a bit, and it means a number of new combinations are available
by setting the parameters properly.
SVN r710 (trunk)
2008-01-25 23:57:44 +00:00
|
|
|
(camera->RenderStyle.BlendOp != STYLEOP_None) &&
|
2006-02-24 04:48:15 +00:00
|
|
|
!(camera->renderflags & RF_INVISIBLE) &&
|
|
|
|
camera->sprite != 0) // Sprite 0 is always TNT1
|
|
|
|
{
|
|
|
|
// [RH] Use chasecam view
|
2008-04-09 18:35:21 +00:00
|
|
|
P_AimCamera (camera, iview->nviewx, iview->nviewy, iview->nviewz, viewsector);
|
2006-02-24 04:48:15 +00:00
|
|
|
r_showviewer = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
iview->nviewx = camera->x;
|
|
|
|
iview->nviewy = camera->y;
|
2006-10-22 10:32:41 +00:00
|
|
|
iview->nviewz = camera->player ? camera->player->viewz : camera->z + camera->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight);
|
2006-02-24 04:48:15 +00:00
|
|
|
viewsector = camera->Sector;
|
|
|
|
r_showviewer = false;
|
|
|
|
}
|
|
|
|
iview->nviewpitch = camera->pitch;
|
|
|
|
if (camera->player != 0)
|
|
|
|
{
|
|
|
|
player = camera->player;
|
|
|
|
}
|
|
|
|
|
|
|
|
iview->nviewangle = camera->angle + viewangleoffset;
|
|
|
|
if (iview->otic == -1 || r_NoInterpolate)
|
|
|
|
{
|
|
|
|
R_ResetViewInterpolation ();
|
|
|
|
iview->otic = nowtic;
|
|
|
|
}
|
|
|
|
|
2006-05-18 01:42:50 +00:00
|
|
|
R_UpdateAnimations (I_MSTime());
|
2006-02-24 04:48:15 +00:00
|
|
|
r_TicFrac = I_GetTimeFrac (&r_FrameTime);
|
|
|
|
if (cl_capfps || r_NoInterpolate)
|
|
|
|
{
|
|
|
|
r_TicFrac = FRACUNIT;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_InterpolateView (player, r_TicFrac, iview);
|
|
|
|
|
|
|
|
#ifdef TEST_X
|
|
|
|
viewx = TEST_X;
|
|
|
|
viewy = TEST_Y;
|
|
|
|
viewz = TEST_Z;
|
|
|
|
viewangle = TEST_ANGLE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
R_CopyStackedViewParameters();
|
|
|
|
R_SetViewAngle ();
|
|
|
|
|
2008-06-04 17:53:15 +00:00
|
|
|
interpolator.DoInterpolations (r_TicFrac);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Keep the view within the sector's floor and ceiling
|
|
|
|
fixed_t theZ = viewsector->ceilingplane.ZatPoint (viewx, viewy) - 4*FRACUNIT;
|
|
|
|
if (viewz > theZ)
|
|
|
|
{
|
|
|
|
viewz = theZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
theZ = viewsector->floorplane.ZatPoint (viewx, viewy) + 4*FRACUNIT;
|
|
|
|
if (viewz < theZ)
|
|
|
|
{
|
|
|
|
viewz = theZ;
|
|
|
|
}
|
|
|
|
|
2006-07-01 00:21:36 +00:00
|
|
|
if (!paused)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-07-01 00:21:36 +00:00
|
|
|
int intensity = DEarthquake::StaticGetQuakeIntensity (camera);
|
|
|
|
if (intensity != 0)
|
|
|
|
{
|
|
|
|
viewx += ((pr_torchflicker() % (intensity<<2))
|
|
|
|
-(intensity<<1))<<FRACBITS;
|
|
|
|
viewy += ((pr_torchflicker() % (intensity<<2))
|
|
|
|
-(intensity<<1))<<FRACBITS;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extralight = camera->player ? camera->player->extralight : 0;
|
|
|
|
|
|
|
|
// killough 3/20/98, 4/4/98: select colormap based on player status
|
|
|
|
// [RH] Can also select a blend
|
|
|
|
|
2009-05-23 10:21:33 +00:00
|
|
|
const sector_t *s = viewsector->GetHeightSec();
|
|
|
|
if (s != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
newblend = viewz < s->floorplane.ZatPoint (viewx, viewy)
|
|
|
|
? s->bottommap
|
|
|
|
: viewz > s->ceilingplane.ZatPoint (viewx, viewy)
|
|
|
|
? s->topmap
|
|
|
|
: s->midmap;
|
|
|
|
if (APART(newblend) == 0 && newblend >= numfakecmaps)
|
|
|
|
newblend = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
newblend = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Don't override testblend unless entering a sector with a
|
|
|
|
// blend different from the previous sector's. Same goes with
|
|
|
|
// NormalLight's maps pointer.
|
|
|
|
if (R_OldBlend != newblend)
|
|
|
|
{
|
|
|
|
R_OldBlend = newblend;
|
|
|
|
if (APART(newblend))
|
|
|
|
{
|
|
|
|
BaseBlendR = RPART(newblend);
|
|
|
|
BaseBlendG = GPART(newblend);
|
|
|
|
BaseBlendB = BPART(newblend);
|
|
|
|
BaseBlendA = APART(newblend) / 255.f;
|
|
|
|
NormalLight.Maps = realcolormaps;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NormalLight.Maps = realcolormaps + NUMCOLORMAPS*256*newblend;
|
|
|
|
BaseBlendR = BaseBlendG = BaseBlendB = 0;
|
|
|
|
BaseBlendA = 0.f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-22 04:21:27 +00:00
|
|
|
realfixedcolormap = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
fixedcolormap = NULL;
|
2009-09-20 03:50:05 +00:00
|
|
|
fixedlightlev = -1;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-09-20 03:50:05 +00:00
|
|
|
if (player != NULL && camera == player->mo)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
if (player->fixedcolormap >= 0 && player->fixedcolormap < (int)SpecialColormaps.Size())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-22 04:21:27 +00:00
|
|
|
realfixedcolormap = &SpecialColormaps[player->fixedcolormap];
|
|
|
|
if (RenderTarget == screen && (DFrameBuffer *)screen->Accel2D)
|
|
|
|
{
|
|
|
|
// Render everything fullbright. The copy to video memory will
|
|
|
|
// apply the special colormap, so it won't be restricted to the
|
|
|
|
// palette.
|
|
|
|
fixedcolormap = realcolormaps;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fixedcolormap = SpecialColormaps[player->fixedcolormap].Colormap;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2009-09-20 03:50:05 +00:00
|
|
|
else if (player->fixedlightlevel >= 0 && player->fixedlightlevel < NUMCOLORMAPS)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-20 03:50:05 +00:00
|
|
|
fixedlightlev = player->fixedlightlevel * 256;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// [RH] Inverse light for shooting the Sigil
|
2009-09-20 03:50:05 +00:00
|
|
|
if (fixedcolormap == NULL && extralight == INT_MIN)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-21 13:15:36 +00:00
|
|
|
fixedcolormap = SpecialColormaps[INVERSECOLORMAP].Colormap;
|
2006-02-24 04:48:15 +00:00
|
|
|
extralight = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] freelook stuff
|
|
|
|
{
|
|
|
|
fixed_t dy;
|
|
|
|
|
|
|
|
if (camera != NULL)
|
|
|
|
{
|
|
|
|
dy = FixedMul (FocalLengthY, finetangent[(ANGLE_90-viewpitch)>>ANGLETOFINESHIFT]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dy = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
centeryfrac = (viewheight << (FRACBITS-1)) + dy;
|
|
|
|
centery = centeryfrac >> FRACBITS;
|
|
|
|
globaluclip = FixedDiv (-centeryfrac, InvZtoScale);
|
|
|
|
globaldclip = FixedDiv ((viewheight<<FRACBITS)-centeryfrac, InvZtoScale);
|
|
|
|
|
|
|
|
//centeryfrac &= 0xffff0000;
|
|
|
|
int e, i;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
e = viewheight;
|
|
|
|
fixed_t focus = FocalLengthY;
|
|
|
|
fixed_t den;
|
|
|
|
if (i < centery)
|
|
|
|
{
|
|
|
|
den = centeryfrac - (i << FRACBITS) - FRACUNIT/2;
|
|
|
|
if (e <= centery)
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
yslope[i] = FixedDiv (focus, den);
|
|
|
|
den -= FRACUNIT;
|
|
|
|
} while (++i < e);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
yslope[i] = FixedDiv (focus, den);
|
|
|
|
den -= FRACUNIT;
|
|
|
|
} while (++i < centery);
|
|
|
|
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2;
|
|
|
|
do {
|
|
|
|
yslope[i] = FixedDiv (focus, den);
|
|
|
|
den += FRACUNIT;
|
|
|
|
} while (++i < e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
den = (i << FRACBITS) - centeryfrac + FRACUNIT/2;
|
|
|
|
do {
|
|
|
|
yslope[i] = FixedDiv (focus, den);
|
|
|
|
den += FRACUNIT;
|
|
|
|
} while (++i < e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
P_UnPredictPlayer ();
|
|
|
|
framecount++;
|
|
|
|
validcount++;
|
|
|
|
|
|
|
|
if (r_polymost)
|
|
|
|
{
|
|
|
|
polyclipped = RP_SetupFrame (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_RefreshViewBorder
|
|
|
|
//
|
|
|
|
// Draws the border around the player view, if needed.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_RefreshViewBorder ()
|
|
|
|
{
|
|
|
|
if (setblocks < 10)
|
|
|
|
{
|
|
|
|
if (BorderNeedRefresh)
|
|
|
|
{
|
|
|
|
BorderNeedRefresh--;
|
|
|
|
if (BorderTopRefresh)
|
|
|
|
{
|
|
|
|
BorderTopRefresh--;
|
|
|
|
}
|
|
|
|
R_DrawViewBorder();
|
|
|
|
}
|
|
|
|
else if (BorderTopRefresh)
|
|
|
|
{
|
|
|
|
BorderTopRefresh--;
|
|
|
|
R_DrawTopBorder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_EnterMirror
|
|
|
|
//
|
|
|
|
// [RH] Draw the reflection inside a mirror
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_EnterMirror (drawseg_t *ds, int depth)
|
|
|
|
{
|
|
|
|
angle_t startang = viewangle;
|
|
|
|
fixed_t startx = viewx;
|
|
|
|
fixed_t starty = viewy;
|
|
|
|
|
|
|
|
unsigned int mirrorsAtStart = WallMirrors.Size ();
|
|
|
|
|
|
|
|
vertex_t *v1 = ds->curline->v1;
|
|
|
|
|
|
|
|
// Reflect the current view behind the mirror.
|
|
|
|
if (ds->curline->linedef->dx == 0)
|
|
|
|
{ // vertical mirror
|
|
|
|
viewx = v1->x - startx + v1->x;
|
|
|
|
}
|
|
|
|
else if (ds->curline->linedef->dy == 0)
|
|
|
|
{ // horizontal mirror
|
|
|
|
viewy = v1->y - starty + v1->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // any mirror--use floats to avoid integer overflow
|
|
|
|
vertex_t *v2 = ds->curline->v2;
|
|
|
|
|
|
|
|
float dx = FIXED2FLOAT(v2->x - v1->x);
|
|
|
|
float dy = FIXED2FLOAT(v2->y - v1->y);
|
|
|
|
float x1 = FIXED2FLOAT(v1->x);
|
|
|
|
float y1 = FIXED2FLOAT(v1->y);
|
|
|
|
float x = FIXED2FLOAT(startx);
|
|
|
|
float y = FIXED2FLOAT(starty);
|
|
|
|
|
|
|
|
// the above two cases catch len == 0
|
|
|
|
float r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy);
|
|
|
|
|
|
|
|
viewx = FLOAT2FIXED((x1 + r * dx)*2 - x);
|
|
|
|
viewy = FLOAT2FIXED((y1 + r * dy)*2 - y);
|
|
|
|
}
|
|
|
|
viewangle = 2*R_PointToAngle2 (ds->curline->v1->x, ds->curline->v1->y,
|
|
|
|
ds->curline->v2->x, ds->curline->v2->y) - startang;
|
|
|
|
|
|
|
|
viewsin = finesine[viewangle>>ANGLETOFINESHIFT];
|
|
|
|
viewcos = finecosine[viewangle>>ANGLETOFINESHIFT];
|
|
|
|
|
|
|
|
viewtansin = FixedMul (FocalTangent, viewsin);
|
|
|
|
viewtancos = FixedMul (FocalTangent, viewcos);
|
|
|
|
|
|
|
|
R_CopyStackedViewParameters();
|
|
|
|
|
|
|
|
validcount++;
|
|
|
|
ActiveWallMirror = ds->curline;
|
|
|
|
|
|
|
|
R_ClearPlanes (false);
|
|
|
|
R_ClearClipSegs (ds->x1, ds->x2 + 1);
|
|
|
|
|
|
|
|
memcpy (ceilingclip + ds->x1, openings + ds->sprtopclip, (ds->x2 - ds->x1 + 1)*sizeof(*ceilingclip));
|
|
|
|
memcpy (floorclip + ds->x1, openings + ds->sprbottomclip, (ds->x2 - ds->x1 + 1)*sizeof(*floorclip));
|
|
|
|
|
|
|
|
WindowLeft = ds->x1;
|
|
|
|
WindowRight = ds->x2;
|
|
|
|
MirrorFlags = (depth + 1) & 1;
|
|
|
|
|
|
|
|
R_RenderBSPNode (nodes + numnodes - 1);
|
|
|
|
|
|
|
|
R_DrawPlanes ();
|
|
|
|
R_DrawSkyBoxes ();
|
|
|
|
|
|
|
|
// Allow up to 4 recursions through a mirror
|
|
|
|
if (depth < 4)
|
|
|
|
{
|
|
|
|
unsigned int mirrorsAtEnd = WallMirrors.Size ();
|
|
|
|
|
|
|
|
for (; mirrorsAtStart < mirrorsAtEnd; mirrorsAtStart++)
|
|
|
|
{
|
|
|
|
R_EnterMirror (drawsegs + WallMirrors[mirrorsAtStart], depth + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
depth = depth;
|
|
|
|
}
|
|
|
|
|
|
|
|
viewangle = startang;
|
|
|
|
viewx = startx;
|
|
|
|
viewy = starty;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_SetupBuffer
|
|
|
|
//
|
|
|
|
// Precalculate all row offsets and fuzz table.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
void R_SetupBuffer ()
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
static BYTE *lastbuff = NULL;
|
|
|
|
|
|
|
|
int pitch = RenderTarget->GetPitch();
|
|
|
|
BYTE *lineptr = RenderTarget->GetBuffer() + viewwindowy*pitch + viewwindowx;
|
|
|
|
|
|
|
|
if (dc_pitch != pitch || lineptr != lastbuff)
|
|
|
|
{
|
|
|
|
if (dc_pitch != pitch)
|
|
|
|
{
|
|
|
|
dc_pitch = pitch;
|
|
|
|
R_InitFuzzTable (pitch);
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
#if defined(X86_ASM) || defined(X64_ASM)
|
2006-02-24 04:48:15 +00:00
|
|
|
ASM_PatchPitch ();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
dc_destorg = lineptr;
|
|
|
|
for (int i = 0; i < RenderTarget->GetHeight(); i++)
|
|
|
|
{
|
|
|
|
ylookup[i] = i * pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_RenderActorView
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2006-06-18 15:49:00 +00:00
|
|
|
void R_RenderActorView (AActor *actor, bool dontmaplines)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 11:29:19 +00:00
|
|
|
WallCycles.Reset();
|
|
|
|
PlaneCycles.Reset();
|
|
|
|
MaskedCycles.Reset();
|
2008-08-10 03:25:08 +00:00
|
|
|
WallScanCycles.Reset();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
R_SetupBuffer ();
|
2006-02-24 04:48:15 +00:00
|
|
|
R_SetupFrame (actor);
|
|
|
|
|
|
|
|
// Clear buffers.
|
|
|
|
R_ClearClipSegs (0, viewwidth);
|
|
|
|
R_ClearDrawSegs ();
|
|
|
|
R_ClearPlanes (true);
|
|
|
|
R_ClearSprites ();
|
|
|
|
|
|
|
|
NetUpdate ();
|
|
|
|
|
|
|
|
// [RH] Show off segs if r_drawflat is 1
|
|
|
|
if (r_drawflat)
|
|
|
|
{
|
|
|
|
hcolfunc_pre = R_FillColumnHorizP;
|
|
|
|
hcolfunc_post1 = rt_copy1col;
|
|
|
|
hcolfunc_post4 = rt_copy4cols;
|
|
|
|
colfunc = R_FillColumnP;
|
|
|
|
spanfunc = R_FillSpan;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hcolfunc_pre = R_DrawColumnHoriz;
|
|
|
|
hcolfunc_post1 = rt_map1col;
|
|
|
|
hcolfunc_post4 = rt_map4cols;
|
|
|
|
colfunc = basecolfunc;
|
|
|
|
spanfunc = R_DrawSpan;
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowLeft = 0;
|
|
|
|
WindowRight = viewwidth - 1;
|
|
|
|
MirrorFlags = 0;
|
|
|
|
ActiveWallMirror = NULL;
|
|
|
|
|
2006-06-18 15:49:00 +00:00
|
|
|
r_dontmaplines = dontmaplines;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// [RH] Hack to make windows into underwater areas possible
|
|
|
|
r_fakingunderwater = false;
|
|
|
|
|
|
|
|
// [RH] Setup particles for this frame
|
|
|
|
R_FindParticleSubsectors ();
|
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
WallCycles.Clock();
|
2006-05-03 14:54:48 +00:00
|
|
|
DWORD savedflags = camera->renderflags;
|
2006-02-24 04:48:15 +00:00
|
|
|
// Never draw the player unless in chasecam mode
|
|
|
|
if (!r_showviewer)
|
|
|
|
{
|
|
|
|
camera->renderflags |= RF_INVISIBLE;
|
|
|
|
}
|
|
|
|
if (r_polymost < 2)
|
|
|
|
{
|
|
|
|
R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output.
|
|
|
|
}
|
|
|
|
camera->renderflags = savedflags;
|
2008-08-10 03:25:08 +00:00
|
|
|
WallCycles.Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
NetUpdate ();
|
|
|
|
|
|
|
|
if (viewactive)
|
|
|
|
{
|
2008-08-10 03:25:08 +00:00
|
|
|
PlaneCycles.Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
R_DrawPlanes ();
|
|
|
|
R_DrawSkyBoxes ();
|
2008-08-10 03:25:08 +00:00
|
|
|
PlaneCycles.Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// [RH] Walk through mirrors
|
|
|
|
size_t lastmirror = WallMirrors.Size ();
|
|
|
|
for (unsigned int i = 0; i < lastmirror; i++)
|
|
|
|
{
|
|
|
|
R_EnterMirror (drawsegs + WallMirrors[i], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
NetUpdate ();
|
|
|
|
|
2008-08-10 03:25:08 +00:00
|
|
|
MaskedCycles.Clock();
|
2006-02-24 04:48:15 +00:00
|
|
|
R_DrawMasked ();
|
2008-08-10 03:25:08 +00:00
|
|
|
MaskedCycles.Unclock();
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
NetUpdate ();
|
|
|
|
|
|
|
|
if (r_polymost)
|
|
|
|
{
|
|
|
|
RP_RenderBSPNode (nodes + numnodes - 1);
|
|
|
|
if (polyclipped)
|
|
|
|
{
|
|
|
|
RP_SetupFrame (true);
|
|
|
|
RP_RenderBSPNode (nodes + numnodes - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WallMirrors.Clear ();
|
2008-06-04 17:53:15 +00:00
|
|
|
interpolator.RestoreInterpolations ();
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
R_SetupBuffer ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_RenderViewToCanvas
|
|
|
|
//
|
|
|
|
// Pre: Canvas is already locked.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
|
2006-06-18 15:49:00 +00:00
|
|
|
int x, int y, int width, int height, bool dontmaplines)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
const bool savedviewactive = viewactive;
|
|
|
|
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
viewwidth = width;
|
2006-02-24 04:48:15 +00:00
|
|
|
RenderTarget = canvas;
|
|
|
|
bRenderingToCanvas = true;
|
|
|
|
|
|
|
|
R_SetWindow (12, width, height, height);
|
|
|
|
viewwindowx = x;
|
|
|
|
viewwindowy = y;
|
|
|
|
viewactive = true;
|
|
|
|
|
2006-06-18 15:49:00 +00:00
|
|
|
R_RenderActorView (actor, dontmaplines);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
RenderTarget = screen;
|
|
|
|
bRenderingToCanvas = false;
|
|
|
|
R_ExecuteSetViewSize ();
|
|
|
|
screen->Lock (true);
|
- Ported vlinetallasm4 to AMD64 assembly. Even with the increased number of
registers AMD64 provides, this routine still needs to be written as self-
modifying code for maximum performance. The additional registers do allow
for further optimization over the x86 version by allowing all four pixels
to be in flight at the same time. The end result is that AMD64 ASM is about
2.18 times faster than AMD64 C and about 1.06 times faster than x86 ASM.
(For further comparison, AMD64 C and x86 C are practically the same for
this function.) Should I port any more assembly to AMD64, mvlineasm4 is the
most likely candidate, but it's not used enough at this point to bother.
Also, this may or may not work with Linux at the moment, since it doesn't
have the eh_handler metadata. Win64 is easier, since I just need to
structure the function prologue and epilogue properly and use some
assembler directives/macros to automatically generate the metadata. And
that brings up another point: You need YASM to assemble the AMD64 code,
because NASM doesn't support the Win64 metadata directives.
- Added an SSE version of DoBlending. This is strictly C intrinsics.
VC++ still throws around unneccessary register moves. GCC seems to be
pretty close to optimal, requiring only about 2 cycles/color. They're
both faster than my hand-written MMX routine, so I don't need to feel
bad about not hand-optimizing this for x64 builds.
- Removed an extra instruction from DoBlending_MMX, transposed two
instructions, and unrolled it once, shaving off about 80 cycles from the
time required to blend 256 palette entries. Why? Because I tried writing
a C version of the routine using compiler intrinsics and was appalled by
all the extra movq's VC++ added to the code. GCC was better, but still
generated extra instructions. I only wanted a C version because I can't
use inline assembly with VC++'s x64 compiler, and x64 assembly is a bit
of a pain. (It's a pain because Linux and Windows have different calling
conventions, and you need to maintain extra metadata for functions.) So,
the assembly version stays and the C version stays out.
- Removed all the pixel doubling r_detail modes, since the one platform they
were intended to assist (486) actually sees very little benefit from them.
- Rewrote CheckMMX in C and renamed it to CheckCPU.
- Fixed: CPUID function 0x80000005 is specified to return detailed L1 cache
only for AMD processors, so we must not use it on other architectures, or
we end up overwriting the L1 cache line size with 0 or some other number
we don't actually understand.
SVN r1134 (trunk)
2008-08-09 03:13:43 +00:00
|
|
|
R_SetupBuffer ();
|
2006-02-24 04:48:15 +00:00
|
|
|
screen->Unlock ();
|
|
|
|
viewactive = savedviewactive;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FCanvasTextureInfo :: Add
|
|
|
|
//
|
|
|
|
// Assigns a camera to a canvas texture.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, int fov)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
FCanvasTextureInfo *probe;
|
|
|
|
FCanvasTexture *texture;
|
|
|
|
|
2008-06-15 18:36:26 +00:00
|
|
|
if (!picnum.isValid())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
texture = static_cast<FCanvasTexture *>(TexMan[picnum]);
|
|
|
|
if (!texture->bHasCanvas)
|
|
|
|
{
|
|
|
|
Printf ("%s is not a valid target for a camera\n", texture->Name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is this texture already assigned to a camera?
|
|
|
|
for (probe = List; probe != NULL; probe = probe->Next)
|
|
|
|
{
|
|
|
|
if (probe->Texture == texture)
|
|
|
|
{
|
|
|
|
// Yes, change its assignment to this new camera
|
2008-03-16 00:54:53 +00:00
|
|
|
if (probe->Viewpoint != viewpoint || probe->FOV != fov)
|
|
|
|
{
|
|
|
|
texture->bFirstUpdate = true;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
probe->Viewpoint = viewpoint;
|
|
|
|
probe->FOV = fov;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// No, create a new assignment
|
|
|
|
probe = new FCanvasTextureInfo;
|
|
|
|
probe->Viewpoint = viewpoint;
|
|
|
|
probe->Texture = texture;
|
|
|
|
probe->PicNum = picnum;
|
|
|
|
probe->FOV = fov;
|
|
|
|
probe->Next = List;
|
2006-06-18 15:49:00 +00:00
|
|
|
texture->bFirstUpdate = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
List = probe;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FCanvasTextureInfo :: UpdateAll
|
|
|
|
//
|
|
|
|
// Updates all canvas textures that were visible in the last frame.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FCanvasTextureInfo::UpdateAll ()
|
|
|
|
{
|
|
|
|
FCanvasTextureInfo *probe;
|
|
|
|
|
|
|
|
for (probe = List; probe != NULL; probe = probe->Next)
|
|
|
|
{
|
|
|
|
if (probe->Viewpoint != NULL && probe->Texture->bNeedsUpdate)
|
|
|
|
{
|
|
|
|
probe->Texture->RenderView (probe->Viewpoint, probe->FOV);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FCanvasTextureInfo :: EmptyList
|
|
|
|
//
|
|
|
|
// Removes all camera->texture assignments.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FCanvasTextureInfo::EmptyList ()
|
|
|
|
{
|
|
|
|
FCanvasTextureInfo *probe, *next;
|
|
|
|
|
|
|
|
for (probe = List; probe != NULL; probe = next)
|
|
|
|
{
|
|
|
|
next = probe->Next;
|
|
|
|
delete probe;
|
|
|
|
}
|
|
|
|
List = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FCanvasTextureInfo :: Serialize
|
|
|
|
//
|
|
|
|
// Reads or writes the current set of mappings in an archive.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FCanvasTextureInfo::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
if (arc.IsStoring ())
|
|
|
|
{
|
|
|
|
FCanvasTextureInfo *probe;
|
|
|
|
|
|
|
|
for (probe = List; probe != NULL; probe = probe->Next)
|
|
|
|
{
|
|
|
|
if (probe->Texture != NULL && probe->Viewpoint != NULL)
|
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
arc << probe->Viewpoint << probe->FOV << probe->PicNum;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
AActor *nullactor = NULL;
|
|
|
|
arc << nullactor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AActor *viewpoint;
|
2008-06-15 18:36:26 +00:00
|
|
|
int fov;
|
|
|
|
FTextureID picnum;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
EmptyList ();
|
2008-06-15 18:36:26 +00:00
|
|
|
while (arc << viewpoint, viewpoint != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-06-15 18:36:26 +00:00
|
|
|
arc << fov << picnum;
|
2006-02-24 04:48:15 +00:00
|
|
|
Add (viewpoint, picnum, fov);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-16 00:54:53 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// FCanvasTextureInfo :: Mark
|
|
|
|
//
|
|
|
|
// Marks all viewpoints in the list for the collector.
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void FCanvasTextureInfo::Mark()
|
|
|
|
{
|
|
|
|
for (FCanvasTextureInfo *probe = List; probe != NULL; probe = probe->Next)
|
|
|
|
{
|
|
|
|
GC::Mark(probe->Viewpoint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
//==========================================================================
|
|
|
|
//
|
|
|
|
// R_MultiresInit
|
|
|
|
//
|
|
|
|
// Called from V_SetResolution()
|
|
|
|
//
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
void R_MultiresInit ()
|
|
|
|
{
|
|
|
|
R_PlaneInitData ();
|
|
|
|
R_OldBlend = ~0;
|
|
|
|
}
|
|
|
|
|