mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-15 08:52:04 +00:00
dda5ddd3c2
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)
125 lines
3.3 KiB
C++
125 lines
3.3 KiB
C++
// 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:
|
|
// Sky rendering. The DOOM sky is a texture map like any
|
|
// wall, wrapping around. 1024 columns equal 360 degrees.
|
|
// The default sky map is 256 columns and repeats 4 times
|
|
// on a 320 screen.
|
|
//
|
|
//
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
// Needed for FRACUNIT.
|
|
#include "m_fixed.h"
|
|
#include "r_data.h"
|
|
#include "c_cvars.h"
|
|
#include "g_level.h"
|
|
#include "r_sky.h"
|
|
#include "r_main.h"
|
|
#include "v_text.h"
|
|
#include "gi.h"
|
|
|
|
//
|
|
// sky mapping
|
|
//
|
|
FTextureID skyflatnum;
|
|
FTextureID sky1texture, sky2texture;
|
|
fixed_t skytexturemid;
|
|
fixed_t skyscale;
|
|
int skystretch;
|
|
fixed_t skyheight;
|
|
fixed_t skyiscale;
|
|
|
|
int sky1shift, sky2shift;
|
|
fixed_t sky1pos=0, sky1speed=0;
|
|
fixed_t sky2pos=0, sky2speed=0;
|
|
|
|
// [RH] Stretch sky texture if not taller than 128 pixels?
|
|
CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE)
|
|
{
|
|
R_InitSkyMap ();
|
|
}
|
|
|
|
extern fixed_t freelookviewheight;
|
|
|
|
//==========================================================================
|
|
//
|
|
// R_InitSkyMap
|
|
//
|
|
// Called whenever the view size changes.
|
|
//
|
|
//==========================================================================
|
|
|
|
void R_InitSkyMap ()
|
|
{
|
|
fixed_t fskyheight;
|
|
FTexture *skytex1, *skytex2;
|
|
|
|
skytex1 = TexMan[sky1texture];
|
|
skytex2 = TexMan[sky2texture];
|
|
|
|
if (skytex1 == NULL)
|
|
return;
|
|
|
|
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetHeight() != skytex2->GetHeight())
|
|
{
|
|
Printf (TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
|
sky2texture = sky1texture;
|
|
}
|
|
|
|
fskyheight = skytex1->GetHeight() << FRACBITS;
|
|
if (skytex1->GetScaledHeight() <= 128)
|
|
{
|
|
skytexturemid = r_Yaspect/2*FRACUNIT;
|
|
skystretch = (r_stretchsky
|
|
&& level.IsFreelookAllowed()
|
|
&& !(level.flags & LEVEL_FORCENOSKYSTRETCH)) ? 1 : 0;
|
|
}
|
|
else
|
|
{
|
|
skytexturemid = 199 * skytex1->yScale;
|
|
skystretch = 0;
|
|
// At heights above 600 pixels, the sky is drawn slightly too low.
|
|
if (SCREENHEIGHT > 600)
|
|
{
|
|
skytexturemid += FRACUNIT;
|
|
}
|
|
}
|
|
skyheight = fskyheight << skystretch;
|
|
|
|
if (viewwidth && viewheight)
|
|
{
|
|
skyiscale = (r_Yaspect*FRACUNIT) / ((freelookviewheight * viewwidth) / viewwidth);
|
|
skyscale = (((freelookviewheight * viewwidth) / viewwidth) << FRACBITS) /
|
|
(r_Yaspect);
|
|
|
|
skyiscale = Scale (skyiscale, FieldOfView, 2048);
|
|
skyscale = Scale (skyscale, 2048, FieldOfView);
|
|
}
|
|
|
|
// The (standard Doom) sky map is 256*128*4 maps.
|
|
sky1shift = 22+skystretch-16;
|
|
sky2shift = 22+skystretch-16;
|
|
if (skytex1->WidthBits >= 9)
|
|
sky1shift -= skystretch;
|
|
if (skytex2->WidthBits >= 9)
|
|
sky2shift -= skystretch;
|
|
}
|
|
|