VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/packer/pack_bbox.h@ 50973

Last change on this file since 50973 was 15532, checked in by vboxsync, 16 years ago

crOpenGL: export to OSE

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved.
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#ifndef CR_PACK_BBOX_H
8#define CR_PACK_BBOX_H
9
10#include "cr_pack.h"
11
12#define UPDATE_1D_BBOX() \
13if (pc->bounds_min.x > fx) pc->bounds_min.x = fx;\
14if (pc->bounds_min.y > 0.0f) pc->bounds_min.y = 0.0f;\
15if (pc->bounds_min.z > 0.0f) pc->bounds_min.z = 0.0f;\
16if (pc->bounds_max.x < fx) pc->bounds_max.x = fx;\
17if (pc->bounds_max.y < 0.0f) pc->bounds_max.y = 0.0f;\
18if (pc->bounds_max.z < 0.0f) pc->bounds_max.z = 0.0f
19
20#define UPDATE_2D_BBOX() \
21if (pc->bounds_min.x > fx) pc->bounds_min.x = fx;\
22if (pc->bounds_min.y > fy) pc->bounds_min.y = fy;\
23if (pc->bounds_min.z > 0.0f) pc->bounds_min.z = 0.0f;\
24if (pc->bounds_max.x < fx) pc->bounds_max.x = fx;\
25if (pc->bounds_max.y < fy) pc->bounds_max.y = fy;\
26if (pc->bounds_max.z < 0.0f) pc->bounds_max.z = 0.0f
27
28#define UPDATE_3D_BBOX() \
29if (pc->bounds_min.x > fx) pc->bounds_min.x = fx; \
30if (pc->bounds_min.y > fy) pc->bounds_min.y = fy; \
31if (pc->bounds_min.z > fz) pc->bounds_min.z = fz; \
32if (pc->bounds_max.x < fx) pc->bounds_max.x = fx; \
33if (pc->bounds_max.y < fy) pc->bounds_max.y = fy; \
34if (pc->bounds_max.z < fz) pc->bounds_max.z = fz
35
36#ifdef SIMD
37#define UPDATE_3D_BBOX_SIMD() \
38__asm {\
39 __asm movups xmm0, fx\
40 __asm movaps xmm1, pc->bounds_min.x\
41 __asm movaps xmm2, pc->bounds_max.x\
42 __asm minps xmm1, xmm0\
43 __asm maxps xmm2, xmm0\
44 __asm movaps pc->bounds_min.x, xmm1\
45 __asm movaps pc->bounds_max.x, xmm2\
46}
47#define UPDATE_3D_BBOX_SIMD_PACK() \
48__asm {\
49 __asm mov ecx, [data_ptr]\
50 __asm movups xmm0, fx\
51 __asm movaps xmm1, pc->bounds_min.x\
52 __asm movaps xmm2, pc->bounds_max.x\
53 __asm minps xmm1, xmm0\
54 __asm maxps xmm2, xmm0\
55 __asm movaps pc->bounds_min.x, xmm1\
56 __asm movaps pc->bounds_max.x, xmm2\
57 __asm movups [ecx], xmm0\
58}
59#define UPDATE_3DV_BBOX_SIMD() \
60__asm {\
61 __asm mov eax, [v]\
62 __asm mov ecx, [data_ptr]\
63 __asm movups xmm0, [eax]\
64 __asm movaps xmm1, pc->bounds_min.x\
65 __asm movaps xmm2, pc->bounds_max.x\
66 __asm minps xmm1, xmm0\
67 __asm maxps xmm2, xmm0\
68 __asm movaps pc->bounds_min.x, xmm1\
69 __asm movaps pc->bounds_max.x, xmm2\
70 __asm movups [ecx], xmm0\
71}
72#else
73#define UPDATE_3DV_BBOX_SIMD() { CREATE_3D_VFLOATS(); UPDATE_3D_BBOX();}
74#define UPDATE_3D_BBOX_SIMD() UPDATE_3D_BBOX()
75#endif
76
77#define CREATE_1D_FLOATS() \
78 GLfloat fx = (GLfloat) x;
79
80#define CREATE_2D_FLOATS() \
81 GLfloat fx = (GLfloat) x; \
82 GLfloat fy = (GLfloat) y
83
84#define CREATE_3D_FLOATS() \
85 GLfloat fx = (GLfloat) x; \
86 GLfloat fy = (GLfloat) y; \
87 GLfloat fz = (GLfloat) z
88
89#define CREATE_4D_FLOATS() \
90 GLfloat fx = (GLfloat) x; \
91 GLfloat fy = (GLfloat) y; \
92 GLfloat fz = (GLfloat) z; \
93 GLfloat fw = (GLfloat) w; \
94 fx /= fw; fy /= fw; fz/= fw
95
96/* For glVertexAttrib4N*ARB */
97#define CREATE_3D_FLOATS_B_NORMALIZED() \
98 GLfloat fx = (GLfloat) x * (1.0 / 128.0); \
99 GLfloat fy = (GLfloat) y * (1.0 / 128.0); \
100 GLfloat fz = (GLfloat) z * (1.0 / 128.0);
101
102#define CREATE_3D_FLOATS_UB_NORMALIZED() \
103 GLfloat fx = (GLfloat) x * (1.0 / 255.0); \
104 GLfloat fy = (GLfloat) y * (1.0 / 255.0); \
105 GLfloat fz = (GLfloat) z * (1.0 / 255.0);
106
107#define CREATE_3D_FLOATS_US_NORMALIZED() \
108 GLfloat fx = (GLfloat) x * (1.0 / 65535.0); \
109 GLfloat fy = (GLfloat) y * (1.0 / 65535.0); \
110 GLfloat fz = (GLfloat) z * (1.0 / 65535.0);
111
112
113#define CREATE_1D_VFLOATS() \
114 GLfloat fx = (GLfloat) v[0];
115
116#define CREATE_2D_VFLOATS() \
117 GLfloat fx = (GLfloat) v[0]; \
118 GLfloat fy = (GLfloat) v[1]
119
120#define CREATE_3D_VFLOATS() \
121 GLfloat fx = (GLfloat) v[0]; \
122 GLfloat fy = (GLfloat) v[1]; \
123 GLfloat fz = (GLfloat) v[2]
124
125#define CREATE_4D_VFLOATS() \
126 GLfloat fx = (GLfloat) v[0]; \
127 GLfloat fy = (GLfloat) v[1]; \
128 GLfloat fz = (GLfloat) v[2]; \
129 GLfloat fw = (GLfloat) v[3]; \
130 fx /= fw; fy /= fw; fz/= fw
131
132/* For glVertexAttrib4N*ARB */
133#define CREATE_4D_FLOATS_UB_NORMALIZED() \
134 GLfloat fx = (GLfloat) (x * (1.0 / 255.0)); \
135 GLfloat fy = (GLfloat) (y * (1.0 / 255.0)); \
136 GLfloat fz = (GLfloat) (z * (1.0 / 255.0)); \
137 GLfloat fw = (GLfloat) (w * (1.0 / 255.0)); \
138 fx /= fw; fy /= fw; fz/= fw
139
140#define CREATE_4D_VFLOATS_B_NORMALIZED() \
141 GLfloat fx = (GLfloat) (v[0] * (1.0 / 128.0)); \
142 GLfloat fy = (GLfloat) (v[1] * (1.0 / 128.0)); \
143 GLfloat fz = (GLfloat) (v[2] * (1.0 / 128.0)); \
144 GLfloat fw = (GLfloat) (v[3] * (1.0 / 128.0)); \
145 fx /= fw; fy /= fw; fz/= fw
146
147#define CREATE_4D_VFLOATS_S_NORMALIZED() \
148 GLfloat fx = (GLfloat) (2.0 * v[0] + 1.0) / ((GLfloat) (0xffff)); \
149 GLfloat fy = (GLfloat) (2.0 * v[1] + 1.0) / ((GLfloat) (0xffff)); \
150 GLfloat fz = (GLfloat) (2.0 * v[2] + 1.0) / ((GLfloat) (0xffff)); \
151 GLfloat fw = (GLfloat) (2.0 * v[3] + 1.0) / ((GLfloat) (0xffff)); \
152 fx /= fw; fy /= fw; fz/= fw
153
154#define CREATE_4D_VFLOATS_I_NORMALIZED() \
155 GLfloat fx = (GLfloat) (2.0 * v[0] + 1.0) / ((GLfloat) (0xffffffff)); \
156 GLfloat fy = (GLfloat) (2.0 * v[1] + 1.0) / ((GLfloat) (0xffffffff)); \
157 GLfloat fz = (GLfloat) (2.0 * v[2] + 1.0) / ((GLfloat) (0xffffffff)); \
158 GLfloat fw = (GLfloat) (2.0 * v[3] + 1.0) / ((GLfloat) (0xffffffff)); \
159 fx /= fw; fy /= fw; fz/= fw
160
161#define CREATE_4D_VFLOATS_UB_NORMALIZED() \
162 GLfloat fx = (GLfloat) (v[0] * (1.0 / 255.0)); \
163 GLfloat fy = (GLfloat) (v[1] * (1.0 / 255.0)); \
164 GLfloat fz = (GLfloat) (v[2] * (1.0 / 255.0)); \
165 GLfloat fw = (GLfloat) (v[3] * (1.0 / 255.0)); \
166 fx /= fw; fy /= fw; fz/= fw
167
168#define CREATE_4D_VFLOATS_US_NORMALIZED() \
169 GLfloat fx = (GLfloat) (v[0] * (1.0 / 65535.0)); \
170 GLfloat fy = (GLfloat) (v[1] * (1.0 / 65535.0)); \
171 GLfloat fz = (GLfloat) (v[2] * (1.0 / 65535.0)); \
172 GLfloat fw = (GLfloat) (v[3] * (1.0 / 65535.0)); \
173 fx /= fw; fy /= fw; fz/= fw
174
175#define CREATE_4D_VFLOATS_UI_NORMALIZED() \
176 GLfloat fx = v[0] / ((GLfloat) (0xffffffff)); \
177 GLfloat fy = v[1] / ((GLfloat) (0xffffffff)); \
178 GLfloat fz = v[2] / ((GLfloat) (0xffffffff)); \
179 GLfloat fw = v[3] / ((GLfloat) (0xffffffff)); \
180 fx /= fw; fy /= fw; fz/= fw
181
182#endif /* CR_PACK_BBOX_H */
183
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette