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 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
82 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
) < 16) {
83 ERR("Your card is not supported by Gallium Nine. Minimum requirement "
84 "is >= r500, >= nv50, >= i965\n");
85 return D3DERR_DRIVERINTERNALERROR
;
88 if (hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
89 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 276 * sizeof(float[4]) || /* we put bool and int constants with float constants */
90 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
91 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 || /* we use some more temp registers */
92 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
93 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 ||
94 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
95 PIPE_SHADER_CAP_MAX_INPUTS
) < 20) /* we don't pack inputs as much as we could */
96 ERR("Your card is at the limit of Gallium Nine requirements. Some games "
97 "may run into issues because requirements are too tight\n");
102 NineAdapter9_dtor( struct NineAdapter9
*This
)
104 struct d3dadapter9_context
*ctx
= This
->ctx
;
106 DBG("This=%p\n", This
);
108 NineUnknown_dtor(&This
->base
);
110 /* special case, call backend-specific dtor AFTER destroying this object
113 if (ctx
->destroy
) { ctx
->destroy(ctx
); }
118 NineAdapter9_GetScreen( struct NineAdapter9
*This
,
120 struct pipe_screen
**ppScreen
)
122 const char *force_sw
= getenv("D3D_ALWAYS_SOFTWARE");
125 if (force_sw
&& !strcmp(force_sw
, "1") && This
->ctx
->ref
) {
126 *ppScreen
= This
->ctx
->ref
;
129 *ppScreen
= This
->ctx
->hal
;
133 case D3DDEVTYPE_NULLREF
:
135 if (force_sw
&& !strcmp(force_sw
, "0")) {
136 *ppScreen
= This
->ctx
->hal
;
139 *ppScreen
= This
->ctx
->ref
;
143 user_assert(!"Invalid device type", D3DERR_INVALIDCALL
);
146 if (!*ppScreen
) { return D3DERR_NOTAVAILABLE
; }
152 NineAdapter9_GetAdapterIdentifier( struct NineAdapter9
*This
,
154 D3DADAPTER_IDENTIFIER9
*pIdentifier
)
156 DBG("This=%p Flags=%x pIdentifier=%p\n", This
, Flags
, pIdentifier
);
158 /* regarding flags, MSDN has this to say:
159 * Flags sets the WHQLLevel member of D3DADAPTER_IDENTIFIER9. Flags can be
160 * set to either 0 or D3DENUM_WHQL_LEVEL. If D3DENUM_WHQL_LEVEL is
161 * specified, this call can connect to the Internet to download new
162 * Microsoft Windows Hardware Quality Labs (WHQL) certificates.
163 * so let's just ignore it. */
164 *pIdentifier
= This
->ctx
->identifier
;
168 static inline boolean
169 backbuffer_format( D3DFORMAT dfmt
,
173 if (dfmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
175 if ((dfmt
== D3DFMT_A2R10G10B10
&& bfmt
== dfmt
) ||
176 (dfmt
== D3DFMT_X8R8G8B8
&& (bfmt
== dfmt
||
177 bfmt
== D3DFMT_A8R8G8B8
)) ||
178 (dfmt
== D3DFMT_X1R5G5B5
&& (bfmt
== dfmt
||
179 bfmt
== D3DFMT_A1R5G5B5
)) ||
180 (dfmt
== D3DFMT_R5G6B5
&& bfmt
== dfmt
)) {
188 NineAdapter9_CheckDeviceType( struct NineAdapter9
*This
,
190 D3DFORMAT AdapterFormat
,
191 D3DFORMAT BackBufferFormat
,
194 struct pipe_screen
*screen
;
195 enum pipe_format dfmt
, bfmt
;
198 DBG("This=%p DevType=%s AdapterFormat=%s BackBufferFormat=%s "
199 "bWindowed=%i\n", This
, nine_D3DDEVTYPE_to_str(DevType
),
200 d3dformat_to_string(AdapterFormat
),
201 d3dformat_to_string(BackBufferFormat
), bWindowed
);
203 user_assert(backbuffer_format(AdapterFormat
, BackBufferFormat
, bWindowed
),
204 D3DERR_NOTAVAILABLE
);
206 hr
= NineAdapter9_GetScreen(This
, DevType
, &screen
);
207 if (FAILED(hr
)) { return hr
; }
209 /* The display format is not handled in Nine. We always present an XRGB8888
210 * buffer (and the display server will eventually do the conversion). We probably
211 * don't need to check for anything for the adapter format support, since if the
212 * display server advertise support, it will likely be able to do the conversion.
213 * We do the approximation that a format is available in the display server if
214 * the format passes with NINE_BIND_BACKBUFFER_FLAGS */
215 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
,
217 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
218 bfmt
= d3d9_to_pipe_format_checked(screen
, BackBufferFormat
, PIPE_TEXTURE_2D
,
220 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
221 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
222 DBG("Unsupported Adapter/BackBufferFormat.\n");
223 return D3DERR_NOTAVAILABLE
;
229 static inline boolean
230 display_format( D3DFORMAT fmt
,
233 /* http://msdn.microsoft.com/en-us/library/bb172558(v=VS.85).aspx#BackBuffer_or_Display_Formats */
234 static const D3DFORMAT allowed
[] = {
242 if (fmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
244 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
245 if (fmt
== allowed
[i
]) { return TRUE
; }
251 NineAdapter9_CheckDeviceFormat( struct NineAdapter9
*This
,
252 D3DDEVTYPE DeviceType
,
253 D3DFORMAT AdapterFormat
,
255 D3DRESOURCETYPE RType
,
256 D3DFORMAT CheckFormat
)
258 struct pipe_screen
*screen
;
261 enum pipe_texture_target target
;
265 /* Check adapter format. */
267 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This
,
268 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
));
269 DBG("Usage=%x RType=%u CheckFormat=%s\n", Usage
, RType
,
270 d3dformat_to_string(CheckFormat
));
272 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_INVALIDCALL
);
274 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
277 pf
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
278 PIPE_BIND_DISPLAY_TARGET
|
279 PIPE_BIND_SHARED
, FALSE
, FALSE
);
280 if (pf
== PIPE_FORMAT_NONE
) {
281 DBG("AdapterFormat %s not available.\n",
282 d3dformat_to_string(AdapterFormat
));
283 return D3DERR_NOTAVAILABLE
;
286 /* Check actual format. */
289 case D3DRTYPE_SURFACE
: target
= PIPE_TEXTURE_2D
; break;
290 case D3DRTYPE_TEXTURE
: target
= PIPE_TEXTURE_2D
; break;
291 case D3DRTYPE_CUBETEXTURE
: target
= PIPE_TEXTURE_CUBE
; break;
292 case D3DRTYPE_VOLUME
: target
= PIPE_TEXTURE_3D
; break;
293 case D3DRTYPE_VOLUMETEXTURE
: target
= PIPE_TEXTURE_3D
; break;
294 case D3DRTYPE_VERTEXBUFFER
: target
= PIPE_BUFFER
; break;
295 case D3DRTYPE_INDEXBUFFER
: target
= PIPE_BUFFER
; break;
297 user_assert(0, D3DERR_INVALIDCALL
);
301 if (Usage
& D3DUSAGE_RENDERTARGET
) bind
|= PIPE_BIND_RENDER_TARGET
;
302 if (Usage
& D3DUSAGE_DEPTHSTENCIL
) {
303 if (!depth_stencil_format(CheckFormat
))
304 return D3DERR_NOTAVAILABLE
;
305 bind
|= d3d9_get_pipe_depth_format_bindings(CheckFormat
);
308 /* API hack because setting RT[0] to NULL is forbidden */
309 if (CheckFormat
== D3DFMT_NULL
&& bind
== PIPE_BIND_RENDER_TARGET
&&
310 (RType
== D3DRTYPE_SURFACE
||
311 RType
== D3DRTYPE_TEXTURE
))
315 if (CheckFormat
== D3DFMT_RESZ
&& bind
== PIPE_BIND_RENDER_TARGET
&&
316 RType
== D3DRTYPE_SURFACE
)
317 return screen
->get_param(screen
, PIPE_CAP_MULTISAMPLE_Z_RESOLVE
) ?
318 D3D_OK
: D3DERR_NOTAVAILABLE
;
321 if (CheckFormat
== D3DFMT_ATOC
&& RType
== D3DRTYPE_SURFACE
)
324 if ((Usage
& D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
) &&
325 (Usage
& D3DUSAGE_RENDERTARGET
))
326 bind
|= PIPE_BIND_BLENDABLE
;
328 if (Usage
& D3DUSAGE_DMAP
) {
329 DBG("D3DUSAGE_DMAP not available\n");
330 return D3DERR_NOTAVAILABLE
; /* TODO: displacement mapping */
334 case D3DRTYPE_TEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
335 case D3DRTYPE_CUBETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
336 case D3DRTYPE_VOLUMETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
337 case D3DRTYPE_VERTEXBUFFER
: bind
|= PIPE_BIND_VERTEX_BUFFER
; break;
338 case D3DRTYPE_INDEXBUFFER
: bind
|= PIPE_BIND_INDEX_BUFFER
; break;
339 case D3DRTYPE_SURFACE
:
340 if (!(Usage
& D3DUSAGE_DEPTHSTENCIL
))
341 bind
|= PIPE_BIND_SAMPLER_VIEW
; /* StretchRect */
342 /* Offscreen surface support: Usage = 0.
343 * In practice drivers are very restrictive on the formats supported.
344 * Basically a few common formats + YUV and compressed formats. The
345 * reason is that offscreen surface are useful only for directdraw
346 * compatibility (a WONTIMPL of nine) + format conversion (useful in
347 * particular for YUV because the format was not advertised for textures
350 bind
|= PIPE_BIND_RENDER_TARGET
; /* A current requirement of our impl, which we should get rid of. */
356 srgb
= (Usage
& (D3DUSAGE_QUERY_SRGBREAD
| D3DUSAGE_QUERY_SRGBWRITE
)) != 0;
357 pf
= d3d9_to_pipe_format_checked(screen
, CheckFormat
, target
,
358 0, bind
, srgb
, FALSE
);
359 if (pf
== PIPE_FORMAT_NONE
) {
360 DBG("NOT AVAILABLE\n");
361 return D3DERR_NOTAVAILABLE
;
364 /* we support ATI1 and ATI2 hack only for 2D and Cube textures */
365 if (RType
!= D3DRTYPE_TEXTURE
&& RType
!= D3DRTYPE_CUBETEXTURE
&&
366 (CheckFormat
== D3DFMT_ATI1
|| CheckFormat
== D3DFMT_ATI2
))
367 return D3DERR_NOTAVAILABLE
;
368 /* if (Usage & D3DUSAGE_NONSECURE) { don't know the implications of this } */
369 /* if (Usage & D3DUSAGE_SOFTWAREPROCESSING) { we can always support this } */
371 if ((Usage
& D3DUSAGE_AUTOGENMIPMAP
) && !(bind
& PIPE_BIND_SAMPLER_VIEW
))
372 return D3DOK_NOAUTOGEN
;
377 NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9
*This
,
378 D3DDEVTYPE DeviceType
,
379 D3DFORMAT SurfaceFormat
,
381 D3DMULTISAMPLE_TYPE MultiSampleType
,
382 DWORD
*pQualityLevels
)
384 struct pipe_screen
*screen
;
389 DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
390 "pQualityLevels=%p\n", This
, nine_D3DDEVTYPE_to_str(DeviceType
),
391 d3dformat_to_string(SurfaceFormat
), Windowed
, MultiSampleType
,
394 if (pQualityLevels
) {
395 /* In error cases return only 1 quality level supported */
398 user_assert(MultiSampleType
<= D3DMULTISAMPLE_16_SAMPLES
, D3DERR_INVALIDCALL
);
400 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
404 if (depth_stencil_format(SurfaceFormat
))
405 bind
= d3d9_get_pipe_depth_format_bindings(SurfaceFormat
);
406 else /* render-target */
407 bind
= PIPE_BIND_SAMPLER_VIEW
| PIPE_BIND_RENDER_TARGET
;
409 pf
= d3d9_to_pipe_format_checked(screen
, SurfaceFormat
, PIPE_TEXTURE_2D
,
410 0, PIPE_BIND_SAMPLER_VIEW
, FALSE
, FALSE
);
412 if (pf
== PIPE_FORMAT_NONE
&& SurfaceFormat
!= D3DFMT_NULL
) {
413 DBG("%s not available.\n", d3dformat_to_string(SurfaceFormat
));
414 return D3DERR_INVALIDCALL
;
417 pf
= d3d9_to_pipe_format_checked(screen
, SurfaceFormat
, PIPE_TEXTURE_2D
,
418 MultiSampleType
, bind
, FALSE
, FALSE
);
420 if (pf
== PIPE_FORMAT_NONE
&& SurfaceFormat
!= D3DFMT_NULL
) {
421 DBG("%s with %u samples not available.\n",
422 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
423 return D3DERR_NOTAVAILABLE
;
426 if (pQualityLevels
) {
427 /* NONMASKABLE MultiSampleType might have more than one quality level,
428 * while MASKABLE MultiSampleTypes have only one level.
429 * Advertise quality levels and map each level to a sample count. */
430 (void ) d3dmultisample_type_check(screen
, SurfaceFormat
,
431 &MultiSampleType
, D3DMULTISAMPLE_16_SAMPLES
, pQualityLevels
);
432 DBG("advertising %u quality levels\n", *pQualityLevels
);
439 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
440 D3DDEVTYPE DeviceType
,
441 D3DFORMAT AdapterFormat
,
442 D3DFORMAT RenderTargetFormat
,
443 D3DFORMAT DepthStencilFormat
)
445 struct pipe_screen
*screen
;
446 enum pipe_format dfmt
, bfmt
, zsfmt
;
449 DBG("This=%p DeviceType=%s AdapterFormat=%s "
450 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
451 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
452 d3dformat_to_string(RenderTargetFormat
),
453 d3dformat_to_string(DepthStencilFormat
));
455 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
456 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
458 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
459 if (FAILED(hr
)) { return hr
; }
461 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
462 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
463 bfmt
= d3d9_to_pipe_format_checked(screen
, RenderTargetFormat
,
465 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
466 if (RenderTargetFormat
== D3DFMT_NULL
)
468 zsfmt
= d3d9_to_pipe_format_checked(screen
, DepthStencilFormat
,
470 d3d9_get_pipe_depth_format_bindings(DepthStencilFormat
),
472 if (dfmt
== PIPE_FORMAT_NONE
||
473 bfmt
== PIPE_FORMAT_NONE
||
474 zsfmt
== PIPE_FORMAT_NONE
) {
475 return D3DERR_NOTAVAILABLE
;
482 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
483 D3DDEVTYPE DeviceType
,
484 D3DFORMAT SourceFormat
,
485 D3DFORMAT TargetFormat
)
487 /* MSDN says this tests whether a certain backbuffer format can be used in
488 * conjunction with a certain front buffer format. It's a little confusing
489 * but some one wiser might be able to figure this one out. XXX */
490 struct pipe_screen
*screen
;
491 enum pipe_format dfmt
, bfmt
;
494 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
495 nine_D3DDEVTYPE_to_str(DeviceType
),
496 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
498 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
499 D3DERR_NOTAVAILABLE
);
501 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
502 if (FAILED(hr
)) { return hr
; }
504 dfmt
= d3d9_to_pipe_format_checked(screen
, TargetFormat
, PIPE_TEXTURE_2D
, 1,
505 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
506 bfmt
= d3d9_to_pipe_format_checked(screen
, SourceFormat
, PIPE_TEXTURE_2D
, 1,
507 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
509 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
510 DBG("%s to %s not supported.\n",
511 d3dformat_to_string(SourceFormat
),
512 d3dformat_to_string(TargetFormat
));
513 return D3DERR_NOTAVAILABLE
;
520 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
521 D3DDEVTYPE DeviceType
,
524 struct pipe_screen
*screen
;
527 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
528 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
530 user_assert(pCaps
, D3DERR_INVALIDCALL
);
532 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
534 DBG("Failed to get pipe_screen.\n");
538 #define D3DPIPECAP(pcap, d3dcap) \
539 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
541 #define D3DNPIPECAP(pcap, d3dcap) \
542 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
544 pCaps
->DeviceType
= DeviceType
;
546 pCaps
->AdapterOrdinal
= 0;
550 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
551 /* D3DCAPS2_CANSHARERESOURCE | */
552 /* D3DCAPS2_CANCALIBRATEGAMMA | */
553 D3DCAPS2_DYNAMICTEXTURES
|
554 D3DCAPS2_FULLSCREENGAMMA
|
555 D3DCAPS2_CANAUTOGENMIPMAP
;
557 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
558 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
559 * and in discard mode. */
560 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
561 D3DCAPS3_COPY_TO_VIDMEM
|
562 D3DCAPS3_COPY_TO_SYSTEMMEM
|
563 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
565 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
566 D3DPRESENT_INTERVAL_ONE
|
567 D3DPRESENT_INTERVAL_TWO
|
568 D3DPRESENT_INTERVAL_THREE
|
569 D3DPRESENT_INTERVAL_FOUR
|
570 D3DPRESENT_INTERVAL_IMMEDIATE
;
571 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
573 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
574 D3DDEVCAPS_CANRENDERAFTERFLIP
|
575 D3DDEVCAPS_DRAWPRIMITIVES2
|
576 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
577 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
578 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
579 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
580 D3DDEVCAPS_HWRASTERIZATION
|
581 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
582 /*D3DDEVCAPS_NPATCHES |*/
583 D3DDEVCAPS_PUREDEVICE
|
584 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
585 /*D3DDEVCAPS_RTPATCHES |*/
586 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
587 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
588 D3DDEVCAPS_TEXTURENONLOCALVIDMEM
|
589 /* D3DDEVCAPS_TEXTURESYSTEMMEMORY |*/
590 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
591 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
592 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
594 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
595 D3DPMISCCAPS_CULLNONE
| /* XXX */
596 D3DPMISCCAPS_CULLCW
|
597 D3DPMISCCAPS_CULLCCW
|
598 D3DPMISCCAPS_COLORWRITEENABLE
|
599 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
600 /*D3DPMISCCAPS_CLIPTLVERTS |*/
601 D3DPMISCCAPS_TSSARGTEMP
|
602 D3DPMISCCAPS_BLENDOP
|
603 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
604 D3DPMISCCAPS_PERSTAGECONSTANT
|
605 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO: advertise if Ex and dx10 able card */
606 D3DPMISCCAPS_FOGANDSPECULARALPHA
| /* Note: documentation of the flag is wrong */
607 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
608 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
609 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
610 D3DPMISCCAPS_FOGVERTEXCLAMPED
;
611 if (!screen
->get_param(screen
, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
))
612 pCaps
->PrimitiveMiscCaps
|= D3DPMISCCAPS_CLIPTLVERTS
;
615 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
616 D3DPRASTERCAPS_COLORPERSPECTIVE
|
617 D3DPRASTERCAPS_DITHER
|
618 D3DPRASTERCAPS_DEPTHBIAS
|
619 D3DPRASTERCAPS_FOGRANGE
|
620 D3DPRASTERCAPS_FOGTABLE
|
621 D3DPRASTERCAPS_FOGVERTEX
|
622 D3DPRASTERCAPS_MIPMAPLODBIAS
|
623 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
624 D3DPRASTERCAPS_SCISSORTEST
|
625 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
626 /*D3DPRASTERCAPS_WBUFFER |*/
627 D3DPRASTERCAPS_WFOG
|
628 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
629 D3DPRASTERCAPS_ZFOG
|
630 D3DPRASTERCAPS_ZTEST
;
632 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
635 D3DPCMPCAPS_LESSEQUAL
|
636 D3DPCMPCAPS_GREATER
|
637 D3DPCMPCAPS_NOTEQUAL
|
638 D3DPCMPCAPS_GREATEREQUAL
|
641 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
643 D3DPBLENDCAPS_SRCCOLOR
|
644 D3DPBLENDCAPS_INVSRCCOLOR
|
645 D3DPBLENDCAPS_SRCALPHA
|
646 D3DPBLENDCAPS_INVSRCALPHA
|
647 D3DPBLENDCAPS_DESTALPHA
|
648 D3DPBLENDCAPS_INVDESTALPHA
|
649 D3DPBLENDCAPS_DESTCOLOR
|
650 D3DPBLENDCAPS_INVDESTCOLOR
|
651 D3DPBLENDCAPS_SRCALPHASAT
|
652 D3DPBLENDCAPS_BOTHSRCALPHA
|
653 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
654 D3DPBLENDCAPS_BLENDFACTOR
|
655 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
656 D3DPBLENDCAPS_INVSRCCOLOR2
|
657 D3DPBLENDCAPS_SRCCOLOR2
);
659 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
661 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_NEVER
|
664 D3DPCMPCAPS_LESSEQUAL
|
665 D3DPCMPCAPS_GREATER
|
666 D3DPCMPCAPS_NOTEQUAL
|
667 D3DPCMPCAPS_GREATEREQUAL
|
670 /* FLAT caps not legal for D3D9. */
671 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
672 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
673 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
674 D3DPSHADECAPS_FOGGOURAUD
;
677 D3DPTEXTURECAPS_ALPHA
|
678 D3DPTEXTURECAPS_ALPHAPALETTE
|
679 D3DPTEXTURECAPS_PERSPECTIVE
|
680 D3DPTEXTURECAPS_PROJECTED
|
681 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
682 D3DPTEXTURECAPS_CUBEMAP
|
683 D3DPTEXTURECAPS_VOLUMEMAP
|
684 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
685 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
686 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
687 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
688 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
689 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
690 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
692 pCaps
->TextureFilterCaps
=
693 D3DPTFILTERCAPS_MINFPOINT
|
694 D3DPTFILTERCAPS_MINFLINEAR
|
695 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
696 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
697 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
698 D3DPTFILTERCAPS_MIPFPOINT
|
699 D3DPTFILTERCAPS_MIPFLINEAR
|
700 D3DPTFILTERCAPS_MAGFPOINT
|
701 D3DPTFILTERCAPS_MAGFLINEAR
|
702 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
703 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
704 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
706 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
707 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
709 pCaps
->TextureAddressCaps
=
710 D3DPTADDRESSCAPS_BORDER
|
711 D3DPTADDRESSCAPS_INDEPENDENTUV
|
712 D3DPTADDRESSCAPS_WRAP
|
713 D3DPTADDRESSCAPS_MIRROR
|
714 D3DPTADDRESSCAPS_CLAMP
|
715 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
717 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
720 D3DLINECAPS_ALPHACMP
|
722 D3DLINECAPS_TEXTURE
|
725 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
726 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
729 pCaps
->MaxTextureWidth
=
730 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
731 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
732 pCaps
->MaxVolumeExtent
=
733 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
734 /* XXX values from wine */
735 pCaps
->MaxTextureRepeat
= 32768;
736 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
738 pCaps
->MaxAnisotropy
=
739 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
741 /* Values for GeForce 9600 GT */
742 pCaps
->MaxVertexW
= 1e10f
;
743 pCaps
->GuardBandLeft
= -1e9f
;
744 pCaps
->GuardBandTop
= -1e9f
;
745 pCaps
->GuardBandRight
= 1e9f
;
746 pCaps
->GuardBandBottom
= 1e9f
;
747 pCaps
->ExtentsAdjust
= 0.0f
;
750 D3DSTENCILCAPS_KEEP
|
751 D3DSTENCILCAPS_ZERO
|
752 D3DSTENCILCAPS_REPLACE
|
753 D3DSTENCILCAPS_INCRSAT
|
754 D3DSTENCILCAPS_DECRSAT
|
755 D3DSTENCILCAPS_INVERT
|
756 D3DSTENCILCAPS_INCR
|
757 D3DSTENCILCAPS_DECR
|
758 D3DSTENCILCAPS_TWOSIDED
;
761 8 | /* 8 textures max */
762 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
765 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
766 D3DTEXOPCAPS_SELECTARG1
|
767 D3DTEXOPCAPS_SELECTARG2
|
768 D3DTEXOPCAPS_MODULATE
|
769 D3DTEXOPCAPS_MODULATE2X
|
770 D3DTEXOPCAPS_MODULATE4X
|
772 D3DTEXOPCAPS_ADDSIGNED
|
773 D3DTEXOPCAPS_ADDSIGNED2X
|
774 D3DTEXOPCAPS_SUBTRACT
|
775 D3DTEXOPCAPS_ADDSMOOTH
|
776 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
777 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
778 D3DTEXOPCAPS_BLENDFACTORALPHA
|
779 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
780 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
781 D3DTEXOPCAPS_PREMODULATE
|
782 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
783 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
784 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
785 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
786 D3DTEXOPCAPS_BUMPENVMAP
|
787 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
788 D3DTEXOPCAPS_DOTPRODUCT3
|
789 D3DTEXOPCAPS_MULTIPLYADD
|
792 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
793 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
794 pCaps
->MaxSimultaneousTextures
= 8;
796 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
797 D3DVTXPCAPS_TEXGEN_SPHEREMAP
|
798 D3DVTXPCAPS_MATERIALSOURCE7
|
799 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
800 D3DVTXPCAPS_POSITIONALLIGHTS
|
801 D3DVTXPCAPS_LOCALVIEWER
|
802 D3DVTXPCAPS_TWEENING
|
803 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
805 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
806 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
807 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
808 pCaps
->MaxVertexBlendMatrixIndex
= 8; /* D3DTS_WORLDMATRIX(0..8) */
810 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
812 pCaps
->MaxPrimitiveCount
= 0x555555; /* <- wine, really 0xFFFFFFFF; */
813 pCaps
->MaxVertexIndex
= 0xFFFFFF; /* <- wine, really 0xFFFFFFFF */
815 _min(screen
->get_shader_param(screen
,
816 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
819 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
820 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
822 pCaps
->VertexShaderVersion
= D3DVS_VERSION(3,0);
824 /* VS 2 as well as 3.0 supports a minimum of 256 consts.
825 * Wine and d3d9 drivers for dx1x hw advertise 256. Just as them,
826 * advertise 256. Problem is with hw that can only do 256, because
827 * we need take a few slots for boolean and integer constants. For these
828 * we'll have to fail later if they use complex shaders. */
829 pCaps
->MaxVertexShaderConst
= NINE_MAX_CONST_F
;
831 pCaps
->PixelShaderVersion
= D3DPS_VERSION(3,0);
832 /* Value for GeForce 9600 GT */
833 pCaps
->PixelShader1xMaxValue
= 65504.f
;
835 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
836 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
837 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
838 /*D3DDEVCAPS2_DMAPNPATCH |*/
839 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
840 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
841 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
843 pCaps
->MasterAdapterOrdinal
= 0;
844 pCaps
->AdapterOrdinalInGroup
= 0;
845 pCaps
->NumberOfAdaptersInGroup
= 1;
848 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
849 pCaps
->Reserved5
= 0;
851 /* XXX: use is_format_supported */
852 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
860 D3DDTCAPS_FLOAT16_2
|
863 pCaps
->NumSimultaneousRTs
=
864 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
865 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
866 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
868 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
869 D3DPTFILTERCAPS_MINFLINEAR
|
870 D3DPTFILTERCAPS_MAGFPOINT
|
871 D3DPTFILTERCAPS_MAGFLINEAR
;
874 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
875 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
876 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
877 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
878 pCaps
->VS20Caps
.NumTemps
=
879 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
880 PIPE_SHADER_CAP_MAX_TEMPS
);
881 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
882 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
883 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
885 /* also check for values < 0, because get_shader_param may return unsigned */
886 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
887 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
888 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
889 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
890 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
891 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
892 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
893 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
894 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
895 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
896 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
899 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
900 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
901 D3DPS20CAPS_PREDICATION
;
902 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
903 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
904 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
905 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
906 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
907 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
908 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
909 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
910 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
911 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
912 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
913 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
914 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
915 pCaps
->PS20Caps
.NumTemps
=
916 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
917 PIPE_SHADER_CAP_MAX_TEMPS
);
918 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
919 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
920 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
921 pCaps
->PS20Caps
.NumInstructionSlots
=
922 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
923 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
925 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
926 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
927 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
928 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
929 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
930 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
931 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
932 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
933 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
934 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
935 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
936 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
937 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
938 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
941 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
942 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
943 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
944 ~(D3DPTFILTERCAPS_MIPFPOINT
|
945 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
947 pCaps
->VertexTextureFilterCaps
= 0;
949 pCaps
->MaxVertexShader30InstructionSlots
=
950 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
951 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
952 pCaps
->MaxPixelShader30InstructionSlots
=
953 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
954 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
955 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
956 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
957 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
958 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
959 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
960 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
962 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
963 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
964 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
966 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
967 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
973 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
975 D3DDEVTYPE DeviceType
,
978 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
980 ID3DPresentGroup
*pPresentationGroup
,
981 IDirect3DDevice9
**ppReturnedDeviceInterface
)
983 struct pipe_screen
*screen
;
984 D3DDEVICE_CREATION_PARAMETERS params
;
989 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
990 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
991 "ppReturnedDeviceInterface=%p\n", This
,
992 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
993 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
995 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
997 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
999 return D3DERR_NOTAVAILABLE
;
1002 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1004 DBG("Failed to get pipe_screen.\n");
1008 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1010 DBG("Failed to get device caps.\n");
1014 params
.AdapterOrdinal
= RealAdapter
;
1015 params
.DeviceType
= DeviceType
;
1016 params
.hFocusWindow
= hFocusWindow
;
1017 params
.BehaviorFlags
= BehaviorFlags
;
1019 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1020 pD3D9
, pPresentationGroup
, This
->ctx
, FALSE
, NULL
,
1021 (struct NineDevice9
**)ppReturnedDeviceInterface
,
1024 DBG("Failed to create device.\n");
1027 DBG("NineDevice9 created successfully.\n");
1033 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1035 D3DDEVTYPE DeviceType
,
1037 DWORD BehaviorFlags
,
1038 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1039 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1040 IDirect3D9Ex
*pD3D9Ex
,
1041 ID3DPresentGroup
*pPresentationGroup
,
1042 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1044 struct pipe_screen
*screen
;
1045 D3DDEVICE_CREATION_PARAMETERS params
;
1050 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1051 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1052 "ppReturnedDeviceInterface=%p\n", This
,
1053 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1054 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1056 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1058 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1060 return D3DERR_NOTAVAILABLE
;
1063 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1065 DBG("Failed to get pipe_screen.\n");
1069 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1071 DBG("Failed to get device caps.\n");
1075 params
.AdapterOrdinal
= RealAdapter
;
1076 params
.DeviceType
= DeviceType
;
1077 params
.hFocusWindow
= hFocusWindow
;
1078 params
.BehaviorFlags
= BehaviorFlags
;
1080 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1081 pFullscreenDisplayMode
,
1082 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1083 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
,
1086 DBG("Failed to create device.\n");
1089 DBG("NineDevice9Ex created successfully.\n");
1094 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1095 (void *)NineUnknown_QueryInterface
,
1096 (void *)NineUnknown_AddRef
,
1097 (void *)NineUnknown_Release
,
1098 (void *)NineAdapter9_GetAdapterIdentifier
,
1099 (void *)NineAdapter9_CheckDeviceType
,
1100 (void *)NineAdapter9_CheckDeviceFormat
,
1101 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1102 (void *)NineAdapter9_CheckDepthStencilMatch
,
1103 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1104 (void *)NineAdapter9_GetDeviceCaps
,
1105 (void *)NineAdapter9_CreateDevice
,
1106 (void *)NineAdapter9_CreateDeviceEx
1109 static const GUID
*NineAdapter9_IIDs
[] = {
1116 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1117 struct NineAdapter9
**ppOut
)
1119 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);