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 0, PIPE_BIND_SAMPLER_VIEW
, FALSE
, FALSE
);
406 if (pf
== PIPE_FORMAT_NONE
&& SurfaceFormat
!= D3DFMT_NULL
) {
407 DBG("%s not available.\n", d3dformat_to_string(SurfaceFormat
));
408 return D3DERR_INVALIDCALL
;
411 pf
= d3d9_to_pipe_format_checked(screen
, SurfaceFormat
, PIPE_TEXTURE_2D
,
412 MultiSampleType
, bind
, FALSE
, FALSE
);
414 if (pf
== PIPE_FORMAT_NONE
&& SurfaceFormat
!= D3DFMT_NULL
) {
415 DBG("%s with %u samples not available.\n",
416 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
417 return D3DERR_NOTAVAILABLE
;
420 if (pQualityLevels
) {
421 /* NONMASKABLE MultiSampleType might have more than one quality level,
422 * while MASKABLE MultiSampleTypes have only one level.
423 * Advertise quality levels and map each level to a sample count. */
424 (void ) d3dmultisample_type_check(screen
, SurfaceFormat
,
425 &MultiSampleType
, D3DMULTISAMPLE_16_SAMPLES
, pQualityLevels
);
426 DBG("advertising %u quality levels\n", *pQualityLevels
);
433 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
434 D3DDEVTYPE DeviceType
,
435 D3DFORMAT AdapterFormat
,
436 D3DFORMAT RenderTargetFormat
,
437 D3DFORMAT DepthStencilFormat
)
439 struct pipe_screen
*screen
;
440 enum pipe_format dfmt
, bfmt
, zsfmt
;
443 DBG("This=%p DeviceType=%s AdapterFormat=%s "
444 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
445 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
446 d3dformat_to_string(RenderTargetFormat
),
447 d3dformat_to_string(DepthStencilFormat
));
449 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
450 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
452 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
453 if (FAILED(hr
)) { return hr
; }
455 dfmt
= d3d9_to_pipe_format_checked(screen
, AdapterFormat
, PIPE_TEXTURE_2D
, 0,
456 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
457 bfmt
= d3d9_to_pipe_format_checked(screen
, RenderTargetFormat
,
459 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
460 if (RenderTargetFormat
== D3DFMT_NULL
)
462 zsfmt
= d3d9_to_pipe_format_checked(screen
, DepthStencilFormat
,
464 d3d9_get_pipe_depth_format_bindings(DepthStencilFormat
),
466 if (dfmt
== PIPE_FORMAT_NONE
||
467 bfmt
== PIPE_FORMAT_NONE
||
468 zsfmt
== PIPE_FORMAT_NONE
) {
469 return D3DERR_NOTAVAILABLE
;
476 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
477 D3DDEVTYPE DeviceType
,
478 D3DFORMAT SourceFormat
,
479 D3DFORMAT TargetFormat
)
481 /* MSDN says this tests whether a certain backbuffer format can be used in
482 * conjunction with a certain front buffer format. It's a little confusing
483 * but some one wiser might be able to figure this one out. XXX */
484 struct pipe_screen
*screen
;
485 enum pipe_format dfmt
, bfmt
;
488 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
489 nine_D3DDEVTYPE_to_str(DeviceType
),
490 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
492 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
493 D3DERR_NOTAVAILABLE
);
495 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
496 if (FAILED(hr
)) { return hr
; }
498 dfmt
= d3d9_to_pipe_format_checked(screen
, TargetFormat
, PIPE_TEXTURE_2D
, 1,
499 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
500 bfmt
= d3d9_to_pipe_format_checked(screen
, SourceFormat
, PIPE_TEXTURE_2D
, 1,
501 NINE_BIND_BACKBUFFER_FLAGS
, FALSE
, FALSE
);
503 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
504 DBG("%s to %s not supported.\n",
505 d3dformat_to_string(SourceFormat
),
506 d3dformat_to_string(TargetFormat
));
507 return D3DERR_NOTAVAILABLE
;
514 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
515 D3DDEVTYPE DeviceType
,
518 struct pipe_screen
*screen
;
521 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
522 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
524 user_assert(pCaps
, D3DERR_INVALIDCALL
);
526 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
528 DBG("Failed to get pipe_screen.\n");
532 #define D3DPIPECAP(pcap, d3dcap) \
533 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
535 #define D3DNPIPECAP(pcap, d3dcap) \
536 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
538 pCaps
->DeviceType
= DeviceType
;
540 pCaps
->AdapterOrdinal
= 0;
544 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
545 /* D3DCAPS2_CANSHARERESOURCE | */
546 /* D3DCAPS2_CANCALIBRATEGAMMA | */
547 D3DCAPS2_DYNAMICTEXTURES
|
548 D3DCAPS2_FULLSCREENGAMMA
|
549 D3DCAPS2_CANAUTOGENMIPMAP
;
551 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
552 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
553 * and in discard mode. */
554 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
555 D3DCAPS3_COPY_TO_VIDMEM
|
556 D3DCAPS3_COPY_TO_SYSTEMMEM
|
557 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
559 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
560 D3DPRESENT_INTERVAL_ONE
|
561 D3DPRESENT_INTERVAL_TWO
|
562 D3DPRESENT_INTERVAL_THREE
|
563 D3DPRESENT_INTERVAL_FOUR
|
564 D3DPRESENT_INTERVAL_IMMEDIATE
;
565 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
567 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
568 D3DDEVCAPS_CANRENDERAFTERFLIP
|
569 D3DDEVCAPS_DRAWPRIMITIVES2
|
570 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
571 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
572 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
573 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
574 D3DDEVCAPS_HWRASTERIZATION
|
575 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
576 /*D3DDEVCAPS_NPATCHES |*/
577 D3DDEVCAPS_PUREDEVICE
|
578 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
579 /*D3DDEVCAPS_RTPATCHES |*/
580 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
581 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
582 D3DDEVCAPS_TEXTURENONLOCALVIDMEM
|
583 /* D3DDEVCAPS_TEXTURESYSTEMMEMORY |*/
584 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
585 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
586 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
588 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
589 D3DPMISCCAPS_CULLNONE
| /* XXX */
590 D3DPMISCCAPS_CULLCW
|
591 D3DPMISCCAPS_CULLCCW
|
592 D3DPMISCCAPS_COLORWRITEENABLE
|
593 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
594 /*D3DPMISCCAPS_CLIPTLVERTS |*/
595 D3DPMISCCAPS_TSSARGTEMP
|
596 D3DPMISCCAPS_BLENDOP
|
597 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
598 D3DPMISCCAPS_PERSTAGECONSTANT
|
599 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO */
600 D3DPMISCCAPS_FOGANDSPECULARALPHA
| /* Note: documentation of the flag is wrong */
601 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
602 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
603 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
604 D3DPMISCCAPS_FOGVERTEXCLAMPED
;
605 if (!screen
->get_param(screen
, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
))
606 pCaps
->PrimitiveMiscCaps
|= D3DPMISCCAPS_CLIPTLVERTS
;
609 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
610 D3DPRASTERCAPS_COLORPERSPECTIVE
|
611 D3DPRASTERCAPS_DITHER
|
612 D3DPRASTERCAPS_DEPTHBIAS
|
613 D3DPRASTERCAPS_FOGRANGE
|
614 D3DPRASTERCAPS_FOGTABLE
|
615 D3DPRASTERCAPS_FOGVERTEX
|
616 D3DPRASTERCAPS_MIPMAPLODBIAS
|
617 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
618 D3DPRASTERCAPS_SCISSORTEST
|
619 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
620 /*D3DPRASTERCAPS_WBUFFER |*/
621 D3DPRASTERCAPS_WFOG
|
622 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
623 D3DPRASTERCAPS_ZFOG
|
624 D3DPRASTERCAPS_ZTEST
;
626 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
629 D3DPCMPCAPS_LESSEQUAL
|
630 D3DPCMPCAPS_GREATER
|
631 D3DPCMPCAPS_NOTEQUAL
|
632 D3DPCMPCAPS_GREATEREQUAL
|
635 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
637 D3DPBLENDCAPS_SRCCOLOR
|
638 D3DPBLENDCAPS_INVSRCCOLOR
|
639 D3DPBLENDCAPS_SRCALPHA
|
640 D3DPBLENDCAPS_INVSRCALPHA
|
641 D3DPBLENDCAPS_DESTALPHA
|
642 D3DPBLENDCAPS_INVDESTALPHA
|
643 D3DPBLENDCAPS_DESTCOLOR
|
644 D3DPBLENDCAPS_INVDESTCOLOR
|
645 D3DPBLENDCAPS_SRCALPHASAT
|
646 D3DPBLENDCAPS_BOTHSRCALPHA
|
647 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
648 D3DPBLENDCAPS_BLENDFACTOR
|
649 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
650 D3DPBLENDCAPS_INVSRCCOLOR2
|
651 D3DPBLENDCAPS_SRCCOLOR2
);
653 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
655 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_NEVER
|
658 D3DPCMPCAPS_LESSEQUAL
|
659 D3DPCMPCAPS_GREATER
|
660 D3DPCMPCAPS_NOTEQUAL
|
661 D3DPCMPCAPS_GREATEREQUAL
|
664 /* FLAT caps not legal for D3D9. */
665 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
666 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
667 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
668 D3DPSHADECAPS_FOGGOURAUD
;
671 D3DPTEXTURECAPS_ALPHA
|
672 D3DPTEXTURECAPS_ALPHAPALETTE
|
673 D3DPTEXTURECAPS_PERSPECTIVE
|
674 D3DPTEXTURECAPS_PROJECTED
|
675 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
676 D3DPTEXTURECAPS_CUBEMAP
|
677 D3DPTEXTURECAPS_VOLUMEMAP
|
678 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
679 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
680 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
681 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
682 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
683 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
684 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
686 pCaps
->TextureFilterCaps
=
687 D3DPTFILTERCAPS_MINFPOINT
|
688 D3DPTFILTERCAPS_MINFLINEAR
|
689 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
690 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
691 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
692 D3DPTFILTERCAPS_MIPFPOINT
|
693 D3DPTFILTERCAPS_MIPFLINEAR
|
694 D3DPTFILTERCAPS_MAGFPOINT
|
695 D3DPTFILTERCAPS_MAGFLINEAR
|
696 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
697 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
698 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
700 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
701 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
703 pCaps
->TextureAddressCaps
=
704 D3DPTADDRESSCAPS_BORDER
|
705 D3DPTADDRESSCAPS_INDEPENDENTUV
|
706 D3DPTADDRESSCAPS_WRAP
|
707 D3DPTADDRESSCAPS_MIRROR
|
708 D3DPTADDRESSCAPS_CLAMP
|
709 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
711 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
714 D3DLINECAPS_ALPHACMP
|
716 D3DLINECAPS_TEXTURE
|
719 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
720 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
723 pCaps
->MaxTextureWidth
=
724 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
725 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
726 pCaps
->MaxVolumeExtent
=
727 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
728 /* XXX values from wine */
729 pCaps
->MaxTextureRepeat
= 32768;
730 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
732 pCaps
->MaxAnisotropy
=
733 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
735 /* Values for GeForce 9600 GT */
736 pCaps
->MaxVertexW
= 1e10f
;
737 pCaps
->GuardBandLeft
= -1e9f
;
738 pCaps
->GuardBandTop
= -1e9f
;
739 pCaps
->GuardBandRight
= 1e9f
;
740 pCaps
->GuardBandBottom
= 1e9f
;
741 pCaps
->ExtentsAdjust
= 0.0f
;
744 D3DSTENCILCAPS_KEEP
|
745 D3DSTENCILCAPS_ZERO
|
746 D3DSTENCILCAPS_REPLACE
|
747 D3DSTENCILCAPS_INCRSAT
|
748 D3DSTENCILCAPS_DECRSAT
|
749 D3DSTENCILCAPS_INVERT
|
750 D3DSTENCILCAPS_INCR
|
751 D3DSTENCILCAPS_DECR
|
752 D3DPIPECAP(TWO_SIDED_STENCIL
, D3DSTENCILCAPS_TWOSIDED
);
755 8 | /* 8 textures max */
756 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
759 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
760 D3DTEXOPCAPS_SELECTARG1
|
761 D3DTEXOPCAPS_SELECTARG2
|
762 D3DTEXOPCAPS_MODULATE
|
763 D3DTEXOPCAPS_MODULATE2X
|
764 D3DTEXOPCAPS_MODULATE4X
|
766 D3DTEXOPCAPS_ADDSIGNED
|
767 D3DTEXOPCAPS_ADDSIGNED2X
|
768 D3DTEXOPCAPS_SUBTRACT
|
769 D3DTEXOPCAPS_ADDSMOOTH
|
770 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
771 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
772 D3DTEXOPCAPS_BLENDFACTORALPHA
|
773 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
774 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
775 D3DTEXOPCAPS_PREMODULATE
|
776 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
777 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
778 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
779 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
780 D3DTEXOPCAPS_BUMPENVMAP
|
781 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
782 D3DTEXOPCAPS_DOTPRODUCT3
|
783 D3DTEXOPCAPS_MULTIPLYADD
|
786 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
787 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
788 pCaps
->MaxSimultaneousTextures
= screen
->get_shader_param(screen
,
789 PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
);
790 if (pCaps
->MaxSimultaneousTextures
> NINE_MAX_SAMPLERS_PS
)
791 pCaps
->MaxSimultaneousTextures
= NINE_MAX_SAMPLERS_PS
;
793 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
794 D3DVTXPCAPS_TEXGEN_SPHEREMAP
|
795 D3DVTXPCAPS_MATERIALSOURCE7
|
796 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
797 D3DVTXPCAPS_POSITIONALLIGHTS
|
798 D3DVTXPCAPS_LOCALVIEWER
|
799 D3DVTXPCAPS_TWEENING
|
800 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
802 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
803 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
804 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
805 pCaps
->MaxVertexBlendMatrixIndex
= 8; /* D3DTS_WORLDMATRIX(0..8) */
807 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
809 pCaps
->MaxPrimitiveCount
= 0x555555; /* <- wine, really 0xFFFFFFFF; */
810 pCaps
->MaxVertexIndex
= 0xFFFFFF; /* <- wine, really 0xFFFFFFFF */
812 _min(screen
->get_shader_param(screen
,
813 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
816 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
817 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
819 pCaps
->VertexShaderVersion
= D3DVS_VERSION(3,0);
821 /* VS 2 as well as 3.0 supports a minimum of 256 consts.
822 * Wine and d3d9 drivers for dx1x hw advertise 256. Just as them,
823 * advertise 256. Problem is with hw that can only do 256, because
824 * we need take a few slots for boolean and integer constants. For these
825 * we'll have to fail later if they use complex shaders. */
826 pCaps
->MaxVertexShaderConst
= NINE_MAX_CONST_F
;
828 pCaps
->PixelShaderVersion
= D3DPS_VERSION(3,0);
829 /* Value for GeForce 9600 GT */
830 pCaps
->PixelShader1xMaxValue
= 65504.f
;
832 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
833 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
834 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
835 /*D3DDEVCAPS2_DMAPNPATCH |*/
836 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
837 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
838 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
840 pCaps
->MasterAdapterOrdinal
= 0;
841 pCaps
->AdapterOrdinalInGroup
= 0;
842 pCaps
->NumberOfAdaptersInGroup
= 1;
845 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
846 pCaps
->Reserved5
= 0;
848 /* XXX: use is_format_supported */
849 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
857 D3DDTCAPS_FLOAT16_2
|
860 pCaps
->NumSimultaneousRTs
=
861 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
862 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
863 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
865 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
866 D3DPTFILTERCAPS_MINFLINEAR
|
867 D3DPTFILTERCAPS_MAGFPOINT
|
868 D3DPTFILTERCAPS_MAGFLINEAR
;
871 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
872 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
873 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
874 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
875 pCaps
->VS20Caps
.NumTemps
=
876 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
877 PIPE_SHADER_CAP_MAX_TEMPS
);
878 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
879 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
880 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
882 /* also check for values < 0, because get_shader_param may return unsigned */
883 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
884 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
885 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
886 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
887 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
888 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
889 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
890 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
891 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
892 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
893 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
896 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
897 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
898 D3DPS20CAPS_PREDICATION
;
899 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
900 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
901 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
902 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
903 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
904 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
905 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
906 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
907 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
908 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
909 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
910 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
911 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
912 pCaps
->PS20Caps
.NumTemps
=
913 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
914 PIPE_SHADER_CAP_MAX_TEMPS
);
915 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
916 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
917 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
918 pCaps
->PS20Caps
.NumInstructionSlots
=
919 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
920 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
922 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
923 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
924 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
925 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
926 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
927 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
928 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
929 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
930 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
931 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
932 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
933 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
934 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
935 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
938 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
939 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
940 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
941 ~(D3DPTFILTERCAPS_MIPFPOINT
|
942 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
944 pCaps
->VertexTextureFilterCaps
= 0;
946 pCaps
->MaxVertexShader30InstructionSlots
=
947 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
948 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
949 pCaps
->MaxPixelShader30InstructionSlots
=
950 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
951 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
952 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
953 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
954 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
955 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
956 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
957 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
959 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
960 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
961 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
963 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
964 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
970 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
972 D3DDEVTYPE DeviceType
,
975 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
977 ID3DPresentGroup
*pPresentationGroup
,
978 IDirect3DDevice9
**ppReturnedDeviceInterface
)
980 struct pipe_screen
*screen
;
981 D3DDEVICE_CREATION_PARAMETERS params
;
986 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
987 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
988 "ppReturnedDeviceInterface=%p\n", This
,
989 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
990 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
992 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
994 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
996 return D3DERR_NOTAVAILABLE
;
999 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1001 DBG("Failed to get pipe_screen.\n");
1005 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1007 DBG("Failed to get device caps.\n");
1011 params
.AdapterOrdinal
= RealAdapter
;
1012 params
.DeviceType
= DeviceType
;
1013 params
.hFocusWindow
= hFocusWindow
;
1014 params
.BehaviorFlags
= BehaviorFlags
;
1016 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1017 pD3D9
, pPresentationGroup
, This
->ctx
, FALSE
, NULL
,
1018 (struct NineDevice9
**)ppReturnedDeviceInterface
,
1021 DBG("Failed to create device.\n");
1024 DBG("NineDevice9 created successfully.\n");
1030 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1032 D3DDEVTYPE DeviceType
,
1034 DWORD BehaviorFlags
,
1035 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1036 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1037 IDirect3D9Ex
*pD3D9Ex
,
1038 ID3DPresentGroup
*pPresentationGroup
,
1039 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1041 struct pipe_screen
*screen
;
1042 D3DDEVICE_CREATION_PARAMETERS params
;
1047 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1048 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1049 "ppReturnedDeviceInterface=%p\n", This
,
1050 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1051 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1053 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1055 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1057 return D3DERR_NOTAVAILABLE
;
1060 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1062 DBG("Failed to get pipe_screen.\n");
1066 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1068 DBG("Failed to get device caps.\n");
1072 params
.AdapterOrdinal
= RealAdapter
;
1073 params
.DeviceType
= DeviceType
;
1074 params
.hFocusWindow
= hFocusWindow
;
1075 params
.BehaviorFlags
= BehaviorFlags
;
1077 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1078 pFullscreenDisplayMode
,
1079 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1080 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
,
1083 DBG("Failed to create device.\n");
1086 DBG("NineDevice9Ex created successfully.\n");
1091 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1092 (void *)NineUnknown_QueryInterface
,
1093 (void *)NineUnknown_AddRef
,
1094 (void *)NineUnknown_Release
,
1095 (void *)NineAdapter9_GetAdapterIdentifier
,
1096 (void *)NineAdapter9_CheckDeviceType
,
1097 (void *)NineAdapter9_CheckDeviceFormat
,
1098 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1099 (void *)NineAdapter9_CheckDepthStencilMatch
,
1100 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1101 (void *)NineAdapter9_GetDeviceCaps
,
1102 (void *)NineAdapter9_CreateDevice
,
1103 (void *)NineAdapter9_CreateDeviceEx
1106 static const GUID
*NineAdapter9_IIDs
[] = {
1113 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1114 struct NineAdapter9
**ppOut
)
1116 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);