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 /* The display format is not handled in Nine. We always present an XRGB8888
208 * buffer (and the display server will eventually do the conversion). We probably
209 * don't need to check for anything for the adapter format support, since if the
210 * display server advertise support, it will likely be able to do the conversion.
211 * We do the approximation that a format is available in the display server if
212 * the format passes with NINE_BIND_BACKBUFFER_FLAGS */
213 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
,
215 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
216 bfmt
= d3d9_to_pipe_format_checked(screen
, BackBufferFormat
, PIPE_TEXTURE_2D
,
218 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
219 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
220 DBG("Unsupported Adapter/BackBufferFormat.\n");
221 return D3DERR_NOTAVAILABLE
;
227 static inline boolean
228 display_format( D3DFORMAT fmt
,
231 /* http://msdn.microsoft.com/en-us/library/bb172558(v=VS.85).aspx#BackBuffer_or_Display_Formats */
232 static const D3DFORMAT allowed
[] = {
240 if (fmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
242 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
243 if (fmt
== allowed
[i
]) { return TRUE
; }
249 NineAdapter9_CheckDeviceFormat( struct NineAdapter9
*This
,
250 D3DDEVTYPE DeviceType
,
251 D3DFORMAT AdapterFormat
,
253 D3DRESOURCETYPE RType
,
254 D3DFORMAT CheckFormat
)
256 struct pipe_screen
*screen
;
259 enum pipe_texture_target target
;
263 /* Check adapter format. */
265 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This
,
266 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
));
267 DBG("Usage=%x RType=%u CheckFormat=%s\n", Usage
, RType
,
268 d3dformat_to_string(CheckFormat
));
270 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_INVALIDCALL
);
272 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
275 pf
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
276 PIPE_BIND_DISPLAY_TARGET
|
277 PIPE_BIND_SHARED
, FALSE
, FALSE
);
278 if (pf
== PIPE_FORMAT_NONE
) {
279 DBG("AdapterFormat %s not available.\n",
280 d3dformat_to_string(AdapterFormat
));
281 return D3DERR_NOTAVAILABLE
;
284 /* Check actual format. */
287 case D3DRTYPE_SURFACE
: target
= PIPE_TEXTURE_2D
; break;
288 case D3DRTYPE_TEXTURE
: target
= PIPE_TEXTURE_2D
; break;
289 case D3DRTYPE_CUBETEXTURE
: target
= PIPE_TEXTURE_CUBE
; break;
290 case D3DRTYPE_VOLUME
: target
= PIPE_TEXTURE_3D
; break;
291 case D3DRTYPE_VOLUMETEXTURE
: target
= PIPE_TEXTURE_3D
; break;
292 case D3DRTYPE_VERTEXBUFFER
: target
= PIPE_BUFFER
; break;
293 case D3DRTYPE_INDEXBUFFER
: target
= PIPE_BUFFER
; break;
295 user_assert(0, D3DERR_INVALIDCALL
);
299 if (Usage
& D3DUSAGE_RENDERTARGET
) bind
|= PIPE_BIND_RENDER_TARGET
;
300 if (Usage
& D3DUSAGE_DEPTHSTENCIL
) bind
|= PIPE_BIND_DEPTH_STENCIL
;
302 /* API hack because setting RT[0] to NULL is forbidden */
303 if (CheckFormat
== D3DFMT_NULL
&& bind
== PIPE_BIND_RENDER_TARGET
&&
304 (RType
== D3DRTYPE_SURFACE
||
305 RType
== D3DRTYPE_TEXTURE
))
309 if (CheckFormat
== D3DFMT_RESZ
&& bind
== PIPE_BIND_RENDER_TARGET
&&
310 RType
== D3DRTYPE_SURFACE
)
311 return screen
->get_param(screen
, PIPE_CAP_MULTISAMPLE_Z_RESOLVE
) ?
312 D3D_OK
: D3DERR_NOTAVAILABLE
;
315 if (CheckFormat
== D3DFMT_ATOC
&& RType
== D3DRTYPE_SURFACE
)
318 if ((Usage
& D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
) &&
319 (Usage
& D3DUSAGE_RENDERTARGET
))
320 bind
|= PIPE_BIND_BLENDABLE
;
322 if (Usage
& D3DUSAGE_DMAP
) {
323 DBG("D3DUSAGE_DMAP not available\n");
324 return D3DERR_NOTAVAILABLE
; /* TODO: displacement mapping */
328 case D3DRTYPE_TEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
329 case D3DRTYPE_CUBETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
330 case D3DRTYPE_VOLUMETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
331 case D3DRTYPE_VERTEXBUFFER
: bind
|= PIPE_BIND_VERTEX_BUFFER
; break;
332 case D3DRTYPE_INDEXBUFFER
: bind
|= PIPE_BIND_INDEX_BUFFER
; break;
333 case D3DRTYPE_SURFACE
:
334 if (!(Usage
& D3DUSAGE_DEPTHSTENCIL
))
335 bind
|= PIPE_BIND_SAMPLER_VIEW
; /* StretchRect */
336 /* Offscreen surface support: Usage = 0.
337 * In practice drivers are very restrictive on the formats supported.
338 * Basically a few common formats + YUV and compressed formats. The
339 * reason is that offscreen surface are useful only for directdraw
340 * compatibility (a WONTIMPL of nine) + format conversion (useful in
341 * particular for YUV because the format was not advertised for textures
344 bind
|= PIPE_BIND_RENDER_TARGET
; /* A current requirement of our impl, which we should get rid of. */
350 srgb
= (Usage
& (D3DUSAGE_QUERY_SRGBREAD
| D3DUSAGE_QUERY_SRGBWRITE
)) != 0;
351 pf
= d3d9_to_pipe_format_checked(screen
, CheckFormat
, target
,
352 0, bind
, srgb
, FALSE
);
353 if (pf
== PIPE_FORMAT_NONE
) {
354 DBG("NOT AVAILABLE\n");
355 return D3DERR_NOTAVAILABLE
;
358 /* we support ATI1 and ATI2 hack only for 2D and Cube textures */
359 if (RType
!= D3DRTYPE_TEXTURE
&& RType
!= D3DRTYPE_CUBETEXTURE
&&
360 (CheckFormat
== D3DFMT_ATI1
|| CheckFormat
== D3DFMT_ATI2
))
361 return D3DERR_NOTAVAILABLE
;
362 /* if (Usage & D3DUSAGE_NONSECURE) { don't know the implications of this } */
363 /* if (Usage & D3DUSAGE_SOFTWAREPROCESSING) { we can always support this } */
365 if ((Usage
& D3DUSAGE_AUTOGENMIPMAP
) && !(bind
& PIPE_BIND_SAMPLER_VIEW
))
366 return D3DOK_NOAUTOGEN
;
371 NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9
*This
,
372 D3DDEVTYPE DeviceType
,
373 D3DFORMAT SurfaceFormat
,
375 D3DMULTISAMPLE_TYPE MultiSampleType
,
376 DWORD
*pQualityLevels
)
378 struct pipe_screen
*screen
;
383 DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
384 "pQualityLevels=%p\n", This
, nine_D3DDEVTYPE_to_str(DeviceType
),
385 d3dformat_to_string(SurfaceFormat
), Windowed
, MultiSampleType
,
388 if (pQualityLevels
) {
389 /* In error cases return only 1 quality level supported */
392 user_assert(MultiSampleType
< D3DMULTISAMPLE_16_SAMPLES
, D3DERR_INVALIDCALL
);
394 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
398 if (depth_stencil_format(SurfaceFormat
))
399 bind
= d3d9_get_pipe_depth_format_bindings(SurfaceFormat
);
400 else /* render-target */
401 bind
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
403 pf
= d3d9_to_pipe_format_checked(screen
, SurfaceFormat
, PIPE_TEXTURE_2D
,
404 MultiSampleType
, bind
, FALSE
, FALSE
);
406 if (pf
== PIPE_FORMAT_NONE
) {
407 DBG("%s with %u samples not available.\n",
408 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
409 return D3DERR_NOTAVAILABLE
;
413 *pQualityLevels
= 1; /* gallium doesn't have quality levels */
419 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
420 D3DDEVTYPE DeviceType
,
421 D3DFORMAT AdapterFormat
,
422 D3DFORMAT RenderTargetFormat
,
423 D3DFORMAT DepthStencilFormat
)
425 struct pipe_screen
*screen
;
426 enum pipe_format dfmt
, bfmt
, zsfmt
;
429 DBG("This=%p DeviceType=%s AdapterFormat=%s "
430 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
431 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
432 d3dformat_to_string(RenderTargetFormat
),
433 d3dformat_to_string(DepthStencilFormat
));
435 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
436 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
438 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
439 if (FAILED(hr
)) { return hr
; }
441 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
442 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
443 bfmt
= d3d9_to_pipe_format_checked(screen
, RenderTargetFormat
,
445 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
446 if (RenderTargetFormat
== D3DFMT_NULL
)
448 zsfmt
= d3d9_to_pipe_format_checked(screen
, DepthStencilFormat
,
450 d3d9_get_pipe_depth_format_bindings(DepthStencilFormat
),
452 if (dfmt
== PIPE_FORMAT_NONE
||
453 bfmt
== PIPE_FORMAT_NONE
||
454 zsfmt
== PIPE_FORMAT_NONE
) {
455 return D3DERR_NOTAVAILABLE
;
462 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
463 D3DDEVTYPE DeviceType
,
464 D3DFORMAT SourceFormat
,
465 D3DFORMAT TargetFormat
)
467 /* MSDN says this tests whether a certain backbuffer format can be used in
468 * conjunction with a certain front buffer format. It's a little confusing
469 * but some one wiser might be able to figure this one out. XXX */
470 struct pipe_screen
*screen
;
471 enum pipe_format dfmt
, bfmt
;
474 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
475 nine_D3DDEVTYPE_to_str(DeviceType
),
476 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
478 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
479 D3DERR_NOTAVAILABLE
);
481 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
482 if (FAILED(hr
)) { return hr
; }
484 dfmt
= d3d9_to_pipe_format_checked(screen
, TargetFormat
, PIPE_TEXTURE_2D
, 1,
485 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
486 bfmt
= d3d9_to_pipe_format_checked(screen
, SourceFormat
, PIPE_TEXTURE_2D
, 1,
487 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
489 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
490 DBG("%s to %s not supported.\n",
491 d3dformat_to_string(SourceFormat
),
492 d3dformat_to_string(TargetFormat
));
493 return D3DERR_NOTAVAILABLE
;
500 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
501 D3DDEVTYPE DeviceType
,
504 struct pipe_screen
*screen
;
507 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
508 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
510 user_assert(pCaps
, D3DERR_INVALIDCALL
);
512 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
514 DBG("Failed to get pipe_screen.\n");
518 #define D3DPIPECAP(pcap, d3dcap) \
519 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
521 #define D3DNPIPECAP(pcap, d3dcap) \
522 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
524 pCaps
->DeviceType
= DeviceType
;
526 pCaps
->AdapterOrdinal
= 0;
530 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
531 /* D3DCAPS2_CANSHARERESOURCE | */
532 /* D3DCAPS2_CANCALIBRATEGAMMA | */
533 D3DCAPS2_DYNAMICTEXTURES
|
534 D3DCAPS2_FULLSCREENGAMMA
|
535 D3DCAPS2_CANAUTOGENMIPMAP
;
537 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
538 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
539 * and in discard mode. */
540 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
541 D3DCAPS3_COPY_TO_VIDMEM
|
542 D3DCAPS3_COPY_TO_SYSTEMMEM
|
543 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
545 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
546 D3DPRESENT_INTERVAL_ONE
|
547 D3DPRESENT_INTERVAL_TWO
|
548 D3DPRESENT_INTERVAL_THREE
|
549 D3DPRESENT_INTERVAL_FOUR
|
550 D3DPRESENT_INTERVAL_IMMEDIATE
;
551 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
553 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
554 D3DDEVCAPS_CANRENDERAFTERFLIP
|
555 D3DDEVCAPS_DRAWPRIMITIVES2
|
556 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
557 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
558 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
559 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
560 D3DDEVCAPS_HWRASTERIZATION
|
561 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
562 /*D3DDEVCAPS_NPATCHES |*/
563 D3DDEVCAPS_PUREDEVICE
|
564 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
565 /*D3DDEVCAPS_RTPATCHES |*/
566 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
567 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
568 D3DDEVCAPS_TEXTURENONLOCALVIDMEM
|
569 /* D3DDEVCAPS_TEXTURESYSTEMMEMORY |*/
570 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
571 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
572 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
574 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
575 D3DPMISCCAPS_CULLNONE
| /* XXX */
576 D3DPMISCCAPS_CULLCW
|
577 D3DPMISCCAPS_CULLCCW
|
578 D3DPMISCCAPS_COLORWRITEENABLE
|
579 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
580 /*D3DPMISCCAPS_CLIPTLVERTS |*/
581 D3DPMISCCAPS_TSSARGTEMP
|
582 D3DPMISCCAPS_BLENDOP
|
583 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
584 D3DPMISCCAPS_PERSTAGECONSTANT
|
585 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO */
586 D3DPMISCCAPS_FOGANDSPECULARALPHA
| /* Note: documentation of the flag is wrong */
587 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
588 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
589 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
590 D3DPMISCCAPS_FOGVERTEXCLAMPED
;
591 if (!screen
->get_param(screen
, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
))
592 pCaps
->PrimitiveMiscCaps
|= D3DPMISCCAPS_CLIPTLVERTS
;
595 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
596 D3DPRASTERCAPS_COLORPERSPECTIVE
|
597 D3DPRASTERCAPS_DITHER
|
598 D3DPRASTERCAPS_DEPTHBIAS
|
599 D3DPRASTERCAPS_FOGRANGE
|
600 D3DPRASTERCAPS_FOGTABLE
|
601 D3DPRASTERCAPS_FOGVERTEX
|
602 D3DPRASTERCAPS_MIPMAPLODBIAS
|
603 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
604 D3DPRASTERCAPS_SCISSORTEST
|
605 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
606 /*D3DPRASTERCAPS_WBUFFER |*/
607 D3DPRASTERCAPS_WFOG
|
608 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
609 D3DPRASTERCAPS_ZFOG
|
610 D3DPRASTERCAPS_ZTEST
;
612 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
615 D3DPCMPCAPS_LESSEQUAL
|
616 D3DPCMPCAPS_GREATER
|
617 D3DPCMPCAPS_NOTEQUAL
|
618 D3DPCMPCAPS_GREATEREQUAL
|
621 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
623 D3DPBLENDCAPS_SRCCOLOR
|
624 D3DPBLENDCAPS_INVSRCCOLOR
|
625 D3DPBLENDCAPS_SRCALPHA
|
626 D3DPBLENDCAPS_INVSRCALPHA
|
627 D3DPBLENDCAPS_DESTALPHA
|
628 D3DPBLENDCAPS_INVDESTALPHA
|
629 D3DPBLENDCAPS_DESTCOLOR
|
630 D3DPBLENDCAPS_INVDESTCOLOR
|
631 D3DPBLENDCAPS_SRCALPHASAT
|
632 D3DPBLENDCAPS_BOTHSRCALPHA
|
633 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
634 D3DPBLENDCAPS_BLENDFACTOR
|
635 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
636 D3DPBLENDCAPS_INVSRCCOLOR2
|
637 D3DPBLENDCAPS_SRCCOLOR2
);
639 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
641 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_NEVER
|
644 D3DPCMPCAPS_LESSEQUAL
|
645 D3DPCMPCAPS_GREATER
|
646 D3DPCMPCAPS_NOTEQUAL
|
647 D3DPCMPCAPS_GREATEREQUAL
|
650 /* FLAT caps not legal for D3D9. */
651 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
652 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
653 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
654 D3DPSHADECAPS_FOGGOURAUD
;
657 D3DPTEXTURECAPS_ALPHA
|
658 D3DPTEXTURECAPS_ALPHAPALETTE
|
659 D3DPTEXTURECAPS_PERSPECTIVE
|
660 D3DPTEXTURECAPS_PROJECTED
|
661 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
662 D3DPTEXTURECAPS_CUBEMAP
|
663 D3DPTEXTURECAPS_VOLUMEMAP
|
664 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
665 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
666 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
667 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
668 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
669 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
670 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
672 pCaps
->TextureFilterCaps
=
673 D3DPTFILTERCAPS_MINFPOINT
|
674 D3DPTFILTERCAPS_MINFLINEAR
|
675 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
676 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
677 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
678 D3DPTFILTERCAPS_MIPFPOINT
|
679 D3DPTFILTERCAPS_MIPFLINEAR
|
680 D3DPTFILTERCAPS_MAGFPOINT
|
681 D3DPTFILTERCAPS_MAGFLINEAR
|
682 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
683 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
684 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
686 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
687 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
689 pCaps
->TextureAddressCaps
=
690 D3DPTADDRESSCAPS_BORDER
|
691 D3DPTADDRESSCAPS_INDEPENDENTUV
|
692 D3DPTADDRESSCAPS_WRAP
|
693 D3DPTADDRESSCAPS_MIRROR
|
694 D3DPTADDRESSCAPS_CLAMP
|
695 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
697 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
700 D3DLINECAPS_ALPHACMP
|
702 D3DLINECAPS_TEXTURE
|
705 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
706 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
709 pCaps
->MaxTextureWidth
=
710 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
711 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
712 pCaps
->MaxVolumeExtent
=
713 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
714 /* XXX values from wine */
715 pCaps
->MaxTextureRepeat
= 32768;
716 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
718 pCaps
->MaxAnisotropy
=
719 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
721 /* Values for GeForce 9600 GT */
722 pCaps
->MaxVertexW
= 1e10f
;
723 pCaps
->GuardBandLeft
= -1e9f
;
724 pCaps
->GuardBandTop
= -1e9f
;
725 pCaps
->GuardBandRight
= 1e9f
;
726 pCaps
->GuardBandBottom
= 1e9f
;
727 pCaps
->ExtentsAdjust
= 0.0f
;
730 D3DSTENCILCAPS_KEEP
|
731 D3DSTENCILCAPS_ZERO
|
732 D3DSTENCILCAPS_REPLACE
|
733 D3DSTENCILCAPS_INCRSAT
|
734 D3DSTENCILCAPS_DECRSAT
|
735 D3DSTENCILCAPS_INVERT
|
736 D3DSTENCILCAPS_INCR
|
737 D3DSTENCILCAPS_DECR
|
738 D3DPIPECAP(TWO_SIDED_STENCIL
, D3DSTENCILCAPS_TWOSIDED
);
741 8 | /* 8 textures max */
742 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
745 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
746 D3DTEXOPCAPS_SELECTARG1
|
747 D3DTEXOPCAPS_SELECTARG2
|
748 D3DTEXOPCAPS_MODULATE
|
749 D3DTEXOPCAPS_MODULATE2X
|
750 D3DTEXOPCAPS_MODULATE4X
|
752 D3DTEXOPCAPS_ADDSIGNED
|
753 D3DTEXOPCAPS_ADDSIGNED2X
|
754 D3DTEXOPCAPS_SUBTRACT
|
755 D3DTEXOPCAPS_ADDSMOOTH
|
756 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
757 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
758 D3DTEXOPCAPS_BLENDFACTORALPHA
|
759 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
760 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
761 D3DTEXOPCAPS_PREMODULATE
|
762 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
763 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
764 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
765 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
766 D3DTEXOPCAPS_BUMPENVMAP
|
767 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
768 D3DTEXOPCAPS_DOTPRODUCT3
|
769 D3DTEXOPCAPS_MULTIPLYADD
|
772 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
773 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
774 pCaps
->MaxSimultaneousTextures
= screen
->get_shader_param(screen
,
775 PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
);
776 if (pCaps
->MaxSimultaneousTextures
> NINE_MAX_SAMPLERS_PS
)
777 pCaps
->MaxSimultaneousTextures
= NINE_MAX_SAMPLERS_PS
;
779 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
780 D3DVTXPCAPS_TEXGEN_SPHEREMAP
|
781 D3DVTXPCAPS_MATERIALSOURCE7
|
782 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
783 D3DVTXPCAPS_POSITIONALLIGHTS
|
784 D3DVTXPCAPS_LOCALVIEWER
|
785 D3DVTXPCAPS_TWEENING
|
786 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
788 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
789 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
790 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
791 pCaps
->MaxVertexBlendMatrixIndex
= 8; /* D3DTS_WORLDMATRIX(0..8) */
793 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
795 pCaps
->MaxPrimitiveCount
= 0x555555; /* <- wine, really 0xFFFFFFFF; */
796 pCaps
->MaxVertexIndex
= 0xFFFFFF; /* <- wine, really 0xFFFFFFFF */
798 _min(screen
->get_shader_param(screen
,
799 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
802 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
803 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
805 pCaps
->VertexShaderVersion
= D3DVS_VERSION(3,0);
807 /* VS 2 as well as 3.0 supports a minimum of 256 consts.
808 * Wine and d3d9 drivers for dx1x hw advertise 256. Just as them,
809 * advertise 256. Problem is with hw that can only do 256, because
810 * we need take a few slots for boolean and integer constants. For these
811 * we'll have to fail later if they use complex shaders. */
812 pCaps
->MaxVertexShaderConst
= NINE_MAX_CONST_F
;
814 pCaps
->PixelShaderVersion
= D3DPS_VERSION(3,0);
815 /* Value for GeForce 9600 GT */
816 pCaps
->PixelShader1xMaxValue
= 65504.f
;
818 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
819 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
820 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
821 /*D3DDEVCAPS2_DMAPNPATCH |*/
822 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
823 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
824 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
826 pCaps
->MasterAdapterOrdinal
= 0;
827 pCaps
->AdapterOrdinalInGroup
= 0;
828 pCaps
->NumberOfAdaptersInGroup
= 1;
831 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
832 pCaps
->Reserved5
= 0;
834 /* XXX: use is_format_supported */
835 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
843 D3DDTCAPS_FLOAT16_2
|
846 pCaps
->NumSimultaneousRTs
=
847 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
848 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
849 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
851 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
852 D3DPTFILTERCAPS_MINFLINEAR
|
853 D3DPTFILTERCAPS_MAGFPOINT
|
854 D3DPTFILTERCAPS_MAGFLINEAR
;
857 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
858 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
859 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
860 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
861 pCaps
->VS20Caps
.NumTemps
=
862 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
863 PIPE_SHADER_CAP_MAX_TEMPS
);
864 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
865 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
866 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
868 /* also check for values < 0, because get_shader_param may return unsigned */
869 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
870 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
871 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
872 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
873 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
874 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
875 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
876 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
877 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
878 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
879 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
882 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
883 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
884 D3DPS20CAPS_PREDICATION
;
885 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
886 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
887 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
888 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
889 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
890 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
891 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
892 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
893 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
894 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
895 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
896 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
897 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
898 pCaps
->PS20Caps
.NumTemps
=
899 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
900 PIPE_SHADER_CAP_MAX_TEMPS
);
901 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
902 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
903 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
904 pCaps
->PS20Caps
.NumInstructionSlots
=
905 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
906 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
908 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
909 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
910 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
911 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
912 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
913 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
914 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
915 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
916 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
917 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
918 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
919 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
920 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
921 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
924 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
925 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
926 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
927 ~(D3DPTFILTERCAPS_MIPFPOINT
|
928 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
930 pCaps
->VertexTextureFilterCaps
= 0;
932 pCaps
->MaxVertexShader30InstructionSlots
=
933 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
934 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
935 pCaps
->MaxPixelShader30InstructionSlots
=
936 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
937 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
938 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
939 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
940 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
941 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
942 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
943 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
945 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
946 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
947 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
949 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
950 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
956 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
958 D3DDEVTYPE DeviceType
,
961 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
963 ID3DPresentGroup
*pPresentationGroup
,
964 IDirect3DDevice9
**ppReturnedDeviceInterface
)
966 struct pipe_screen
*screen
;
967 D3DDEVICE_CREATION_PARAMETERS params
;
972 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
973 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
974 "ppReturnedDeviceInterface=%p\n", This
,
975 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
976 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
978 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
980 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
982 return D3DERR_NOTAVAILABLE
;
985 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
987 DBG("Failed to get pipe_screen.\n");
991 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
993 DBG("Failed to get device caps.\n");
997 params
.AdapterOrdinal
= RealAdapter
;
998 params
.DeviceType
= DeviceType
;
999 params
.hFocusWindow
= hFocusWindow
;
1000 params
.BehaviorFlags
= BehaviorFlags
;
1002 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1003 pD3D9
, pPresentationGroup
, This
->ctx
, FALSE
, NULL
,
1004 (struct NineDevice9
**)ppReturnedDeviceInterface
,
1007 DBG("Failed to create device.\n");
1010 DBG("NineDevice9 created successfully.\n");
1016 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1018 D3DDEVTYPE DeviceType
,
1020 DWORD BehaviorFlags
,
1021 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1022 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1023 IDirect3D9Ex
*pD3D9Ex
,
1024 ID3DPresentGroup
*pPresentationGroup
,
1025 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1027 struct pipe_screen
*screen
;
1028 D3DDEVICE_CREATION_PARAMETERS params
;
1033 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1034 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1035 "ppReturnedDeviceInterface=%p\n", This
,
1036 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1037 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1039 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1041 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1043 return D3DERR_NOTAVAILABLE
;
1046 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1048 DBG("Failed to get pipe_screen.\n");
1052 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1054 DBG("Failed to get device caps.\n");
1058 params
.AdapterOrdinal
= RealAdapter
;
1059 params
.DeviceType
= DeviceType
;
1060 params
.hFocusWindow
= hFocusWindow
;
1061 params
.BehaviorFlags
= BehaviorFlags
;
1063 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1064 pFullscreenDisplayMode
,
1065 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1066 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
,
1069 DBG("Failed to create device.\n");
1072 DBG("NineDevice9Ex created successfully.\n");
1077 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1078 (void *)NineUnknown_QueryInterface
,
1079 (void *)NineUnknown_AddRef
,
1080 (void *)NineUnknown_Release
,
1081 (void *)NineAdapter9_GetAdapterIdentifier
,
1082 (void *)NineAdapter9_CheckDeviceType
,
1083 (void *)NineAdapter9_CheckDeviceFormat
,
1084 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1085 (void *)NineAdapter9_CheckDepthStencilMatch
,
1086 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1087 (void *)NineAdapter9_GetDeviceCaps
,
1088 (void *)NineAdapter9_CreateDevice
,
1089 (void *)NineAdapter9_CreateDeviceEx
1092 static const GUID
*NineAdapter9_IIDs
[] = {
1099 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1100 struct NineAdapter9
**ppOut
)
1102 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);