2
|
1 |
/*
|
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
#include "dxInit.h"
|
|
27 |
#include "ddrawUtils.h"
|
|
28 |
#include "RegistryKey.h"
|
|
29 |
#include "D3DTestRaster.h"
|
|
30 |
#include "WindowsFlags.h"
|
|
31 |
#include "D3DRuntimeTest.h"
|
|
32 |
#include "D3DSurfaceData.h"
|
|
33 |
#include "D3DUtils.h"
|
|
34 |
|
|
35 |
#ifdef DEBUG
|
|
36 |
void TestRasterOutput(byte *rasPtr, int x, int y, int w, int h,
|
|
37 |
int scanStride, int pixelStride,
|
|
38 |
TIntTestRaster goldenArray = NULL);
|
|
39 |
#endif // DEBUG
|
|
40 |
void PrintD3DCaps(int caps);
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Test whether we should enable d3d rendering on this device.
|
|
44 |
* This includes checking whether there were problems creating
|
|
45 |
* the necessary offscreen surface, problems during any of the
|
|
46 |
* rendering calls (Blts and d3d lines) and any rendering artifacts
|
|
47 |
* caused by d3d lines. The rendering artifact tests are
|
|
48 |
* performed by checking a pre-rendered test pattern (produced
|
|
49 |
* by our software renderer) against that same pattern rendered
|
|
50 |
* on this device. If there are any pixels which differ between
|
|
51 |
* the two patterns we disable d3d line rendering on the device.
|
|
52 |
* Differences in the test pattern rendering can be caused
|
|
53 |
* by different rendering algorithms used by our software
|
|
54 |
* renderer and the driver or hardware on this device. For example,
|
|
55 |
* some Intel cards (e.g., i815) are known to use polygon renderers
|
|
56 |
* for their lines, which sometimes result in wide lines.
|
|
57 |
* The test pattern is stored in d3dTestRaster.h, which is generated
|
|
58 |
* by a Java test program
|
|
59 |
* (src/share/test/java2d/VolatileImage/D3DTestPattern/D3DTestPattern.java).
|
|
60 |
*/
|
|
61 |
|
|
62 |
int TestForBadHardware(DxCapabilities *dxCaps)
|
|
63 |
{
|
|
64 |
// Check this device against a list of bad d3d devices and
|
|
65 |
// disable as necessary
|
|
66 |
static WCHAR *badDeviceStrings[] = {
|
|
67 |
L"Trident Video Accelerator",
|
|
68 |
L"RAGE PRO",
|
|
69 |
L"RAGE XL",
|
|
70 |
L"Rage Fury",
|
|
71 |
};
|
|
72 |
static int numBadDevices = 4;
|
|
73 |
WCHAR *dxDeviceName = dxCaps->GetDeviceName();
|
|
74 |
for (int i = 0; i < numBadDevices; ++i) {
|
|
75 |
if (wcsstr(dxDeviceName, badDeviceStrings[i]) != NULL) {
|
|
76 |
// REMIND: For now, we disable d3d for all operations because
|
|
77 |
// of one bad d3d device in the system. This is because we
|
|
78 |
// should avoid registering the d3d rendering loops at the
|
|
79 |
// Java level since we cannot use d3d at the native level.
|
|
80 |
// A real fix would instead understand the difference between
|
|
81 |
// a surface that could handle d3d native rendering and one
|
|
82 |
// that could not and would use the appropriate rendering loop
|
|
83 |
// so that disabling d3d on simply one device would be
|
|
84 |
// sufficient.
|
|
85 |
// Note that this disable-all approach is okay for now because
|
|
86 |
// the single bad device (Trident) that triggers this error
|
|
87 |
// is generally found on laptops, where multiple graphics
|
|
88 |
// devices are not even possible, so disabling d3d for all
|
|
89 |
// devices is equivalent to disabling d3d for this single
|
|
90 |
// device.
|
|
91 |
J2dRlsTraceLn1(J2D_TRACE_ERROR,
|
|
92 |
"TestForBadHardware: Found match: %S. Test FAILED",
|
|
93 |
badDeviceStrings[i]);
|
|
94 |
return J2D_D3D_FAILURE;
|
|
95 |
}
|
|
96 |
}
|
|
97 |
return J2D_D3D_HW_OK;
|
|
98 |
}
|
|
99 |
|
|
100 |
int TestTextureFormats(D3DContext *d3dContext)
|
|
101 |
{
|
|
102 |
int testRes = J2D_D3D_FAILURE;
|
|
103 |
|
|
104 |
D3DTextureTable &table = d3dContext->GetTextureTable();
|
|
105 |
int pfExists;
|
|
106 |
// Check that there's at least one valid pixel format
|
|
107 |
// for each transparency type (opaque, bitmask, translucent)
|
|
108 |
for (int t = TR_OPAQUE_IDX; t < TR_MAX_IDX; t++) {
|
|
109 |
pfExists = FALSE;
|
|
110 |
for (int d = DEPTH16_IDX; d < DEPTH_MAX_IDX; d++) {
|
|
111 |
if (table[t][d].pfType != PF_INVALID) {
|
|
112 |
pfExists = TRUE;
|
|
113 |
break;
|
|
114 |
}
|
|
115 |
}
|
|
116 |
if (pfExists == FALSE) {
|
|
117 |
// couldn't find a pixel formap for this transparency type
|
|
118 |
J2dRlsTraceLn1(J2D_TRACE_ERROR,
|
|
119 |
"D3DTest::TestTextureFormats no texture formats"\
|
|
120 |
" for %d transparency", t);
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
}
|
|
124 |
|
|
125 |
// we must have ARGB texture format (may be used for text rendering)
|
|
126 |
if (pfExists == TRUE &&
|
|
127 |
table[TR_TRANSLUCENT_IDX][DEPTH32_IDX].pfType == PF_INT_ARGB)
|
|
128 |
{
|
|
129 |
testRes |= J2D_D3D_PIXEL_FORMATS_OK;
|
|
130 |
} else {
|
|
131 |
J2dRlsTraceLn1(J2D_TRACE_ERROR,
|
|
132 |
"D3DTest::TestTextureFormats: FAILED pfType=%d",
|
|
133 |
table[TR_TRANSLUCENT_IDX][DEPTH32_IDX].pfType);
|
|
134 |
}
|
|
135 |
return testRes;
|
|
136 |
}
|
|
137 |
|
|
138 |
int TestSetClip(JNIEnv *env, D3DContext *d3dContext,
|
|
139 |
DDrawSurface *lpPlainSurface)
|
|
140 |
{
|
|
141 |
int testRes = J2D_D3D_FAILURE;
|
|
142 |
|
|
143 |
if (SUCCEEDED(d3dContext->SetRenderTarget(lpPlainSurface))) {
|
|
144 |
jobject clip =
|
|
145 |
JNU_CallStaticMethodByName(env, NULL,
|
|
146 |
"sun/java2d/pipe/Region",
|
|
147 |
"getInstanceXYWH",
|
|
148 |
"(IIII)Lsun/java2d/pipe/Region;",
|
|
149 |
0, 0, D3D_TEST_RASTER_W, D3D_TEST_RASTER_H).l;
|
|
150 |
if (!JNU_IsNull(env, clip)) {
|
|
151 |
if (SUCCEEDED(d3dContext->SetClip(env, clip, JNI_TRUE,
|
|
152 |
0, 0,
|
|
153 |
D3D_TEST_RASTER_W,
|
|
154 |
D3D_TEST_RASTER_H)))
|
|
155 |
{
|
|
156 |
testRes |= J2D_D3D_DEPTH_SURFACE_OK;
|
|
157 |
}
|
|
158 |
env->DeleteLocalRef(clip);
|
|
159 |
}
|
|
160 |
}
|
|
161 |
return testRes;
|
|
162 |
}
|
|
163 |
|
|
164 |
int TestRenderingResults(DDrawSurface *lpPlainSurface,
|
|
165 |
TIntTestRaster goldenArray)
|
|
166 |
{
|
|
167 |
// Now, check the results of the test raster against our d3d drawing
|
|
168 |
SurfaceDataRasInfo rasInfo;
|
|
169 |
if (FAILED(lpPlainSurface->Lock(NULL, &rasInfo, DDLOCK_WAIT, NULL))) {
|
|
170 |
return J2D_D3D_FAILURE;
|
|
171 |
}
|
|
172 |
|
|
173 |
byte *rasPtr = (byte*)rasInfo.rasBase;
|
|
174 |
int pixelStride = rasInfo.pixelStride;
|
|
175 |
int scanStride = rasInfo.scanStride;
|
|
176 |
for (int row = 0; row < D3D_TEST_RASTER_H; ++row) {
|
|
177 |
byte *tmpRasPtr = rasPtr + row * scanStride;
|
|
178 |
for (int col = 0; col < D3D_TEST_RASTER_W; ++col) {
|
|
179 |
DWORD pixelVal;
|
|
180 |
switch (pixelStride) {
|
|
181 |
case 1:
|
|
182 |
pixelVal = *tmpRasPtr;
|
|
183 |
break;
|
|
184 |
case 2:
|
|
185 |
pixelVal = *((unsigned short*)tmpRasPtr);
|
|
186 |
break;
|
|
187 |
default:
|
|
188 |
pixelVal = *((unsigned int*)tmpRasPtr);
|
|
189 |
break;
|
|
190 |
}
|
|
191 |
tmpRasPtr += pixelStride;
|
|
192 |
// The test is simple: if the test raster pixel has value 0, then
|
|
193 |
// we expect 0 in the d3d surface. If the test raster has a nonzero
|
|
194 |
// value, then we expect the d3d surface to also have non-zero value.
|
|
195 |
// All other results represent failure.
|
|
196 |
int goldenValue = (goldenArray[row][col] & 0x00ffffff);
|
|
197 |
if ((goldenValue == 0 && pixelVal != 0) ||
|
|
198 |
(goldenValue != 0 && pixelVal == 0))
|
|
199 |
{
|
|
200 |
J2dRlsTraceLn3(J2D_TRACE_WARNING,
|
|
201 |
"TestRenderingResults: Quality test failed due "\
|
|
202 |
"to value %x at (%d, %d)", pixelVal, col, row);
|
|
203 |
#ifdef DEBUG
|
|
204 |
// This section is not necessary, but it might be
|
|
205 |
// nice to know why we are failing D3DTest on some
|
|
206 |
// systems. If tracing is enabled, this section will
|
|
207 |
// produce an ascii representation of the test pattern,
|
|
208 |
// the result on this device, and the pixels that were
|
|
209 |
// in error.
|
|
210 |
J2dTraceLn(J2D_TRACE_VERBOSE, "TestRaster:");
|
|
211 |
TestRasterOutput((byte*)goldenArray, 0, 0, D3D_TEST_RASTER_W,
|
|
212 |
D3D_TEST_RASTER_H, D3D_TEST_RASTER_W*4, 4);
|
|
213 |
J2dTraceLn(J2D_TRACE_VERBOSE, "D3D Raster:");
|
|
214 |
TestRasterOutput(rasPtr, 0, 0, D3D_TEST_RASTER_W,
|
|
215 |
D3D_TEST_RASTER_H, scanStride, pixelStride);
|
|
216 |
J2dTraceLn(J2D_TRACE_VERBOSE, "Deltas (x indicates problem pixel):");
|
|
217 |
TestRasterOutput(rasPtr, 0, 0, D3D_TEST_RASTER_W,
|
|
218 |
D3D_TEST_RASTER_H, scanStride, pixelStride,
|
|
219 |
goldenArray);
|
|
220 |
#endif // DEBUG
|
|
221 |
lpPlainSurface->Unlock(NULL);
|
|
222 |
return J2D_D3D_FAILURE;
|
|
223 |
}
|
|
224 |
}
|
|
225 |
}
|
|
226 |
|
|
227 |
lpPlainSurface->Unlock(NULL);
|
|
228 |
return (J2D_D3D_LINES_OK | J2D_D3D_LINE_CLIPPING_OK);
|
|
229 |
}
|
|
230 |
|
|
231 |
int TestLineRenderingQuality(JNIEnv *env, D3DContext *d3dContext,
|
|
232 |
DDrawSurface *lpPlainSurface)
|
|
233 |
{
|
|
234 |
static J2D_XY_C_VERTEX lineVerts[] = {
|
|
235 |
#ifdef USE_SINGLE_VERTEX_FORMAT
|
|
236 |
{ 0, 0, 0, 0xffffffff, 0.0f, 0.0f },
|
|
237 |
{ 0, 0, 0, 0xffffffff, 0.0f, 0.0f },
|
|
238 |
{ 0, 0, 0, 0xffffffff, 0.0f, 0.0f },
|
|
239 |
{ 0, 0, 0, 0xffffffff, 0.0f, 0.0f },
|
|
240 |
{ 0, 0, 0, 0xffffffff, 0.0f, 0.0f },
|
|
241 |
#else
|
|
242 |
{ 0, 0, 0, 0xffffffff }, // x, y, z, color
|
|
243 |
{ 0, 0, 0, 0xffffffff },
|
|
244 |
{ 0, 0, 0, 0xffffffff },
|
|
245 |
{ 0, 0, 0, 0xffffffff },
|
|
246 |
{ 0, 0, 0, 0xffffffff },
|
|
247 |
#endif // USE_SINGLE_VERTEX_FORMAT
|
|
248 |
};
|
|
249 |
IDirect3DDevice7 *d3dDevice = d3dContext->Get3DDevice();
|
|
250 |
HRESULT res;
|
|
251 |
|
|
252 |
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0x0, 0.0, 0);
|
|
253 |
|
|
254 |
if (FAILED(d3dContext->BeginScene(STATE_RENDEROP))) {
|
|
255 |
return J2D_D3D_FAILURE;
|
|
256 |
}
|
|
257 |
|
|
258 |
int i;
|
|
259 |
|
|
260 |
for (i = 0; i < d3dNumTestLines * 4; i += 4) {
|
|
261 |
lineVerts[0].x = d3dTestLines[i + 0];
|
|
262 |
lineVerts[0].y = d3dTestLines[i + 1];
|
|
263 |
lineVerts[1].x = d3dTestLines[i + 2];
|
|
264 |
lineVerts[1].y = d3dTestLines[i + 3];
|
|
265 |
if (FAILED(res = d3dDevice->DrawPrimitive(D3DPT_LINESTRIP,
|
|
266 |
D3DFVF_J2D_XY_C,
|
|
267 |
lineVerts, 2, 0)))
|
|
268 |
{
|
|
269 |
d3dContext->ForceEndScene();
|
|
270 |
return J2D_D3D_FAILURE;
|
|
271 |
}
|
|
272 |
// REMIND: needed for the test to pass on ATI some boards
|
|
273 |
d3dDevice->DrawPrimitive(D3DPT_POINTLIST, D3DFVF_J2D_XY_C,
|
|
274 |
&(lineVerts[1]), 1, 0);
|
|
275 |
}
|
|
276 |
|
|
277 |
for (i = 0; i < d3dNumTestRects * 4; i += 4) {
|
|
278 |
float x1 = d3dTestRects[i + 0];
|
|
279 |
float y1 = d3dTestRects[i + 1];
|
|
280 |
float x2 = d3dTestRects[i + 2];
|
|
281 |
float y2 = d3dTestRects[i + 3];
|
|
282 |
D3DU_INIT_VERTEX_PENT_XY(lineVerts, x1, y1, x2, y2);
|
|
283 |
if (FAILED(res = d3dDevice->DrawPrimitive(D3DPT_LINESTRIP,
|
|
284 |
D3DFVF_J2D_XY_C,
|
|
285 |
lineVerts, 5, 0)))
|
|
286 |
{
|
|
287 |
d3dContext->ForceEndScene();
|
|
288 |
return J2D_D3D_FAILURE;
|
|
289 |
}
|
|
290 |
}
|
|
291 |
d3dContext->ForceEndScene();
|
|
292 |
|
|
293 |
// REMIND: add rendering of clipped lines
|
|
294 |
|
|
295 |
return TestRenderingResults(lpPlainSurface, d3dTestRaster);
|
|
296 |
}
|
|
297 |
|
|
298 |
int TestTextureMappingQuality(JNIEnv *env, DDraw *ddObject,
|
|
299 |
D3DContext *d3dContext,
|
|
300 |
DDrawSurface *lpPlainSurface)
|
|
301 |
{
|
|
302 |
static J2DLVERTEX quadVerts[4] = {
|
|
303 |
{ 0.0f, 0.0f, 0.0f, 0xffffffff, 0.0f, 0.0f },
|
|
304 |
{ 0.0f, 0.0f, 0.0f, 0xffffffff, 0.0f, 0.0f },
|
|
305 |
{ 0.0f, 0.0f, 0.0f, 0xffffffff, 0.0f, 0.0f },
|
|
306 |
{ 0.0f, 0.0f, 0.0f, 0xffffffff, 0.0f, 0.0f }
|
|
307 |
};
|
|
308 |
|
|
309 |
int testRes = TestTextureFormats(d3dContext);
|
|
310 |
|
|
311 |
if (testRes & J2D_D3D_PIXEL_FORMATS_OK) {
|
|
312 |
|
|
313 |
DDrawSurface *lpTexture =
|
|
314 |
D3DUtils_CreateTexture(env, ddObject, d3dContext, TR_TRANSLUCENT,
|
|
315 |
D3D_TEXTURE_RASTER_W, D3D_TEXTURE_RASTER_H);
|
|
316 |
if (lpTexture) {
|
|
317 |
D3DUtils_UploadIntImageToXRGBTexture(lpTexture,
|
|
318 |
(int *)srcImageArray,
|
|
319 |
D3D_TEXTURE_RASTER_W,
|
|
320 |
D3D_TEXTURE_RASTER_H);
|
|
321 |
|
|
322 |
float u2 = ((float)D3D_TEXTURE_RASTER_W) /
|
|
323 |
(float)lpTexture->GetDXSurface()->GetWidth();
|
|
324 |
float v2 = ((float)D3D_TEXTURE_RASTER_H) /
|
|
325 |
(float)lpTexture->GetDXSurface()->GetHeight();
|
|
326 |
D3DU_INIT_VERTEX_QUAD_UV(quadVerts, 0.0f, 0.0f, u2, v2);
|
|
327 |
|
|
328 |
IDirect3DDevice7 *d3dDevice = d3dContext->Get3DDevice();
|
|
329 |
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 0.0, 0);
|
|
330 |
|
|
331 |
d3dContext->SetAlphaComposite(3/*SrcOver*/,
|
|
332 |
1.0f, D3DC_NO_CONTEXT_FLAGS);
|
|
333 |
d3dDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTFG_POINT);
|
|
334 |
d3dDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTFG_POINT);
|
|
335 |
|
|
336 |
HRESULT res;
|
|
337 |
if (SUCCEEDED(res = d3dContext->BeginScene(STATE_BLITOP))) {
|
|
338 |
DXSurface *dxSurface = lpTexture->GetDXSurface();
|
|
339 |
if (SUCCEEDED(d3dContext->SetTexture(dxSurface))) {
|
|
340 |
for (int i = 0; i < d3dNumTextureRects * 4; i += 4) {
|
|
341 |
float x1 = d3dTextureRects[i + 0];
|
|
342 |
float y1 = d3dTextureRects[i + 1];
|
|
343 |
float x2 = d3dTextureRects[i + 2];
|
|
344 |
float y2 = d3dTextureRects[i + 3];
|
|
345 |
D3DU_INIT_VERTEX_QUAD_XY(quadVerts, x1, y1, x2, y2);
|
|
346 |
d3dDevice->DrawPrimitive(D3DPT_TRIANGLEFAN,
|
|
347 |
D3DFVF_J2DLVERTEX,
|
|
348 |
quadVerts, 4, 0);
|
|
349 |
}
|
|
350 |
}
|
|
351 |
res = d3dContext->ForceEndScene();
|
|
352 |
d3dContext->SetTexture(NULL);
|
|
353 |
}
|
|
354 |
// REMIND: at this point we ignore the results of
|
|
355 |
// the test.
|
|
356 |
TestRenderingResults(lpPlainSurface, linInterpArray);
|
|
357 |
if (SUCCEEDED(res)) {
|
|
358 |
testRes |= (J2D_D3D_TR_TEXTURE_SURFACE_OK |
|
|
359 |
J2D_D3D_TEXTURE_BLIT_OK |
|
|
360 |
J2D_D3D_TEXTURE_TRANSFORM_OK);
|
|
361 |
|
|
362 |
// REMIND: add tests for opaque and bitmask textures
|
|
363 |
testRes |= (J2D_D3D_OP_TEXTURE_SURFACE_OK |
|
|
364 |
J2D_D3D_BM_TEXTURE_SURFACE_OK);
|
|
365 |
}
|
|
366 |
delete lpTexture;
|
|
367 |
} else {
|
|
368 |
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
369 |
"TestTextureMappingQuality: "\
|
|
370 |
"CreateTexture(TRANSLUCENT) FAILED");
|
|
371 |
}
|
|
372 |
}
|
|
373 |
return testRes;
|
|
374 |
}
|
|
375 |
|
|
376 |
int TestD3DDevice(DDraw *ddObject,
|
|
377 |
D3DContext *d3dContext,
|
|
378 |
DxCapabilities *dxCaps)
|
|
379 |
{
|
|
380 |
int testRes = TestForBadHardware(dxCaps);
|
|
381 |
if (!(testRes & J2D_D3D_HW_OK) || !d3dContext) {
|
|
382 |
return testRes;
|
|
383 |
}
|
|
384 |
|
|
385 |
D3DDEVICEDESC7 d3dDevDesc;
|
|
386 |
IDirect3DDevice7 *d3dDevice = d3dContext->Get3DDevice();
|
|
387 |
if (d3dDevice == NULL ||
|
|
388 |
FAILED(d3dDevice->GetCaps(&d3dDevDesc)) ||
|
|
389 |
FAILED(D3DUtils_CheckDeviceCaps(&d3dDevDesc)))
|
|
390 |
{
|
|
391 |
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
392 |
"TestD3DDevice: device caps testing FAILED");
|
|
393 |
return testRes;
|
|
394 |
}
|
|
395 |
testRes |= J2D_D3D_DEVICE_OK;
|
|
396 |
|
|
397 |
JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
|
398 |
DDrawSurface *lpPlainSurface =
|
|
399 |
D3DUtils_CreatePlainSurface(env, ddObject, d3dContext,
|
|
400 |
D3D_TEST_RASTER_W, D3D_TEST_RASTER_H);
|
|
401 |
if (!lpPlainSurface) {
|
|
402 |
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
403 |
"TestD3DDevice: CreatePlainSurface FAILED");
|
|
404 |
return testRes;
|
|
405 |
}
|
|
406 |
testRes |= J2D_D3D_PLAIN_SURFACE_OK;
|
|
407 |
|
|
408 |
// Set identity transform
|
|
409 |
if (FAILED(d3dContext->SetTransform(NULL, 0, 0, 0, 0, 0, 0))) {
|
|
410 |
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
411 |
"TestD3DDevice: SetTransform FAILED");
|
|
412 |
delete lpPlainSurface;
|
|
413 |
return testRes;
|
|
414 |
}
|
|
415 |
testRes |= J2D_D3D_SET_TRANSFORM_OK;
|
|
416 |
|
|
417 |
// Test setting the target surface, create depth buffer, and
|
|
418 |
// clip
|
|
419 |
testRes |= TestSetClip(env, d3dContext, lpPlainSurface);
|
|
420 |
if (!(testRes & J2D_D3D_DEPTH_SURFACE_OK)) {
|
|
421 |
J2dRlsTraceLn(J2D_TRACE_ERROR, "TestD3DDevice: SetClip FAILED");
|
|
422 |
delete lpPlainSurface;
|
|
423 |
return testRes;
|
|
424 |
}
|
|
425 |
|
|
426 |
// Test drawLines
|
|
427 |
testRes |= TestLineRenderingQuality(env, d3dContext, lpPlainSurface);
|
|
428 |
|
|
429 |
// Test texture mapping
|
|
430 |
testRes |= TestTextureMappingQuality(env, ddObject, d3dContext,
|
|
431 |
lpPlainSurface);
|
|
432 |
|
|
433 |
d3dContext->SetRenderTarget(NULL);
|
|
434 |
|
|
435 |
delete lpPlainSurface;
|
|
436 |
return testRes;
|
|
437 |
}
|
|
438 |
|
|
439 |
#ifdef DEBUG
|
|
440 |
/**
|
|
441 |
* Output test raster (produced in D3DTest function). Utility
|
|
442 |
* used in debugging only. Enable by setting J2D_TRACE_LEVEL=J2D_VERBOSE
|
|
443 |
* prior to running application with debug java. The output from this will
|
|
444 |
* be seen only if D3DTest fails.
|
|
445 |
*/
|
|
446 |
void TestRasterOutput(byte *rasPtr, int x, int y, int w, int h,
|
|
447 |
int scanStride, int pixelStride,
|
|
448 |
TIntTestRaster goldenArray)
|
|
449 |
{
|
|
450 |
int goldenValue;
|
|
451 |
for (int traceRow = y; traceRow < h; ++traceRow) {
|
|
452 |
byte *tmpRasPtr = rasPtr + traceRow * scanStride;
|
|
453 |
for (int traceCol = x; traceCol < w; ++traceCol) {
|
|
454 |
DWORD pixelVal;
|
|
455 |
switch (pixelStride) {
|
|
456 |
case 1:
|
|
457 |
pixelVal = *tmpRasPtr;
|
|
458 |
break;
|
|
459 |
case 2:
|
|
460 |
pixelVal = *((unsigned short*)tmpRasPtr);
|
|
461 |
break;
|
|
462 |
default:
|
|
463 |
pixelVal = *((unsigned int*)tmpRasPtr) & 0x00ffffff;
|
|
464 |
break;
|
|
465 |
}
|
|
466 |
tmpRasPtr += pixelStride;
|
|
467 |
if (goldenArray == NULL) {
|
|
468 |
if (pixelVal) {
|
|
469 |
J2dTrace(J2D_TRACE_VERBOSE, "1");
|
|
470 |
} else {
|
|
471 |
J2dTrace(J2D_TRACE_VERBOSE, "0");
|
|
472 |
}
|
|
473 |
} else {
|
|
474 |
goldenValue = (goldenArray[traceRow][traceCol] & 0x00ffffff);
|
|
475 |
if ((goldenValue == 0 && pixelVal != 0) ||
|
|
476 |
(goldenValue != 0 && pixelVal == 0))
|
|
477 |
{
|
|
478 |
J2dTrace(J2D_TRACE_VERBOSE, "x");
|
|
479 |
} else {
|
|
480 |
J2dTrace(J2D_TRACE_VERBOSE, "-");
|
|
481 |
}
|
|
482 |
}
|
|
483 |
|
|
484 |
}
|
|
485 |
J2dTrace(J2D_TRACE_VERBOSE, "\n");
|
|
486 |
}
|
|
487 |
}
|
|
488 |
#endif // DEBUG
|
|
489 |
|
|
490 |
void PrintD3DCaps(int caps)
|
|
491 |
{
|
|
492 |
J2dTraceLn(J2D_TRACE_VERBOSE, "{")
|
|
493 |
if (caps == J2D_D3D_FAILURE) {
|
|
494 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_FAILURE");
|
|
495 |
} else {
|
|
496 |
if (caps & J2D_D3D_DEPTH_SURFACE_OK) {
|
|
497 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_DEPTH_SURFACE_OK,");
|
|
498 |
}
|
|
499 |
if (caps & J2D_D3D_PLAIN_SURFACE_OK) {
|
|
500 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_PLAIN_SURFACE_OK,");
|
|
501 |
}
|
|
502 |
if (caps & J2D_D3D_OP_TEXTURE_SURFACE_OK) {
|
|
503 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_OP_TEXTURE_SURFACE_OK,");
|
|
504 |
}
|
|
505 |
if (caps & J2D_D3D_BM_TEXTURE_SURFACE_OK) {
|
|
506 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_BM_TEXTURE_SURFACE_OK,");
|
|
507 |
}
|
|
508 |
if (caps & J2D_D3D_TR_TEXTURE_SURFACE_OK) {
|
|
509 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_TR_TEXTURE_SURFACE_OK,");
|
|
510 |
}
|
|
511 |
if (caps & J2D_D3D_OP_RTT_SURFACE_OK) {
|
|
512 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_OP_RTT_SURFACE_OK,");
|
|
513 |
}
|
|
514 |
if (caps & J2D_D3D_LINE_CLIPPING_OK) {
|
|
515 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_LINE_CLIPPING_OK,");
|
|
516 |
}
|
|
517 |
if (caps & J2D_D3D_LINES_OK) {
|
|
518 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_LINES_OK,");
|
|
519 |
}
|
|
520 |
if (caps & J2D_D3D_TEXTURE_BLIT_OK) {
|
|
521 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_TEXTURE_BLIT_OK,");
|
|
522 |
}
|
|
523 |
if (caps & J2D_D3D_TEXTURE_TRANSFORM_OK) {
|
|
524 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_TEXTURE_TRANSFORM_OK,");
|
|
525 |
}
|
|
526 |
if (caps & J2D_D3D_DEVICE_OK) {
|
|
527 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_DEVICE_OK,");
|
|
528 |
}
|
|
529 |
if (caps & J2D_D3D_PIXEL_FORMATS_OK) {
|
|
530 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_SET_TRANSFORM_OK,");
|
|
531 |
}
|
|
532 |
if (caps & J2D_D3D_HW_OK) {
|
|
533 |
J2dTraceLn(J2D_TRACE_VERBOSE, " J2D_D3D_HW_OK,");
|
|
534 |
}
|
|
535 |
}
|
|
536 |
J2dTraceLn(J2D_TRACE_VERBOSE, "}");
|
|
537 |
}
|