2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 #include "device9ex.h"
25 #include "nine_helpers.h"
26 #include "nine_defines.h"
27 #include "nine_pipe.h"
28 #include "nine_dump.h"
29 #include "util/u_math.h"
30 #include "util/u_format.h"
31 #include "util/u_dump.h"
33 #include "pipe/p_screen.h"
35 #define DBG_CHANNEL DBG_ADAPTER
38 NineAdapter9_ctor( struct NineAdapter9
*This
,
39 struct NineUnknownParams
*pParams
,
40 struct d3dadapter9_context
*pCTX
)
42 struct pipe_screen
*hal
= pCTX
->hal
;
43 HRESULT hr
= NineUnknown_ctor(&This
->base
, pParams
);
44 if (FAILED(hr
)) { return hr
; }
46 DBG("This=%p pParams=%p pCTX=%p\n", This
, pParams
, pCTX
);
47 nine_dump_D3DADAPTER_IDENTIFIER9(DBG_CHANNEL
, &pCTX
->identifier
);
50 if (!hal
->get_param(hal
, PIPE_CAP_CLIP_HALFZ
)) {
51 ERR("Driver doesn't support d3d9 coordinates\n");
52 return D3DERR_DRIVERINTERNALERROR
;
55 !This
->ctx
->ref
->get_param(This
->ctx
->ref
, PIPE_CAP_CLIP_HALFZ
)) {
56 ERR("Warning: Sotware rendering driver doesn't support d3d9 coordinates\n");
58 /* Old cards had tricks to bypass some restrictions to implement
59 * everything and fit tight the requirements: number of constants,
60 * number of temp registers, special behaviours, etc. Since we don't
61 * have access to all this, we need a bit more than what dx9 required.
62 * For example we have to use more than 32 temp registers to emulate
63 * behaviours, while some dx9 hw don't have more. As for sm2 hardware,
64 * we could support vs2 / ps2 for them but it needs some more care, and
65 * as these are very old, we choose to drop support for them */
67 /* checks minimum requirements, most are vs3/ps3 strict requirements */
68 if (!hal
->get_param(hal
, PIPE_CAP_SM3
) ||
69 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
70 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 256 * sizeof(float[4]) ||
71 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
72 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 244 * sizeof(float[4]) ||
73 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
74 PIPE_SHADER_CAP_MAX_TEMPS
) < 32 ||
75 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
76 PIPE_SHADER_CAP_MAX_TEMPS
) < 32 ||
77 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
78 PIPE_SHADER_CAP_MAX_INPUTS
) < 16 ||
79 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
80 PIPE_SHADER_CAP_MAX_INPUTS
) < 10) {
81 ERR("Your card is not supported by Gallium Nine. Minimum requirement "
82 "is >= r500, >= nv50, >= i965\n");
83 return D3DERR_DRIVERINTERNALERROR
;
86 if (hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
87 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 276 * sizeof(float[4]) || /* we put bool and int constants with float constants */
88 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
89 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 || /* we use some more temp registers */
90 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
91 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 ||
92 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
93 PIPE_SHADER_CAP_MAX_INPUTS
) < 20) /* we don't pack inputs as much as we could */
94 ERR("Your card is at the limit of Gallium Nine requirements. Some games "
95 "may run into issues because requirements are too tight\n");
100 NineAdapter9_dtor( struct NineAdapter9
*This
)
102 struct d3dadapter9_context
*ctx
= This
->ctx
;
104 DBG("This=%p\n", This
);
106 NineUnknown_dtor(&This
->base
);
108 /* special case, call backend-specific dtor AFTER destroying this object
111 if (ctx
->destroy
) { ctx
->destroy(ctx
); }
116 NineAdapter9_GetScreen( struct NineAdapter9
*This
,
118 struct pipe_screen
**ppScreen
)
120 const char *force_sw
= getenv("D3D_ALWAYS_SOFTWARE");
123 if (force_sw
&& !strcmp(force_sw
, "1") && This
->ctx
->ref
) {
124 *ppScreen
= This
->ctx
->ref
;
127 *ppScreen
= This
->ctx
->hal
;
131 case D3DDEVTYPE_NULLREF
:
133 if (force_sw
&& !strcmp(force_sw
, "0")) {
134 *ppScreen
= This
->ctx
->hal
;
137 *ppScreen
= This
->ctx
->ref
;
141 user_assert(!"Invalid device type", D3DERR_INVALIDCALL
);
144 if (!*ppScreen
) { return D3DERR_NOTAVAILABLE
; }
150 NineAdapter9_GetAdapterIdentifier( struct NineAdapter9
*This
,
152 D3DADAPTER_IDENTIFIER9
*pIdentifier
)
154 DBG("This=%p Flags=%x pIdentifier=%p\n", This
, Flags
, pIdentifier
);
156 /* regarding flags, MSDN has this to say:
157 * Flags sets the WHQLLevel member of D3DADAPTER_IDENTIFIER9. Flags can be
158 * set to either 0 or D3DENUM_WHQL_LEVEL. If D3DENUM_WHQL_LEVEL is
159 * specified, this call can connect to the Internet to download new
160 * Microsoft Windows Hardware Quality Labs (WHQL) certificates.
161 * so let's just ignore it. */
162 *pIdentifier
= This
->ctx
->identifier
;
166 static inline boolean
167 backbuffer_format( D3DFORMAT dfmt
,
171 if (dfmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
173 if ((dfmt
== D3DFMT_A2R10G10B10
&& bfmt
== dfmt
) ||
174 (dfmt
== D3DFMT_X8R8G8B8
&& (bfmt
== dfmt
||
175 bfmt
== D3DFMT_A8R8G8B8
)) ||
176 (dfmt
== D3DFMT_X1R5G5B5
&& (bfmt
== dfmt
||
177 bfmt
== D3DFMT_A1R5G5B5
)) ||
178 (dfmt
== D3DFMT_R5G6B5
&& bfmt
== dfmt
)) {
186 NineAdapter9_CheckDeviceType( struct NineAdapter9
*This
,
188 D3DFORMAT AdapterFormat
,
189 D3DFORMAT BackBufferFormat
,
192 struct pipe_screen
*screen
;
193 enum pipe_format dfmt
, bfmt
;
196 DBG("This=%p DevType=%s AdapterFormat=%s BackBufferFormat=%s "
197 "bWindowed=%i\n", This
, nine_D3DDEVTYPE_to_str(DevType
),
198 d3dformat_to_string(AdapterFormat
),
199 d3dformat_to_string(BackBufferFormat
), bWindowed
);
201 user_assert(backbuffer_format(AdapterFormat
, BackBufferFormat
, bWindowed
),
202 D3DERR_NOTAVAILABLE
);
204 hr
= NineAdapter9_GetScreen(This
, DevType
, &screen
);
205 if (FAILED(hr
)) { return hr
; }
207 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
,
209 PIPE_BIND_DISPLAY_TARGET
|
210 PIPE_BIND_SHARED
, FALSE
, FALSE
);
211 bfmt
= d3d9_to_pipe_format_checked(screen
, BackBufferFormat
, PIPE_TEXTURE_2D
,
213 PIPE_BIND_DISPLAY_TARGET
|
214 PIPE_BIND_SHARED
, FALSE
, FALSE
);
215 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
216 DBG("Unsupported Adapter/BackBufferFormat.\n");
217 return D3DERR_NOTAVAILABLE
;
223 static inline boolean
224 display_format( D3DFORMAT fmt
,
227 /* http://msdn.microsoft.com/en-us/library/bb172558(v=VS.85).aspx#BackBuffer_or_Display_Formats */
228 static const D3DFORMAT allowed
[] = {
236 if (fmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
238 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
239 if (fmt
== allowed
[i
]) { return TRUE
; }
245 NineAdapter9_CheckDeviceFormat( struct NineAdapter9
*This
,
246 D3DDEVTYPE DeviceType
,
247 D3DFORMAT AdapterFormat
,
249 D3DRESOURCETYPE RType
,
250 D3DFORMAT CheckFormat
)
252 struct pipe_screen
*screen
;
255 enum pipe_texture_target target
;
259 /* Check adapter format. */
261 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This
,
262 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
));
263 DBG("Usage=%x RType=%u CheckFormat=%s\n", Usage
, RType
,
264 d3dformat_to_string(CheckFormat
));
266 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_INVALIDCALL
);
268 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
271 pf
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
272 PIPE_BIND_DISPLAY_TARGET
|
273 PIPE_BIND_SHARED
, FALSE
, FALSE
);
274 if (pf
== PIPE_FORMAT_NONE
) {
275 DBG("AdapterFormat %s not available.\n",
276 d3dformat_to_string(AdapterFormat
));
277 return D3DERR_NOTAVAILABLE
;
280 /* Check actual format. */
283 case D3DRTYPE_SURFACE
: target
= PIPE_TEXTURE_2D
; break;
284 case D3DRTYPE_TEXTURE
: target
= PIPE_TEXTURE_2D
; break;
285 case D3DRTYPE_CUBETEXTURE
: target
= PIPE_TEXTURE_CUBE
; break;
286 case D3DRTYPE_VOLUME
: target
= PIPE_TEXTURE_3D
; break;
287 case D3DRTYPE_VOLUMETEXTURE
: target
= PIPE_TEXTURE_3D
; break;
288 case D3DRTYPE_VERTEXBUFFER
: target
= PIPE_BUFFER
; break;
289 case D3DRTYPE_INDEXBUFFER
: target
= PIPE_BUFFER
; break;
291 user_assert(0, D3DERR_INVALIDCALL
);
295 if (Usage
& D3DUSAGE_RENDERTARGET
) bind
|= PIPE_BIND_RENDER_TARGET
;
296 if (Usage
& D3DUSAGE_DEPTHSTENCIL
) bind
|= PIPE_BIND_DEPTH_STENCIL
;
298 /* API hack because setting RT[0] to NULL is forbidden */
299 if (CheckFormat
== D3DFMT_NULL
&& bind
== PIPE_BIND_RENDER_TARGET
&&
300 (RType
== D3DRTYPE_SURFACE
||
301 RType
== D3DRTYPE_TEXTURE
))
305 if (CheckFormat
== D3DFMT_RESZ
&& bind
== PIPE_BIND_RENDER_TARGET
&&
306 RType
== D3DRTYPE_SURFACE
)
307 return screen
->get_param(screen
, PIPE_CAP_MULTISAMPLE_Z_RESOLVE
) ?
308 D3D_OK
: D3DERR_NOTAVAILABLE
;
311 if (CheckFormat
== D3DFMT_ATOC
&& RType
== D3DRTYPE_SURFACE
)
314 if ((Usage
& D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
) &&
315 (Usage
& D3DUSAGE_RENDERTARGET
))
316 bind
|= PIPE_BIND_BLENDABLE
;
318 if (Usage
& D3DUSAGE_DMAP
) {
319 DBG("D3DUSAGE_DMAP not available\n");
320 return D3DERR_NOTAVAILABLE
; /* TODO: displacement mapping */
324 case D3DRTYPE_TEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
325 case D3DRTYPE_CUBETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
326 case D3DRTYPE_VOLUMETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
327 case D3DRTYPE_VERTEXBUFFER
: bind
|= PIPE_BIND_VERTEX_BUFFER
; break;
328 case D3DRTYPE_INDEXBUFFER
: bind
|= PIPE_BIND_INDEX_BUFFER
; break;
329 case D3DRTYPE_SURFACE
:
330 if (!(Usage
& D3DUSAGE_DEPTHSTENCIL
))
331 bind
|= PIPE_BIND_SAMPLER_VIEW
; /* StretchRect */
332 /* Offscreen surface support: Usage = 0.
333 * In practice drivers are very restrictive on the formats supported.
334 * Basically a few common formats + YUV and compressed formats. The
335 * reason is that offscreen surface are useful only for directdraw
336 * compatibility (a WONTIMPL of nine) + format conversion (useful in
337 * particular for YUV because the format was not advertised for textures
340 bind
|= PIPE_BIND_RENDER_TARGET
; /* A current requirement of our impl, which we should get rid of. */
346 srgb
= (Usage
& (D3DUSAGE_QUERY_SRGBREAD
| D3DUSAGE_QUERY_SRGBWRITE
)) != 0;
347 pf
= d3d9_to_pipe_format_checked(screen
, CheckFormat
, target
,
348 0, bind
, srgb
, FALSE
);
349 if (pf
== PIPE_FORMAT_NONE
) {
350 DBG("NOT AVAILABLE\n");
351 return D3DERR_NOTAVAILABLE
;
354 /* we support ATI1 and ATI2 hack only for 2D and Cube textures */
355 if (RType
!= D3DRTYPE_TEXTURE
&& RType
!= D3DRTYPE_CUBETEXTURE
&&
356 (CheckFormat
== D3DFMT_ATI1
|| CheckFormat
== D3DFMT_ATI2
))
357 return D3DERR_NOTAVAILABLE
;
358 /* if (Usage & D3DUSAGE_NONSECURE) { don't know the implications of this } */
359 /* if (Usage & D3DUSAGE_SOFTWAREPROCESSING) { we can always support this } */
361 if ((Usage
& D3DUSAGE_AUTOGENMIPMAP
) && !(bind
& PIPE_BIND_SAMPLER_VIEW
))
362 return D3DOK_NOAUTOGEN
;
367 NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9
*This
,
368 D3DDEVTYPE DeviceType
,
369 D3DFORMAT SurfaceFormat
,
371 D3DMULTISAMPLE_TYPE MultiSampleType
,
372 DWORD
*pQualityLevels
)
374 struct pipe_screen
*screen
;
379 DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
380 "pQualityLevels=%p\n", This
, nine_D3DDEVTYPE_to_str(DeviceType
),
381 d3dformat_to_string(SurfaceFormat
), Windowed
, MultiSampleType
,
384 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
388 if (depth_stencil_format(SurfaceFormat
))
389 bind
= d3d9_get_pipe_depth_format_bindings(SurfaceFormat
);
390 else /* render-target */
391 bind
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
393 pf
= d3d9_to_pipe_format_checked(screen
, SurfaceFormat
, PIPE_TEXTURE_2D
,
394 MultiSampleType
, bind
, FALSE
, FALSE
);
396 if (pf
== PIPE_FORMAT_NONE
) {
397 DBG("%s with %u samples not available.\n",
398 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
399 return D3DERR_NOTAVAILABLE
;
403 *pQualityLevels
= 1; /* gallium doesn't have quality levels */
409 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
410 D3DDEVTYPE DeviceType
,
411 D3DFORMAT AdapterFormat
,
412 D3DFORMAT RenderTargetFormat
,
413 D3DFORMAT DepthStencilFormat
)
415 struct pipe_screen
*screen
;
416 enum pipe_format dfmt
, bfmt
, zsfmt
;
419 DBG("This=%p DeviceType=%s AdapterFormat=%s "
420 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
421 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
422 d3dformat_to_string(RenderTargetFormat
),
423 d3dformat_to_string(DepthStencilFormat
));
425 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
426 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
428 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
429 if (FAILED(hr
)) { return hr
; }
431 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
432 PIPE_BIND_DISPLAY_TARGET
|
433 PIPE_BIND_SHARED
, FALSE
, FALSE
);
434 bfmt
= d3d9_to_pipe_format_checked(screen
, RenderTargetFormat
,
436 PIPE_BIND_RENDER_TARGET
, FALSE
, FALSE
);
437 if (RenderTargetFormat
== D3DFMT_NULL
)
439 zsfmt
= d3d9_to_pipe_format_checked(screen
, DepthStencilFormat
,
441 d3d9_get_pipe_depth_format_bindings(DepthStencilFormat
),
443 if (dfmt
== PIPE_FORMAT_NONE
||
444 bfmt
== PIPE_FORMAT_NONE
||
445 zsfmt
== PIPE_FORMAT_NONE
) {
446 return D3DERR_NOTAVAILABLE
;
453 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
454 D3DDEVTYPE DeviceType
,
455 D3DFORMAT SourceFormat
,
456 D3DFORMAT TargetFormat
)
458 /* MSDN says this tests whether a certain backbuffer format can be used in
459 * conjunction with a certain front buffer format. It's a little confusing
460 * but some one wiser might be able to figure this one out. XXX */
461 struct pipe_screen
*screen
;
462 enum pipe_format dfmt
, bfmt
;
465 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
466 nine_D3DDEVTYPE_to_str(DeviceType
),
467 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
469 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
470 D3DERR_NOTAVAILABLE
);
472 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
473 if (FAILED(hr
)) { return hr
; }
475 dfmt
= d3d9_to_pipe_format_checked(screen
, TargetFormat
, PIPE_TEXTURE_2D
, 1,
476 PIPE_BIND_DISPLAY_TARGET
|
477 PIPE_BIND_SHARED
, FALSE
, FALSE
);
478 bfmt
= d3d9_to_pipe_format_checked(screen
, SourceFormat
, PIPE_TEXTURE_2D
, 1,
479 PIPE_BIND_DISPLAY_TARGET
|
480 PIPE_BIND_SHARED
, FALSE
, FALSE
);
482 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
483 DBG("%s to %s not supported.\n",
484 d3dformat_to_string(SourceFormat
),
485 d3dformat_to_string(TargetFormat
));
486 return D3DERR_NOTAVAILABLE
;
493 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
494 D3DDEVTYPE DeviceType
,
497 struct pipe_screen
*screen
;
500 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
501 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
503 user_assert(pCaps
, D3DERR_INVALIDCALL
);
505 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
507 DBG("Failed to get pipe_screen.\n");
511 #define D3DPIPECAP(pcap, d3dcap) \
512 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
514 #define D3DNPIPECAP(pcap, d3dcap) \
515 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
517 pCaps
->DeviceType
= DeviceType
;
519 pCaps
->AdapterOrdinal
= 0;
523 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
524 /* D3DCAPS2_CANSHARERESOURCE | */
525 /* D3DCAPS2_CANCALIBRATEGAMMA | */
526 D3DCAPS2_DYNAMICTEXTURES
|
527 D3DCAPS2_FULLSCREENGAMMA
|
528 D3DCAPS2_CANAUTOGENMIPMAP
;
530 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
531 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
532 * and in discard mode. */
533 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
534 D3DCAPS3_COPY_TO_VIDMEM
|
535 D3DCAPS3_COPY_TO_SYSTEMMEM
|
536 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
538 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
539 D3DPRESENT_INTERVAL_ONE
|
540 D3DPRESENT_INTERVAL_TWO
|
541 D3DPRESENT_INTERVAL_THREE
|
542 D3DPRESENT_INTERVAL_FOUR
|
543 D3DPRESENT_INTERVAL_IMMEDIATE
;
544 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
546 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
547 D3DDEVCAPS_CANRENDERAFTERFLIP
|
548 D3DDEVCAPS_DRAWPRIMITIVES2
|
549 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
550 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
551 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
552 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
553 D3DDEVCAPS_HWRASTERIZATION
|
554 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
555 /*D3DDEVCAPS_NPATCHES |*/
556 D3DDEVCAPS_PUREDEVICE
|
557 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
558 /*D3DDEVCAPS_RTPATCHES |*/
559 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
560 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
561 D3DDEVCAPS_TEXTURENONLOCALVIDMEM
|
562 /* D3DDEVCAPS_TEXTURESYSTEMMEMORY |*/
563 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
564 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
565 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
567 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
568 D3DPMISCCAPS_CULLNONE
| /* XXX */
569 D3DPMISCCAPS_CULLCW
|
570 D3DPMISCCAPS_CULLCCW
|
571 D3DPMISCCAPS_COLORWRITEENABLE
|
572 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
573 /*D3DPMISCCAPS_CLIPTLVERTS |*/
574 D3DPMISCCAPS_TSSARGTEMP
|
575 D3DPMISCCAPS_BLENDOP
|
576 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
577 D3DPMISCCAPS_PERSTAGECONSTANT
|
578 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO */
579 D3DPMISCCAPS_FOGANDSPECULARALPHA
| /* Note: documentation of the flag is wrong */
580 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
581 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
582 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
583 D3DPMISCCAPS_FOGVERTEXCLAMPED
;
584 if (!screen
->get_param(screen
, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
))
585 pCaps
->PrimitiveMiscCaps
|= D3DPMISCCAPS_CLIPTLVERTS
;
588 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
589 D3DPRASTERCAPS_COLORPERSPECTIVE
|
590 D3DPRASTERCAPS_DITHER
|
591 D3DPRASTERCAPS_DEPTHBIAS
|
592 D3DPRASTERCAPS_FOGRANGE
|
593 D3DPRASTERCAPS_FOGTABLE
|
594 D3DPRASTERCAPS_FOGVERTEX
|
595 D3DPRASTERCAPS_MIPMAPLODBIAS
|
596 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
597 D3DPRASTERCAPS_SCISSORTEST
|
598 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
599 /*D3DPRASTERCAPS_WBUFFER |*/
600 D3DPRASTERCAPS_WFOG
|
601 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
602 D3DPRASTERCAPS_ZFOG
|
603 D3DPRASTERCAPS_ZTEST
;
605 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
608 D3DPCMPCAPS_LESSEQUAL
|
609 D3DPCMPCAPS_GREATER
|
610 D3DPCMPCAPS_NOTEQUAL
|
611 D3DPCMPCAPS_GREATEREQUAL
|
614 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
616 D3DPBLENDCAPS_SRCCOLOR
|
617 D3DPBLENDCAPS_INVSRCCOLOR
|
618 D3DPBLENDCAPS_SRCALPHA
|
619 D3DPBLENDCAPS_INVSRCALPHA
|
620 D3DPBLENDCAPS_DESTALPHA
|
621 D3DPBLENDCAPS_INVDESTALPHA
|
622 D3DPBLENDCAPS_DESTCOLOR
|
623 D3DPBLENDCAPS_INVDESTCOLOR
|
624 D3DPBLENDCAPS_SRCALPHASAT
|
625 D3DPBLENDCAPS_BOTHSRCALPHA
|
626 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
627 D3DPBLENDCAPS_BLENDFACTOR
|
628 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
629 D3DPBLENDCAPS_INVSRCCOLOR2
|
630 D3DPBLENDCAPS_SRCCOLOR2
);
632 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
634 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_NEVER
|
637 D3DPCMPCAPS_LESSEQUAL
|
638 D3DPCMPCAPS_GREATER
|
639 D3DPCMPCAPS_NOTEQUAL
|
640 D3DPCMPCAPS_GREATEREQUAL
|
643 /* FLAT caps not legal for D3D9. */
644 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
645 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
646 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
647 D3DPSHADECAPS_FOGGOURAUD
;
650 D3DPTEXTURECAPS_ALPHA
|
651 D3DPTEXTURECAPS_ALPHAPALETTE
|
652 D3DPTEXTURECAPS_PERSPECTIVE
|
653 D3DPTEXTURECAPS_PROJECTED
|
654 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
655 D3DPTEXTURECAPS_CUBEMAP
|
656 D3DPTEXTURECAPS_VOLUMEMAP
|
657 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
658 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
659 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
660 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
661 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
662 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
663 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
665 pCaps
->TextureFilterCaps
=
666 D3DPTFILTERCAPS_MINFPOINT
|
667 D3DPTFILTERCAPS_MINFLINEAR
|
668 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
669 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
670 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
671 D3DPTFILTERCAPS_MIPFPOINT
|
672 D3DPTFILTERCAPS_MIPFLINEAR
|
673 D3DPTFILTERCAPS_MAGFPOINT
|
674 D3DPTFILTERCAPS_MAGFLINEAR
|
675 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
676 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
677 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
679 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
680 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
682 pCaps
->TextureAddressCaps
=
683 D3DPTADDRESSCAPS_BORDER
|
684 D3DPTADDRESSCAPS_INDEPENDENTUV
|
685 D3DPTADDRESSCAPS_WRAP
|
686 D3DPTADDRESSCAPS_MIRROR
|
687 D3DPTADDRESSCAPS_CLAMP
|
688 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
690 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
693 D3DLINECAPS_ALPHACMP
|
695 D3DLINECAPS_TEXTURE
|
698 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
699 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
702 pCaps
->MaxTextureWidth
=
703 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
704 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
705 pCaps
->MaxVolumeExtent
=
706 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
707 /* XXX values from wine */
708 pCaps
->MaxTextureRepeat
= 32768;
709 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
711 pCaps
->MaxAnisotropy
=
712 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
714 /* Values for GeForce 9600 GT */
715 pCaps
->MaxVertexW
= 1e10f
;
716 pCaps
->GuardBandLeft
= -1e9f
;
717 pCaps
->GuardBandTop
= -1e9f
;
718 pCaps
->GuardBandRight
= 1e9f
;
719 pCaps
->GuardBandBottom
= 1e9f
;
720 pCaps
->ExtentsAdjust
= 0.0f
;
723 D3DSTENCILCAPS_KEEP
|
724 D3DSTENCILCAPS_ZERO
|
725 D3DSTENCILCAPS_REPLACE
|
726 D3DSTENCILCAPS_INCRSAT
|
727 D3DSTENCILCAPS_DECRSAT
|
728 D3DSTENCILCAPS_INVERT
|
729 D3DSTENCILCAPS_INCR
|
730 D3DSTENCILCAPS_DECR
|
731 D3DPIPECAP(TWO_SIDED_STENCIL
, D3DSTENCILCAPS_TWOSIDED
);
734 8 | /* 8 textures max */
735 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
738 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
739 D3DTEXOPCAPS_SELECTARG1
|
740 D3DTEXOPCAPS_SELECTARG2
|
741 D3DTEXOPCAPS_MODULATE
|
742 D3DTEXOPCAPS_MODULATE2X
|
743 D3DTEXOPCAPS_MODULATE4X
|
745 D3DTEXOPCAPS_ADDSIGNED
|
746 D3DTEXOPCAPS_ADDSIGNED2X
|
747 D3DTEXOPCAPS_SUBTRACT
|
748 D3DTEXOPCAPS_ADDSMOOTH
|
749 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
750 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
751 D3DTEXOPCAPS_BLENDFACTORALPHA
|
752 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
753 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
754 D3DTEXOPCAPS_PREMODULATE
|
755 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
756 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
757 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
758 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
759 D3DTEXOPCAPS_BUMPENVMAP
|
760 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
761 D3DTEXOPCAPS_DOTPRODUCT3
|
762 D3DTEXOPCAPS_MULTIPLYADD
|
765 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
766 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
767 pCaps
->MaxSimultaneousTextures
= screen
->get_shader_param(screen
,
768 PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
);
769 if (pCaps
->MaxSimultaneousTextures
> NINE_MAX_SAMPLERS_PS
)
770 pCaps
->MaxSimultaneousTextures
= NINE_MAX_SAMPLERS_PS
;
772 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
773 /*D3DVTXPCAPS_TEXGEN_SPHEREMAP |*/
774 D3DVTXPCAPS_MATERIALSOURCE7
|
775 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
776 D3DVTXPCAPS_POSITIONALLIGHTS
|
777 D3DVTXPCAPS_LOCALVIEWER
|
778 D3DVTXPCAPS_TWEENING
|
779 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
781 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
782 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
783 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
784 pCaps
->MaxVertexBlendMatrixIndex
= 7; /* D3DTS_WORLDMATRIX(0..7) */
786 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
788 pCaps
->MaxPrimitiveCount
= 0x555555; /* <- wine, really 0xFFFFFFFF; */
789 pCaps
->MaxVertexIndex
= 0xFFFFFF; /* <- wine, really 0xFFFFFFFF */
791 _min(screen
->get_shader_param(screen
,
792 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
795 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
796 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
798 pCaps
->VertexShaderVersion
= D3DVS_VERSION(3,0);
800 /* VS 2 as well as 3.0 supports a minimum of 256 consts.
801 * Wine and d3d9 drivers for dx1x hw advertise 256. Just as them,
802 * advertise 256. Problem is with hw that can only do 256, because
803 * we need take a few slots for boolean and integer constants. For these
804 * we'll have to fail later if they use complex shaders. */
805 pCaps
->MaxVertexShaderConst
= NINE_MAX_CONST_F
;
807 pCaps
->PixelShaderVersion
= D3DPS_VERSION(3,0);
808 /* Value for GeForce 9600 GT */
809 pCaps
->PixelShader1xMaxValue
= 65504.f
;
811 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
812 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
813 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
814 /*D3DDEVCAPS2_DMAPNPATCH |*/
815 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
816 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
817 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
819 pCaps
->MasterAdapterOrdinal
= 0;
820 pCaps
->AdapterOrdinalInGroup
= 0;
821 pCaps
->NumberOfAdaptersInGroup
= 1;
824 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
825 pCaps
->Reserved5
= 0;
827 /* XXX: use is_format_supported */
828 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
836 D3DDTCAPS_FLOAT16_2
|
839 pCaps
->NumSimultaneousRTs
=
840 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
841 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
842 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
844 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
845 D3DPTFILTERCAPS_MINFLINEAR
|
846 D3DPTFILTERCAPS_MAGFPOINT
|
847 D3DPTFILTERCAPS_MAGFLINEAR
;
850 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
851 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
852 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
853 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
854 pCaps
->VS20Caps
.NumTemps
=
855 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
856 PIPE_SHADER_CAP_MAX_TEMPS
);
857 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
858 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
859 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
861 /* also check for values < 0, because get_shader_param may return unsigned */
862 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
863 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
864 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
865 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
866 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
867 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
868 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
869 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
870 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
871 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
872 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
875 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
876 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
877 D3DPS20CAPS_PREDICATION
;
878 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
879 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
880 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
881 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
882 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
883 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
884 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
885 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
886 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
887 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
888 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
889 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
890 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
891 pCaps
->PS20Caps
.NumTemps
=
892 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
893 PIPE_SHADER_CAP_MAX_TEMPS
);
894 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
895 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
896 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
897 pCaps
->PS20Caps
.NumInstructionSlots
=
898 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
899 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
901 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
902 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
903 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
904 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
905 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
906 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
907 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
908 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
909 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
910 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
911 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
912 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
913 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
914 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
917 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
918 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
919 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
920 ~(D3DPTFILTERCAPS_MIPFPOINT
|
921 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
923 pCaps
->VertexTextureFilterCaps
= 0;
925 pCaps
->MaxVertexShader30InstructionSlots
=
926 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
927 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
928 pCaps
->MaxPixelShader30InstructionSlots
=
929 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
930 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
931 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
932 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
933 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
934 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
935 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
936 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
938 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
939 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
940 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
942 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
943 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
949 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
951 D3DDEVTYPE DeviceType
,
954 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
956 ID3DPresentGroup
*pPresentationGroup
,
957 IDirect3DDevice9
**ppReturnedDeviceInterface
)
959 struct pipe_screen
*screen
;
960 D3DDEVICE_CREATION_PARAMETERS params
;
965 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
966 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
967 "ppReturnedDeviceInterface=%p\n", This
,
968 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
969 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
971 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
973 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
975 return D3DERR_NOTAVAILABLE
;
978 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
980 DBG("Failed to get pipe_screen.\n");
984 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
986 DBG("Failed to get device caps.\n");
990 params
.AdapterOrdinal
= RealAdapter
;
991 params
.DeviceType
= DeviceType
;
992 params
.hFocusWindow
= hFocusWindow
;
993 params
.BehaviorFlags
= BehaviorFlags
;
995 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
996 pD3D9
, pPresentationGroup
, This
->ctx
, FALSE
, NULL
,
997 (struct NineDevice9
**)ppReturnedDeviceInterface
,
1000 DBG("Failed to create device.\n");
1003 DBG("NineDevice9 created successfully.\n");
1009 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1011 D3DDEVTYPE DeviceType
,
1013 DWORD BehaviorFlags
,
1014 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1015 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1016 IDirect3D9Ex
*pD3D9Ex
,
1017 ID3DPresentGroup
*pPresentationGroup
,
1018 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1020 struct pipe_screen
*screen
;
1021 D3DDEVICE_CREATION_PARAMETERS params
;
1026 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1027 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1028 "ppReturnedDeviceInterface=%p\n", This
,
1029 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1030 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1032 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1034 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1036 return D3DERR_NOTAVAILABLE
;
1039 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1041 DBG("Failed to get pipe_screen.\n");
1045 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1047 DBG("Failed to get device caps.\n");
1051 params
.AdapterOrdinal
= RealAdapter
;
1052 params
.DeviceType
= DeviceType
;
1053 params
.hFocusWindow
= hFocusWindow
;
1054 params
.BehaviorFlags
= BehaviorFlags
;
1056 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1057 pFullscreenDisplayMode
,
1058 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1059 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
,
1062 DBG("Failed to create device.\n");
1065 DBG("NineDevice9Ex created successfully.\n");
1070 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1071 (void *)NineUnknown_QueryInterface
,
1072 (void *)NineUnknown_AddRef
,
1073 (void *)NineUnknown_Release
,
1074 (void *)NineAdapter9_GetAdapterIdentifier
,
1075 (void *)NineAdapter9_CheckDeviceType
,
1076 (void *)NineAdapter9_CheckDeviceFormat
,
1077 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1078 (void *)NineAdapter9_CheckDepthStencilMatch
,
1079 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1080 (void *)NineAdapter9_GetDeviceCaps
,
1081 (void *)NineAdapter9_CreateDevice
,
1082 (void *)NineAdapter9_CreateDeviceEx
1085 static const GUID
*NineAdapter9_IIDs
[] = {
1092 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1093 struct NineAdapter9
**ppOut
)
1095 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);