123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582 |
- //===========================================================================//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #include "MLRHeaders.hpp"
- //#############################################################################
- //############################ GOSPoint #################################
- //#############################################################################
- GOSPoint::GOSPoint()
- {
- x = 0.0f;
- y = 0.0f;
- z = 0.0f;
- w = 1.0f;
- argb = 0xffffffff;
- }
- #if 0
- bool
- GOSCopyTriangleData
- ( GOSPoint *gos_points,
- Vector4D *coords,
- RGBAColor *colors,
- int offset0,
- int offset1,
- int offset2)
- {
- #if USE_ASSEMBLER_CODE
- _asm {
- ; gos_points[0].w = 1.0f/coords[offset0].w;
- mov ecx,dword ptr [coords]
- fld1
- mov edi,dword ptr [offset0]
- mov eax,edi
- shl eax,4
- fdiv dword ptr [eax+ecx+0Ch]
- add eax,ecx
- mov edx,dword ptr [gos_points]
- fst dword ptr [edx+0Ch]
- ; gos_points[0].x = coords[offset0].x * gos_points[0].w;
- fld st(0)
- fmul dword ptr [eax]
- fstp dword ptr [edx]
- ; gos_points[0].y = coords[offset0].y * gos_points[0].w;
- fld dword ptr [eax+4]
- fmul st,st(1)
- fstp dword ptr [edx+4]
- ; gos_points[0].z = coords[offset0].z * gos_points[0].w;
- fld dword ptr [eax+8]
- ; gos_points[1].w = 1.0f/coords[offset1].w;
- mov eax,dword ptr [offset1]
- fmul st,st(1)
- shl eax,4
- add eax,ecx
- fstp dword ptr [edx+8]
- fstp st(0)
- fld1
- fdiv dword ptr [eax+0Ch]
- fst dword ptr [edx+2Ch]
- ; gos_points[1].x = coords[offset1].x * gos_points[1].w;
- fld st(0)
- fmul dword ptr [eax]
- fstp dword ptr [edx+20h]
- ; gos_points[1].y = coords[offset1].y * gos_points[1].w;
- fld dword ptr [eax+4]
- fmul st,st(1)
- fstp dword ptr [edx+24h]
- ; gos_points[1].z = coords[offset1].z * gos_points[1].w;
- fld dword ptr [eax+8]
- ; gos_points[2].w = 1.0f/coords[offset2].w;
- mov eax,dword ptr [offset2]
- fmul st,st(1)
- shl eax,4
- add eax,ecx
- fstp dword ptr [edx+28h]
- fstp st(0)
- fld1
- fdiv dword ptr [eax+0Ch]
- fst dword ptr [edx+4Ch]
- ; gos_points[2].x = coords[offset2].x * gos_points[2].w;
- fld st(0)
- fmul dword ptr [eax]
- fstp dword ptr [edx+40h]
- ; gos_points[2].y = coords[offset2].y * gos_points[2].w;
- fld dword ptr [eax+4]
- fmul st,st(1)
- fstp dword ptr [edx+44h]
- ; gos_points[2].z = coords[offset2].z * gos_points[2].w;
- fld dword ptr [eax+8]
- fmul st,st(1)
- fstp dword ptr [edx+48h]
- fstp st(0)
- }
- #else
- gos_points[0].w = 1.0f/coords[offset0].w;
- gos_points[0].x = coords[offset0].x * gos_points[0].w;
- gos_points[0].y = coords[offset0].y * gos_points[0].w;
- gos_points[0].z = coords[offset0].z * gos_points[0].w;
- gos_points[1].w = 1.0f/coords[offset1].w;
- gos_points[1].x = coords[offset1].x * gos_points[1].w;
- gos_points[1].y = coords[offset1].y * gos_points[1].w;
- gos_points[1].z = coords[offset1].z * gos_points[1].w;
- gos_points[2].w = 1.0f/coords[offset2].w;
- gos_points[2].x = coords[offset2].x * gos_points[2].w;
- gos_points[2].y = coords[offset2].y * gos_points[2].w;
- gos_points[2].z = coords[offset2].z * gos_points[2].w;
- #endif
- // gos_points[0] = colors[offset0];
- // gos_points[1] = colors[offset1];
- // gos_points[2] = colors[offset2];
- Scalar f;
- #if USE_ASSEMBLER_CODE
- int argb;
- _asm {
- fld float_cheat
- mov esi, dword ptr [colors]
- mov eax, offset0
- shl eax, 4
- add esi, eax
- fld dword ptr [esi + 0Ch]
- mov ecx, dword ptr [esi + 0Ch]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov argb, ebx
- fld dword ptr [esi]
- mov ecx, dword ptr [esi]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+4]
- mov ecx, dword ptr [esi+4]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+8]
- mov ecx, dword ptr [esi+8]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- }
- gos_points[0].argb = argb;
- _asm {
- mov esi, dword ptr [colors]
- mov eax, offset1
- shl eax, 4
- add esi, eax
- fld dword ptr [esi + 0Ch]
- mov ecx, dword ptr [esi + 0Ch]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov argb, ebx
- fld dword ptr [esi]
- mov ecx, dword ptr [esi]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+4]
- mov ecx, dword ptr [esi+4]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+8]
- mov ecx, dword ptr [esi+8]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- }
- gos_points[1].argb = argb;
- _asm {
- mov esi, dword ptr [colors]
- mov eax, offset2
- shl eax, 4
- add esi, eax
- fld dword ptr [esi + 0Ch]
- mov ecx, dword ptr [esi + 0Ch]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov argb, ebx
- fld dword ptr [esi]
- mov ecx, dword ptr [esi]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+4]
- mov ecx, dword ptr [esi+4]
- fadd st, st(1)
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- fld dword ptr [esi+8]
- mov ecx, dword ptr [esi+8]
- faddp st(1), st
- rcl ecx, 1
- sbb eax, eax
- xor eax, -1
- fstp f
- xor ecx, ecx
- mov ebx, f
- and ebx, eax
- test ebx, 0000ff00h
- seta cl
- xor eax, eax
- sub eax, ecx
- or ebx, eax
- and ebx, 000000ffh
- mov ecx, argb
- shl ecx, 8
- or ecx, ebx
- mov argb, ecx
- }
- gos_points[2].argb = argb;
- #else
- f = colors[offset0].alpha * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[0].argb = Positive_Float_To_Byte (f);
- f = colors[offset0].red * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[0].argb = (gos_points[0].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset0].green * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[0].argb = (gos_points[0].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset0].blue * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[0].argb = (gos_points[0].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset1].alpha * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[1].argb = Positive_Float_To_Byte (f);
- f = colors[offset1].red * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[1].argb = (gos_points[1].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset1].green * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[1].argb = (gos_points[1].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset1].blue * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[1].argb = (gos_points[1].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset2].alpha * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[2].argb = Positive_Float_To_Byte (f);
- f = colors[offset2].red * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[2].argb = (gos_points[2].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset2].green * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[2].argb = (gos_points[2].argb << 8) | Positive_Float_To_Byte (f);
- f = colors[offset2].blue * 255.99f;
- Clamp(f, 0.0f, 255.f);
- gos_points[2].argb = (gos_points[2].argb << 8) | Positive_Float_To_Byte (f);
- #endif
- return true;
- }
- #endif
|