forked from 0ad/0ad
janwas
ffdff6888d
enable most of IA-32 specific code to be used in amd64 (resides in directory lib/sysdep/x86_x64) bits: add IsBitSet remove mem_PageSize (use os_cpu_PageSize instead) cpuid: change interface to allow gracefully supporting later subfunctions that require input parameters amd64_asm.asm: add amd64 implementation of cpuid cpu: move functions provided by OS to sysdep/os_cpu.cpp cpu topology: avoid trouble when process affinity is set by remapping processor numbers to 0..PopulationCount(processAffinity) topology.cpp: move ex-ia32 topology code here. This was SVN commit r5945.
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/**
|
|
* =========================================================================
|
|
* File : Color.cpp
|
|
* Project : 0 A.D.
|
|
* Description : Convert float RGB(A) colors to unsigned byte
|
|
* =========================================================================
|
|
*/
|
|
|
|
#include "precompiled.h"
|
|
|
|
#include "graphics/Color.h"
|
|
|
|
#include "maths/MathUtil.h"
|
|
#include "graphics/SColor.h"
|
|
#include "lib/sysdep/x86_x64/x86_x64.h"
|
|
|
|
static u32 fallback_ConvertRGBColorTo4ub(const RGBColor& src)
|
|
{
|
|
SColor4ub result;
|
|
result.R=clamp(int(src.X*255),0,255);
|
|
result.G=clamp(int(src.Y*255),0,255);
|
|
result.B=clamp(int(src.Z*255),0,255);
|
|
result.A=0xff;
|
|
return *(u32*)&result;
|
|
}
|
|
|
|
// on IA32, this is replaced by an SSE assembly version in ia32.cpp
|
|
u32 (*ConvertRGBColorTo4ub)(const RGBColor& src) = fallback_ConvertRGBColorTo4ub;
|
|
|
|
|
|
// Assembler-optimized function for color conversion
|
|
#if ARCH_IA32
|
|
EXTERN_C u32 sse_ConvertRGBColorTo4ub(const RGBColor& src);
|
|
#endif
|
|
|
|
void ColorActivateFastImpl()
|
|
{
|
|
if(0)
|
|
{
|
|
}
|
|
#if ARCH_IA32
|
|
else if (x86_x64_cap(X86_X64_CAP_SSE))
|
|
{
|
|
ConvertRGBColorTo4ub = sse_ConvertRGBColorTo4ub;
|
|
}
|
|
#endif
|
|
else
|
|
{
|
|
debug_printf("No SSE available. Slow fallback routines will be used.\n");
|
|
}
|
|
}
|