mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
- Restored DoBlending_MMX for non SSE2 cpus.
This commit is contained in:
parent
0c38c72ad7
commit
a695491a1f
2 changed files with 75 additions and 8 deletions
|
@ -361,6 +361,7 @@ void InitPalette ()
|
|||
R_InitColormaps ();
|
||||
}
|
||||
|
||||
void DoBlending_MMX (const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a);
|
||||
void DoBlending_SSE2 (const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a);
|
||||
|
||||
void DoBlending (const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a)
|
||||
|
@ -385,17 +386,37 @@ void DoBlending (const PalEntry *from, PalEntry *to, int count, int r, int g, in
|
|||
return;
|
||||
}
|
||||
#if defined(_M_X64) || defined(_M_IX86) || defined(__i386__) || defined(__amd64__)
|
||||
else if (count >= 4)
|
||||
else if (CPU.bSSE2)
|
||||
{
|
||||
int not3count = count & ~3;
|
||||
DoBlending_SSE2 (from, to, not3count, r, g, b, a);
|
||||
count &= 3;
|
||||
if (count <= 0)
|
||||
if (count >= 4)
|
||||
{
|
||||
return;
|
||||
int not3count = count & ~3;
|
||||
DoBlending_SSE2 (from, to, not3count, r, g, b, a);
|
||||
count &= 3;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
from += not3count;
|
||||
to += not3count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(_M_IX86) || defined(__i386__)
|
||||
else if (CPU.bMMX)
|
||||
{
|
||||
if (count >= 4)
|
||||
{
|
||||
int not3count = count & ~3;
|
||||
DoBlending_MMX (from, to, not3count, r, g, b, a);
|
||||
count &= 3;
|
||||
if (count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
from += not3count;
|
||||
to += not3count;
|
||||
}
|
||||
from += not3count;
|
||||
to += not3count;
|
||||
}
|
||||
#endif
|
||||
int i, ia;
|
||||
|
|
46
src/x86.cpp
46
src/x86.cpp
|
@ -246,6 +246,9 @@ void DumpCPUInfo(const CPUInfo *cpu)
|
|||
cpu->Family, cpu->Model, cpu->Stepping);
|
||||
}
|
||||
Printf(" Features:");
|
||||
if (cpu->bMMX) Printf(" MMX");
|
||||
if (cpu->bMMXPlus) Printf(" MMX+");
|
||||
if (cpu->bSSE) Printf(" SSE");
|
||||
if (cpu->bSSE2) Printf(" SSE2");
|
||||
if (cpu->bSSE3) Printf(" SSE3");
|
||||
if (cpu->bSSSE3) Printf(" SSSE3");
|
||||
|
@ -257,6 +260,49 @@ void DumpCPUInfo(const CPUInfo *cpu)
|
|||
Printf ("\n");
|
||||
}
|
||||
}
|
||||
#if !defined(__amd64__) && !defined(_M_X64)
|
||||
|
||||
void DoBlending_MMX(const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a)
|
||||
{
|
||||
__m64 blendcolor;
|
||||
__m64 blendalpha;
|
||||
__m64 zero;
|
||||
__m64 blending256;
|
||||
__m64 color1;
|
||||
__m64 color2;
|
||||
|
||||
zero = _mm_setzero_si64();
|
||||
#ifndef __GNUC__
|
||||
blending256.m64_i64 = 0x10001000100;
|
||||
#else
|
||||
blending256 = (__m64)0x10001000100ll;
|
||||
#endif
|
||||
|
||||
blendcolor = _mm_unpacklo_pi8(_m_from_int((r << 16) | (g << 8) | b), zero); // 000000RR 00GG00BB
|
||||
blendalpha = _mm_unpacklo_pi8(_m_from_int((a << 16) | (a << 8) | a), zero); // 000000AA 00AA00AA
|
||||
|
||||
blendcolor = _mm_mullo_pi16(blendcolor, blendalpha); // premultiply blend by alpha
|
||||
blendalpha = _mm_subs_pu16(blending256, blendalpha); // one minus alpha
|
||||
|
||||
// Do two colors per iteration: Count must be even
|
||||
for (count >>= 1; count > 0; --count)
|
||||
{
|
||||
color1 = *(__m64 *)from; // 00r2g2b2 00r1g1b1
|
||||
from += 2;
|
||||
color2 = _mm_unpackhi_pi8(color1, zero); // 000000r2 00g200b2
|
||||
color1 = _mm_unpacklo_pi8(color1, zero); // 000000r1 00g100b1
|
||||
color1 = _mm_mullo_pi16(blendalpha, color1); // 0000r1rr g1ggb1bb
|
||||
color2 = _mm_mullo_pi16(blendalpha, color2); // 0000r2rr g2ggb2bb
|
||||
color1 = _mm_adds_pu16(blendcolor, color1);
|
||||
color2 = _mm_adds_pu16(blendcolor, color2);
|
||||
color1 = _mm_srli_pi16(color1, 8);
|
||||
color2 = _mm_srli_pi16(color2, 8);
|
||||
*(__m64 *)to = _mm_packs_pu16(color1, color2); // 00r2g2b2 00r1g1b1
|
||||
to += 2;
|
||||
}
|
||||
_mm_empty();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void DoBlending_SSE2(const PalEntry *from, PalEntry *to, int count, int r, int g, int b, int a)
|
||||
|
|
Loading…
Reference in a new issue