cinput, ogl_shader, h_mgr, vfs: stomp on warnings
ia32, sysdep: add rint() minimap: saw TODO on GetMapSpaceCoords and sped it up by 15% using rintf and precalculating scaleX timer: add indication of how often something was billed (helps measure stuff called an indeterminate number of times) This was SVN commit r2973.
This commit is contained in:
parent
353260f8ec
commit
39060e7900
@ -1428,6 +1428,7 @@ int CInput::GetMouseHoveringTextPosition()
|
||||
|
||||
// Pointer to caption, will come in handy
|
||||
CStrW *pCaption = (CStrW*)m_Settings["caption"].m_pSetting;
|
||||
UNUSED2(pCaption);
|
||||
|
||||
// Now get the height of the font.
|
||||
// TODO: Get the real font
|
||||
|
@ -22,6 +22,13 @@
|
||||
|
||||
bool g_TerrainModified = false;
|
||||
|
||||
// used by GetMapSpaceCoords (precalculated as an optimization).
|
||||
// this was formerly access via inline asm, which required it to be
|
||||
// static data instead of a class member. that is no longer the case,
|
||||
// but we leave it because this is slightly more efficient.
|
||||
static float m_scaleX, m_scaleY;
|
||||
|
||||
|
||||
static unsigned int ScaleColor(unsigned int color, float x)
|
||||
{
|
||||
unsigned int r = uint(float(color & 0xff) * x);
|
||||
@ -168,6 +175,9 @@ void CMiniMap::Draw()
|
||||
m_MapSize = m_Terrain->GetVerticesPerSide();
|
||||
m_TextureSize = round_up_to_pow2(m_MapSize);
|
||||
|
||||
m_scaleX = float(m_Width) / float(m_MapSize - 1);
|
||||
m_scaleY = float(m_Height) / float(m_MapSize - 1);
|
||||
|
||||
if(!m_TerrainTexture)
|
||||
CreateTextures();
|
||||
|
||||
@ -422,23 +432,12 @@ void CMiniMap::Destroy()
|
||||
}
|
||||
}
|
||||
|
||||
TIMER_ADD_CLIENT(tc_minimap_getmapspacecoords);
|
||||
|
||||
/*
|
||||
* Calefaction
|
||||
* TODO: Speed this up. There has to be some mathematical way to make
|
||||
* this more efficient. This works for now.
|
||||
*/
|
||||
CVector2D CMiniMap::GetMapSpaceCoords(CVector3D worldPos)
|
||||
{
|
||||
TIMER_ACCRUE(tc_minimap_getmapspacecoords);
|
||||
|
||||
u32 x = (u32)(worldPos.X / CELL_SIZE);
|
||||
float x = rintf(worldPos.X / CELL_SIZE);
|
||||
float y = rintf(worldPos.Z / CELL_SIZE);
|
||||
// Entity's Z coordinate is really its longitudinal coordinate on the terrain
|
||||
u32 y = (u32)(worldPos.Z / CELL_SIZE);
|
||||
|
||||
// Calculate map space scale
|
||||
float scaleX = float(m_Width) / float(m_MapSize - 1);
|
||||
float scaleY = float(m_Height) / float(m_MapSize - 1);
|
||||
return CVector2D(float(x) * scaleX, float(y) * scaleY);
|
||||
return CVector2D(x * m_scaleX, y * m_scaleY);
|
||||
}
|
||||
|
@ -58,9 +58,6 @@ protected:
|
||||
// map size
|
||||
u32 m_MapSize;
|
||||
|
||||
// used by GetMapSpaceCoords (precalculated as an optimization)
|
||||
float m_scaleX, m_scaleY;
|
||||
|
||||
// texture size
|
||||
u32 m_TextureSize;
|
||||
|
||||
|
@ -142,6 +142,7 @@ static int VDir_validate(const VDir* vd)
|
||||
if(vd->filter && !isprint(vd->filter[0]))
|
||||
return -2;
|
||||
#endif
|
||||
UNUSED2(vd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ static void Ogl_Shader_dtor(Ogl_Shader* shdr)
|
||||
}
|
||||
}
|
||||
|
||||
static int Ogl_Shader_validate(const Ogl_Shader* shdr)
|
||||
static int Ogl_Shader_validate(const Ogl_Shader* UNUSED(shdr))
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
@ -225,7 +225,7 @@ static void Ogl_Program_init(Ogl_Program* UNUSED(p), va_list UNUSED(args))
|
||||
// Load the shader associated with one Shader element,
|
||||
// and attach it to our program object.
|
||||
static int do_load_shader(
|
||||
Ogl_Program* p, const char* filename, Handle h,
|
||||
Ogl_Program* p, const char* filename, Handle UNUSED(h),
|
||||
const CXeromyces& XeroFile, const XMBElement& Shader)
|
||||
{
|
||||
#define AT(x) int at_##x = XeroFile.getAttributeID(#x)
|
||||
@ -379,7 +379,7 @@ static void Ogl_Program_dtor(Ogl_Program* p)
|
||||
}
|
||||
}
|
||||
|
||||
static int Ogl_Program_validate(const Ogl_Program* p)
|
||||
static int Ogl_Program_validate(const Ogl_Program* UNUSED(p))
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
|
@ -481,6 +481,8 @@ static void warn_if_invalid(HDATA* hd)
|
||||
if(*p != 0)
|
||||
debug_warn("handle user data was overrun!");
|
||||
}
|
||||
#else
|
||||
UNUSED2(hd);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,10 @@
|
||||
#error ia32.cpp needs inline assembly support!
|
||||
#endif
|
||||
|
||||
#if HAVE_MS_ASM
|
||||
|
||||
// replace pathetic MS libc implementation.
|
||||
// not needed on non-Win32, so don't bother converting from MS inline asm.
|
||||
#if HAVE_MS_ASM
|
||||
double _ceil(double f)
|
||||
{
|
||||
UNUSED2(f); // avoid bogus warning
|
||||
@ -57,6 +58,28 @@ __asm
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
// note: declspec naked is significantly faster: it avoids redundant
|
||||
// store/load, even though it prevents inlining.
|
||||
|
||||
// if on 64-bit systems, [esp+4] will have to change
|
||||
cassert(sizeof(int)*CHAR_BIT == 32);
|
||||
|
||||
__declspec(naked) float ia32_rintf(float)
|
||||
{
|
||||
__asm fld [esp+4]
|
||||
__asm frndint
|
||||
__asm ret
|
||||
}
|
||||
|
||||
inline double ia32_rint(double)
|
||||
{
|
||||
__asm fld [esp+4]
|
||||
__asm frndint
|
||||
__asm ret
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -34,8 +34,13 @@ extern "C" {
|
||||
// call before any of the following functions
|
||||
extern void ia32_init();
|
||||
|
||||
|
||||
extern double _ceil(double);
|
||||
|
||||
extern float ia32_rintf(float f);
|
||||
extern double ia32_rint(double f);
|
||||
|
||||
|
||||
extern u64 rdtsc(void);
|
||||
|
||||
|
||||
|
@ -35,8 +35,23 @@ float fmaxf(float a, float b)
|
||||
return (a > b)? a : b;
|
||||
}
|
||||
|
||||
|
||||
#ifndef rint
|
||||
|
||||
inline float rintf(float f)
|
||||
{
|
||||
return (float)(int)f;
|
||||
}
|
||||
|
||||
inline double rint(double d)
|
||||
{
|
||||
return (double)(int)d;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // !HAVE_C99
|
||||
|
||||
|
||||
void memcpy2(void* dst, const void* src, size_t nbytes)
|
||||
{
|
||||
|
@ -39,6 +39,19 @@ extern int vsnprintf2(char* buffer, size_t count, const char* format, va_list ar
|
||||
extern void* alloca(size_t size);
|
||||
#endif
|
||||
|
||||
// rint: round float to nearest integer.
|
||||
// provided by C99, otherwise:
|
||||
#if !HAVE_C99
|
||||
// .. implemented on IA-32; define as macro to avoid jmp overhead
|
||||
# if CPU_IA32
|
||||
# define rintf ia32_rintf
|
||||
# define rint ia32_rint
|
||||
# endif
|
||||
// .. forward-declare either the IA-32 version or portable C emulation.
|
||||
extern float rintf(float f);
|
||||
extern double rint(double d);
|
||||
#endif
|
||||
|
||||
// finite: return 0 iff the given double is infinite or NaN.
|
||||
#if OS_WIN
|
||||
# define finite _finite
|
||||
@ -71,6 +84,7 @@ extern void* alloca(size_t size);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//
|
||||
// output
|
||||
//
|
||||
|
@ -278,6 +278,7 @@ TimerClient* timer_add_client(TimerClient* tc, const char* description)
|
||||
void timer_bill_client(TimerClient* tc, double dt)
|
||||
{
|
||||
tc->sum += dt;
|
||||
tc->num_calls++;
|
||||
}
|
||||
|
||||
|
||||
@ -305,7 +306,7 @@ void timer_display_client_totals()
|
||||
else if(sum > 1e-3)
|
||||
scale = 1e3, unit = "ms";
|
||||
|
||||
debug_printf(" %s: %g %s\n", tc->description, sum*scale, unit);
|
||||
debug_printf(" %s: %g %s (%dx)\n", tc->description, sum*scale, unit, tc->num_calls);
|
||||
}
|
||||
|
||||
debug_printf("-----------------------------------------------------\n");
|
||||
|
@ -62,6 +62,10 @@ struct TimerClient
|
||||
const char* description;
|
||||
|
||||
TimerClient* next;
|
||||
|
||||
// how often timer_bill_client was called (helps measure relative
|
||||
// performance of something that is done indeterminately often).
|
||||
uint num_calls;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user