2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
24 #include "device9ex.h"
25 #include "nine_helpers.h"
26 #include "nine_defines.h"
27 #include "nine_pipe.h"
28 #include "nine_dump.h"
29 #include "util/u_math.h"
30 #include "util/u_format.h"
31 #include "util/u_dump.h"
33 #include "pipe/p_screen.h"
35 #define DBG_CHANNEL DBG_ADAPTER
38 NineAdapter9_ctor( struct NineAdapter9
*This
,
39 struct NineUnknownParams
*pParams
,
40 struct d3dadapter9_context
*pCTX
)
42 struct pipe_screen
*hal
= pCTX
->hal
;
43 HRESULT hr
= NineUnknown_ctor(&This
->base
, pParams
);
44 if (FAILED(hr
)) { return hr
; }
46 DBG("This=%p pParams=%p pCTX=%p\n", This
, pParams
, pCTX
);
47 nine_dump_D3DADAPTER_IDENTIFIER9(DBG_CHANNEL
, &pCTX
->identifier
);
50 if (!hal
->get_param(hal
, PIPE_CAP_CLIP_HALFZ
)) {
51 ERR("Driver doesn't support d3d9 coordinates\n");
52 return D3DERR_DRIVERINTERNALERROR
;
55 !This
->ctx
->ref
->get_param(This
->ctx
->ref
, PIPE_CAP_CLIP_HALFZ
)) {
56 ERR("Warning: Sotware rendering driver doesn't support d3d9 coordinates\n");
58 /* Old cards had tricks to bypass some restrictions to implement
59 * everything and fit tight the requirements: number of constants,
60 * number of temp registers, special behaviours, etc. Since we don't
61 * have access to all this, we need a bit more than what dx9 required.
62 * For example we have to use more than 32 temp registers to emulate
63 * behaviours, while some dx9 hw don't have more. As for sm2 hardware,
64 * we could support vs2 / ps2 for them but it needs some more care, and
65 * as these are very old, we choose to drop support for them */
67 /* checks minimum requirements, most are vs3/ps3 strict requirements */
68 if (!hal
->get_param(hal
, PIPE_CAP_SM3
) ||
69 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
70 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 256 * sizeof(float[4]) ||
71 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
72 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 244 * sizeof(float[4]) ||
73 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
74 PIPE_SHADER_CAP_MAX_TEMPS
) < 32 ||
75 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
76 PIPE_SHADER_CAP_MAX_TEMPS
) < 32 ||
77 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
78 PIPE_SHADER_CAP_MAX_INPUTS
) < 16 ||
79 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
80 PIPE_SHADER_CAP_MAX_INPUTS
) < 10) {
81 ERR("Your card is not supported by Gallium Nine. Minimum requirement "
82 "is >= r500, >= nv50, >= i965\n");
83 return D3DERR_DRIVERINTERNALERROR
;
86 if (hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
87 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) < 276 * sizeof(float[4]) || /* we put bool and int constants with float constants */
88 hal
->get_shader_param(hal
, PIPE_SHADER_VERTEX
,
89 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 || /* we use some more temp registers */
90 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
91 PIPE_SHADER_CAP_MAX_TEMPS
) < 40 ||
92 hal
->get_shader_param(hal
, PIPE_SHADER_FRAGMENT
,
93 PIPE_SHADER_CAP_MAX_INPUTS
) < 20) /* we don't pack inputs as much as we could */
94 ERR("Your card is at the limit of Gallium Nine requirements. Some games "
95 "may run into issues because requirements are too tight\n");
100 NineAdapter9_dtor( struct NineAdapter9
*This
)
102 struct d3dadapter9_context
*ctx
= This
->ctx
;
104 DBG("This=%p\n", This
);
106 NineUnknown_dtor(&This
->base
);
108 /* special case, call backend-specific dtor AFTER destroying this object
111 if (ctx
->destroy
) { ctx
->destroy(ctx
); }
116 NineAdapter9_GetScreen( struct NineAdapter9
*This
,
118 struct pipe_screen
**ppScreen
)
120 const char *force_sw
= getenv("D3D_ALWAYS_SOFTWARE");
123 if (force_sw
&& !strcmp(force_sw
, "1") && This
->ctx
->ref
) {
124 *ppScreen
= This
->ctx
->ref
;
127 *ppScreen
= This
->ctx
->hal
;
131 case D3DDEVTYPE_NULLREF
:
133 if (force_sw
&& !strcmp(force_sw
, "0")) {
134 *ppScreen
= This
->ctx
->hal
;
137 *ppScreen
= This
->ctx
->ref
;
141 user_assert(!"Invalid device type", D3DERR_INVALIDCALL
);
144 if (!*ppScreen
) { return D3DERR_NOTAVAILABLE
; }
150 NineAdapter9_GetAdapterIdentifier( struct NineAdapter9
*This
,
152 D3DADAPTER_IDENTIFIER9
*pIdentifier
)
154 DBG("This=%p Flags=%x pIdentifier=%p\n", This
, Flags
, pIdentifier
);
156 /* regarding flags, MSDN has this to say:
157 * Flags sets the WHQLLevel member of D3DADAPTER_IDENTIFIER9. Flags can be
158 * set to either 0 or D3DENUM_WHQL_LEVEL. If D3DENUM_WHQL_LEVEL is
159 * specified, this call can connect to the Internet to download new
160 * Microsoft Windows Hardware Quality Labs (WHQL) certificates.
161 * so let's just ignore it. */
162 *pIdentifier
= This
->ctx
->identifier
;
166 static INLINE boolean
167 backbuffer_format( D3DFORMAT dfmt
,
171 if (dfmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
173 if ((dfmt
== D3DFMT_A2R10G10B10
&& bfmt
== dfmt
) ||
174 (dfmt
== D3DFMT_X8R8G8B8
&& (bfmt
== dfmt
||
175 bfmt
== D3DFMT_A8R8G8B8
)) ||
176 (dfmt
== D3DFMT_X1R5G5B5
&& (bfmt
== dfmt
||
177 bfmt
== D3DFMT_A1R5G5B5
)) ||
178 (dfmt
== D3DFMT_R5G6B5
&& bfmt
== dfmt
)) {
186 NineAdapter9_CheckDeviceType( struct NineAdapter9
*This
,
188 D3DFORMAT AdapterFormat
,
189 D3DFORMAT BackBufferFormat
,
192 struct pipe_screen
*screen
;
193 enum pipe_format dfmt
, bfmt
;
196 DBG("This=%p DevType=%s AdapterFormat=%s BackBufferFormat=%s "
197 "bWindowed=%i\n", This
, nine_D3DDEVTYPE_to_str(DevType
),
198 d3dformat_to_string(AdapterFormat
),
199 d3dformat_to_string(BackBufferFormat
), bWindowed
);
201 user_assert(backbuffer_format(AdapterFormat
, BackBufferFormat
, bWindowed
),
202 D3DERR_NOTAVAILABLE
);
204 hr
= NineAdapter9_GetScreen(This
, DevType
, &screen
);
205 if (FAILED(hr
)) { return hr
; }
207 dfmt
= d3d9_to_pipe_format(AdapterFormat
);
208 bfmt
= d3d9_to_pipe_format(BackBufferFormat
);
209 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
210 DBG("Invalid Adapter/BackBufferFormat.\n");
211 return D3DERR_NOTAVAILABLE
;
214 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 1,
215 PIPE_BIND_DISPLAY_TARGET
|
217 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 1,
218 PIPE_BIND_DISPLAY_TARGET
|
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
;
262 /* Check adapter format. */
264 /* Nicer output if we only have the line at the end. */
266 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This
,
267 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
));
269 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_INVALIDCALL
);
271 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
274 pf
= d3d9_to_pipe_format(AdapterFormat
);
275 if (pf
== PIPE_FORMAT_NONE
||
276 !screen
->is_format_supported(screen
, pf
, PIPE_TEXTURE_2D
, 0,
277 PIPE_BIND_DISPLAY_TARGET
|
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
))
308 if (Usage
& D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
309 bind
|= PIPE_BIND_BLENDABLE
;
311 if (Usage
& D3DUSAGE_DMAP
) {
312 DBG("D3DUSAGE_DMAP not available\n");
313 return D3DERR_NOTAVAILABLE
; /* TODO: displacement mapping */
317 case D3DRTYPE_TEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
318 case D3DRTYPE_CUBETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
319 case D3DRTYPE_VOLUMETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
320 case D3DRTYPE_VERTEXBUFFER
: bind
|= PIPE_BIND_VERTEX_BUFFER
; break;
321 case D3DRTYPE_INDEXBUFFER
: bind
|= PIPE_BIND_INDEX_BUFFER
; break;
327 pf
= d3d9_to_pipe_format(CheckFormat
);
328 if (Usage
& (D3DUSAGE_QUERY_SRGBREAD
| D3DUSAGE_QUERY_SRGBWRITE
))
329 pf
= util_format_srgb(pf
);
331 DBG("Format=%s/%s Usage/Bind=%x/%d RType/Target=%u/%s\n", // replace %d to %s
332 d3dformat_to_string(CheckFormat
), util_format_name(pf
),
333 Usage
, bind
, // temporary simplified for merge, FIXME
334 /* Usage, util_dump_bind_flags(bind), */
335 RType
, util_dump_tex_target(target
, TRUE
));
337 if (pf
== PIPE_FORMAT_NONE
||
338 !screen
->is_format_supported(screen
, pf
, target
, 0, bind
)) {
339 DBG("NOT AVAILABLE\n");
340 return D3DERR_NOTAVAILABLE
;
343 /* we support ATI1 and ATI2 hack only for 2D textures */
344 if (RType
!= D3DRTYPE_TEXTURE
&& (CheckFormat
== D3DFMT_ATI1
|| CheckFormat
== D3DFMT_ATI2
))
345 return D3DERR_NOTAVAILABLE
;
346 /* if (Usage & D3DUSAGE_NONSECURE) { don't know the implications of this } */
347 /* if (Usage & D3DUSAGE_SOFTWAREPROCESSING) { we can always support this } */
349 if ((Usage
& D3DUSAGE_AUTOGENMIPMAP
) && !(bind
& PIPE_BIND_SAMPLER_VIEW
))
350 return D3DOK_NOAUTOGEN
;
355 NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9
*This
,
356 D3DDEVTYPE DeviceType
,
357 D3DFORMAT SurfaceFormat
,
359 D3DMULTISAMPLE_TYPE MultiSampleType
,
360 DWORD
*pQualityLevels
)
362 struct pipe_screen
*screen
;
367 DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
368 "pQualityLevels=%p\n", This
, nine_D3DDEVTYPE_to_str(DeviceType
),
369 d3dformat_to_string(SurfaceFormat
), Windowed
, MultiSampleType
,
372 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
376 pf
= d3d9_to_pipe_format(SurfaceFormat
);
377 bind
= util_format_is_depth_or_stencil(pf
) ?
378 PIPE_BIND_DEPTH_STENCIL
: PIPE_BIND_RENDER_TARGET
;
380 if (pf
== PIPE_FORMAT_NONE
||
381 !screen
->is_format_supported(screen
, pf
, PIPE_TEXTURE_2D
,
382 MultiSampleType
, bind
)) {
383 DBG("%s with %u samples not available.\n",
384 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
385 return D3DERR_NOTAVAILABLE
;
389 *pQualityLevels
= 1; /* gallium doesn't have quality levels */
394 static INLINE boolean
395 depth_stencil_format( D3DFORMAT fmt
)
397 static D3DFORMAT allowed
[] = {
405 D3DFMT_D32F_LOCKABLE
,
411 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
412 if (fmt
== allowed
[i
]) { return TRUE
; }
418 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
419 D3DDEVTYPE DeviceType
,
420 D3DFORMAT AdapterFormat
,
421 D3DFORMAT RenderTargetFormat
,
422 D3DFORMAT DepthStencilFormat
)
424 struct pipe_screen
*screen
;
425 enum pipe_format dfmt
, bfmt
, zsfmt
;
428 DBG("This=%p DeviceType=%s AdapterFormat=%s "
429 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
430 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
431 d3dformat_to_string(RenderTargetFormat
),
432 d3dformat_to_string(DepthStencilFormat
));
434 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
435 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
437 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
438 if (FAILED(hr
)) { return hr
; }
440 dfmt
= d3d9_to_pipe_format(AdapterFormat
);
441 bfmt
= d3d9_to_pipe_format(RenderTargetFormat
);
442 if (RenderTargetFormat
== D3DFMT_NULL
)
444 zsfmt
= d3d9_to_pipe_format(DepthStencilFormat
);
445 if (dfmt
== PIPE_FORMAT_NONE
||
446 bfmt
== PIPE_FORMAT_NONE
||
447 zsfmt
== PIPE_FORMAT_NONE
) {
448 return D3DERR_NOTAVAILABLE
;
451 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 0,
452 PIPE_BIND_DISPLAY_TARGET
|
454 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 0,
455 PIPE_BIND_RENDER_TARGET
) ||
456 !screen
->is_format_supported(screen
, zsfmt
, PIPE_TEXTURE_2D
, 0,
457 PIPE_BIND_DEPTH_STENCIL
)) {
458 return D3DERR_NOTAVAILABLE
;
465 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
466 D3DDEVTYPE DeviceType
,
467 D3DFORMAT SourceFormat
,
468 D3DFORMAT TargetFormat
)
470 /* MSDN says this tests whether a certain backbuffer format can be used in
471 * conjunction with a certain front buffer format. It's a little confusing
472 * but some one wiser might be able to figure this one out. XXX */
473 struct pipe_screen
*screen
;
474 enum pipe_format dfmt
, bfmt
;
477 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
478 nine_D3DDEVTYPE_to_str(DeviceType
),
479 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
481 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
482 D3DERR_NOTAVAILABLE
);
484 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
485 if (FAILED(hr
)) { return hr
; }
487 dfmt
= d3d9_to_pipe_format(TargetFormat
);
488 bfmt
= d3d9_to_pipe_format(SourceFormat
);
489 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
490 return D3DERR_NOTAVAILABLE
;
492 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 1,
493 PIPE_BIND_DISPLAY_TARGET
|
495 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 1,
496 PIPE_BIND_DISPLAY_TARGET
|
498 DBG("%s to %s not supported.\n",
499 d3dformat_to_string(SourceFormat
),
500 d3dformat_to_string(TargetFormat
));
501 return D3DERR_NOTAVAILABLE
;
508 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
509 D3DDEVTYPE DeviceType
,
512 struct pipe_screen
*screen
;
515 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
516 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
518 user_assert(pCaps
, D3DERR_INVALIDCALL
);
520 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
522 DBG("Failed to get pipe_screen.\n");
526 #define D3DPIPECAP(pcap, d3dcap) \
527 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
529 #define D3DNPIPECAP(pcap, d3dcap) \
530 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
532 pCaps
->DeviceType
= DeviceType
;
534 pCaps
->AdapterOrdinal
= 0;
538 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
539 /* D3DCAPS2_CANSHARERESOURCE | */
540 /* D3DCAPS2_CANCALIBRATEGAMMA | */
541 D3DCAPS2_DYNAMICTEXTURES
|
542 D3DCAPS2_FULLSCREENGAMMA
|
543 D3DCAPS2_CANAUTOGENMIPMAP
;
545 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
546 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
547 * and in discard mode. */
548 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
549 D3DCAPS3_COPY_TO_VIDMEM
|
550 D3DCAPS3_COPY_TO_SYSTEMMEM
|
551 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
553 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
554 D3DPRESENT_INTERVAL_ONE
|
555 D3DPRESENT_INTERVAL_TWO
|
556 D3DPRESENT_INTERVAL_THREE
|
557 D3DPRESENT_INTERVAL_FOUR
|
558 D3DPRESENT_INTERVAL_IMMEDIATE
;
559 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
561 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
562 D3DDEVCAPS_CANRENDERAFTERFLIP
|
563 D3DDEVCAPS_DRAWPRIMITIVES2
|
564 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
565 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
566 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
567 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
568 D3DDEVCAPS_HWRASTERIZATION
|
569 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
570 /*D3DDEVCAPS_NPATCHES |*/
571 D3DDEVCAPS_PUREDEVICE
|
572 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
573 /*D3DDEVCAPS_RTPATCHES |*/
574 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
575 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
576 /*D3DDEVCAPS_TEXTURENONLOCALVIDMEM |*/
577 D3DDEVCAPS_TEXTURESYSTEMMEMORY
|
578 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
579 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
580 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
582 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
583 D3DPMISCCAPS_CULLNONE
| /* XXX */
584 D3DPMISCCAPS_CULLCW
|
585 D3DPMISCCAPS_CULLCCW
|
586 D3DPMISCCAPS_COLORWRITEENABLE
|
587 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
588 /*D3DPMISCCAPS_CLIPTLVERTS |*/
589 D3DPMISCCAPS_TSSARGTEMP
|
590 D3DPMISCCAPS_BLENDOP
|
591 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
592 /*D3DPMISCCAPS_PERSTAGECONSTANT |*/
593 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO */
594 D3DPMISCCAPS_FOGANDSPECULARALPHA
|
595 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
596 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
597 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
598 /*D3DPMISCCAPS_FOGVERTEXCLAMPED*/0;
599 if (!screen
->get_param(screen
, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION
))
600 pCaps
->PrimitiveMiscCaps
|= D3DPMISCCAPS_CLIPTLVERTS
;
603 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
604 /*D3DPRASTERCAPS_COLORPERSPECTIVE |*/
605 D3DPRASTERCAPS_DITHER
|
606 D3DPRASTERCAPS_DEPTHBIAS
|
607 /*D3DPRASTERCAPS_FOGRANGE |*/
608 /*D3DPRASTERCAPS_FOGTABLE |*/
609 /*D3DPRASTERCAPS_FOGVERTEX |*/
610 D3DPRASTERCAPS_MIPMAPLODBIAS
|
611 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
612 D3DPRASTERCAPS_SCISSORTEST
|
613 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
614 /*D3DPRASTERCAPS_WBUFFER |*/
615 /*D3DPRASTERCAPS_WFOG |*/
616 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
617 /*D3DPRASTERCAPS_ZFOG |*/
618 D3DPRASTERCAPS_ZTEST
;
620 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
623 D3DPCMPCAPS_LESSEQUAL
|
624 D3DPCMPCAPS_GREATER
|
625 D3DPCMPCAPS_NOTEQUAL
|
626 D3DPCMPCAPS_GREATEREQUAL
|
629 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
631 D3DPBLENDCAPS_SRCCOLOR
|
632 D3DPBLENDCAPS_INVSRCCOLOR
|
633 D3DPBLENDCAPS_SRCALPHA
|
634 D3DPBLENDCAPS_INVSRCALPHA
|
635 D3DPBLENDCAPS_DESTALPHA
|
636 D3DPBLENDCAPS_INVDESTALPHA
|
637 D3DPBLENDCAPS_DESTCOLOR
|
638 D3DPBLENDCAPS_INVDESTCOLOR
|
639 D3DPBLENDCAPS_SRCALPHASAT
|
640 D3DPBLENDCAPS_BOTHSRCALPHA
|
641 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
642 D3DPBLENDCAPS_BLENDFACTOR
|
643 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
644 D3DPBLENDCAPS_INVSRCCOLOR2
|
645 D3DPBLENDCAPS_SRCCOLOR2
);
647 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
649 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_LESS
|
651 D3DPCMPCAPS_LESSEQUAL
|
652 D3DPCMPCAPS_GREATER
|
653 D3DPCMPCAPS_NOTEQUAL
|
654 D3DPCMPCAPS_GREATEREQUAL
|
657 /* FLAT caps not legal for D3D9. */
658 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
659 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
660 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
661 D3DPSHADECAPS_FOGGOURAUD
;
664 D3DPTEXTURECAPS_ALPHA
|
665 D3DPTEXTURECAPS_ALPHAPALETTE
|
666 D3DPTEXTURECAPS_PERSPECTIVE
|
667 D3DPTEXTURECAPS_PROJECTED
|
668 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
669 D3DPTEXTURECAPS_CUBEMAP
|
670 D3DPTEXTURECAPS_VOLUMEMAP
|
671 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
672 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
673 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
674 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
675 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
676 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
677 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
679 pCaps
->TextureFilterCaps
=
680 D3DPTFILTERCAPS_MINFPOINT
|
681 D3DPTFILTERCAPS_MINFLINEAR
|
682 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
683 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
684 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
685 D3DPTFILTERCAPS_MIPFPOINT
|
686 D3DPTFILTERCAPS_MIPFLINEAR
|
687 D3DPTFILTERCAPS_MAGFPOINT
|
688 D3DPTFILTERCAPS_MAGFLINEAR
|
689 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
690 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
691 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
693 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
694 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
696 pCaps
->TextureAddressCaps
=
697 D3DPTADDRESSCAPS_BORDER
|
698 D3DPTADDRESSCAPS_INDEPENDENTUV
|
699 D3DPTADDRESSCAPS_WRAP
|
700 D3DPTADDRESSCAPS_MIRROR
|
701 D3DPTADDRESSCAPS_CLAMP
|
702 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
704 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
707 D3DLINECAPS_ALPHACMP
|
709 D3DLINECAPS_TEXTURE
|
712 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
713 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
716 pCaps
->MaxTextureWidth
=
717 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
718 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
719 pCaps
->MaxVolumeExtent
=
720 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
721 /* XXX values from wine */
722 pCaps
->MaxTextureRepeat
= 32768;
723 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
725 pCaps
->MaxAnisotropy
=
726 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
728 pCaps
->MaxVertexW
= 1.0f
; /* XXX */
729 pCaps
->GuardBandLeft
= screen
->get_paramf(screen
,
730 PIPE_CAPF_GUARD_BAND_LEFT
);
731 pCaps
->GuardBandTop
= screen
->get_paramf(screen
,
732 PIPE_CAPF_GUARD_BAND_TOP
);
733 pCaps
->GuardBandRight
= screen
->get_paramf(screen
,
734 PIPE_CAPF_GUARD_BAND_RIGHT
);
735 pCaps
->GuardBandBottom
= screen
->get_paramf(screen
,
736 PIPE_CAPF_GUARD_BAND_BOTTOM
);
737 pCaps
->ExtentsAdjust
= 0.0f
;
740 D3DSTENCILCAPS_KEEP
|
741 D3DSTENCILCAPS_ZERO
|
742 D3DSTENCILCAPS_REPLACE
|
743 D3DSTENCILCAPS_INCRSAT
|
744 D3DSTENCILCAPS_DECRSAT
|
745 D3DSTENCILCAPS_INVERT
|
746 D3DSTENCILCAPS_INCR
|
747 D3DSTENCILCAPS_DECR
|
748 D3DPIPECAP(TWO_SIDED_STENCIL
, D3DSTENCILCAPS_TWOSIDED
);
751 (D3DFVFCAPS_TEXCOORDCOUNTMASK
& 0xff) |
752 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
755 /* XXX: Some of these are probably not in SM2.0 so cap them when I figure
756 * them out. For now leave them all enabled. */
757 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
758 D3DTEXOPCAPS_SELECTARG1
|
759 D3DTEXOPCAPS_SELECTARG2
|
760 D3DTEXOPCAPS_MODULATE
|
761 D3DTEXOPCAPS_MODULATE2X
|
762 D3DTEXOPCAPS_MODULATE4X
|
764 D3DTEXOPCAPS_ADDSIGNED
|
765 D3DTEXOPCAPS_ADDSIGNED2X
|
766 D3DTEXOPCAPS_SUBTRACT
|
767 D3DTEXOPCAPS_ADDSMOOTH
|
768 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
769 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
770 D3DTEXOPCAPS_BLENDFACTORALPHA
|
771 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
772 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
773 D3DTEXOPCAPS_PREMODULATE
|
774 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
775 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
776 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
777 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
778 D3DTEXOPCAPS_BUMPENVMAP
|
779 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
780 D3DTEXOPCAPS_DOTPRODUCT3
|
781 D3DTEXOPCAPS_MULTIPLYADD
|
784 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
785 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
786 pCaps
->MaxSimultaneousTextures
= screen
->get_shader_param(screen
,
787 PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
);
788 if (pCaps
->MaxSimultaneousTextures
> NINE_MAX_SAMPLERS_PS
)
789 pCaps
->MaxSimultaneousTextures
= NINE_MAX_SAMPLERS_PS
;
791 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
792 /*D3DVTXPCAPS_TEXGEN_SPHEREMAP |*/
793 D3DVTXPCAPS_MATERIALSOURCE7
|
794 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
795 D3DVTXPCAPS_POSITIONALLIGHTS
|
796 D3DVTXPCAPS_LOCALVIEWER
|
797 D3DVTXPCAPS_TWEENING
|
798 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
800 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
801 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
802 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
803 pCaps
->MaxVertexBlendMatrixIndex
= 7; /* D3DTS_WORLDMATRIX(0..7) */
805 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
807 pCaps
->MaxPrimitiveCount
= 0xFFFFF; /* <- wine, really 0xFFFFFFFF; */
808 pCaps
->MaxVertexIndex
= 0xFFFFF; /* <- wine, really 0xFFFFFFFF */
810 _min(screen
->get_shader_param(screen
,
811 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
814 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
815 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
817 pCaps
->VertexShaderVersion
= D3DVS_VERSION(3,0);
819 /* VS 2 as well as 3.0 supports a minimum of 256 consts.
820 * Wine and d3d9 drivers for dx1x hw advertise 256. Just as them,
821 * advertise 256. Problem is with hw that can only do 256, because
822 * we need take a few slots for boolean and integer constants. For these
823 * we'll have to fail later if they use complex shaders. */
824 pCaps
->MaxVertexShaderConst
= NINE_MAX_CONST_F
;
826 pCaps
->PixelShaderVersion
= D3DPS_VERSION(3,0);
827 pCaps
->PixelShader1xMaxValue
= 8.0f
; /* XXX: wine */
829 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
830 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
831 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
832 /*D3DDEVCAPS2_DMAPNPATCH |*/
833 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
834 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
835 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
837 pCaps
->MasterAdapterOrdinal
= 0;
838 pCaps
->AdapterOrdinalInGroup
= 0;
839 pCaps
->NumberOfAdaptersInGroup
= 1;
842 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
843 pCaps
->Reserved5
= 0;
845 /* XXX: use is_format_supported */
846 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
854 D3DDTCAPS_FLOAT16_2
|
857 pCaps
->NumSimultaneousRTs
=
858 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
859 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
860 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
862 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
863 D3DPTFILTERCAPS_MINFLINEAR
|
864 D3DPTFILTERCAPS_MAGFPOINT
|
865 D3DPTFILTERCAPS_MAGFLINEAR
;
868 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
869 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
870 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
871 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
872 pCaps
->VS20Caps
.NumTemps
=
873 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
874 PIPE_SHADER_CAP_MAX_TEMPS
);
875 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
876 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
877 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
879 /* also check for values < 0, because get_shader_param may return unsigned */
880 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
881 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
882 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
883 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
884 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
885 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
886 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
887 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
888 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
889 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
890 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
893 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
894 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
895 D3DPS20CAPS_PREDICATION
;
896 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
897 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
898 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
899 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
900 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
901 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
902 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
903 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
904 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
905 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
906 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
907 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
908 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
909 pCaps
->PS20Caps
.NumTemps
=
910 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
911 PIPE_SHADER_CAP_MAX_TEMPS
);
912 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
913 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
914 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
915 pCaps
->PS20Caps
.NumInstructionSlots
=
916 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
917 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
919 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
920 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
921 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
922 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
923 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
924 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
925 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
926 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
927 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
928 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
929 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
930 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
931 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
932 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
935 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
936 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
937 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
938 ~(D3DPTFILTERCAPS_MIPFPOINT
|
939 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
941 pCaps
->VertexTextureFilterCaps
= 0;
943 pCaps
->MaxVertexShader30InstructionSlots
=
944 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
945 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
946 pCaps
->MaxPixelShader30InstructionSlots
=
947 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
948 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
949 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
950 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
951 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
952 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
953 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
954 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
956 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
957 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
958 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
960 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
961 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
967 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
969 D3DDEVTYPE DeviceType
,
972 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
974 ID3DPresentGroup
*pPresentationGroup
,
975 IDirect3DDevice9
**ppReturnedDeviceInterface
)
977 struct pipe_screen
*screen
;
978 D3DDEVICE_CREATION_PARAMETERS params
;
983 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
984 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
985 "ppReturnedDeviceInterface=%p\n", This
,
986 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
987 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
989 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
991 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
993 return D3DERR_NOTAVAILABLE
;
996 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
998 DBG("Failed to get pipe_screen.\n");
1002 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1004 DBG("Failed to get device caps.\n");
1008 params
.AdapterOrdinal
= RealAdapter
;
1009 params
.DeviceType
= DeviceType
;
1010 params
.hFocusWindow
= hFocusWindow
;
1011 params
.BehaviorFlags
= BehaviorFlags
;
1013 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1014 pD3D9
, pPresentationGroup
, This
->ctx
, FALSE
, NULL
,
1015 (struct NineDevice9
**)ppReturnedDeviceInterface
);
1017 DBG("Failed to create device.\n");
1020 DBG("NineDevice9 created successfully.\n");
1026 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1028 D3DDEVTYPE DeviceType
,
1030 DWORD BehaviorFlags
,
1031 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1032 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1033 IDirect3D9Ex
*pD3D9Ex
,
1034 ID3DPresentGroup
*pPresentationGroup
,
1035 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1037 struct pipe_screen
*screen
;
1038 D3DDEVICE_CREATION_PARAMETERS params
;
1043 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1044 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1045 "ppReturnedDeviceInterface=%p\n", This
,
1046 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1047 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1049 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1051 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1053 return D3DERR_NOTAVAILABLE
;
1056 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1058 DBG("Failed to get pipe_screen.\n");
1062 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1064 DBG("Failed to get device caps.\n");
1068 params
.AdapterOrdinal
= RealAdapter
;
1069 params
.DeviceType
= DeviceType
;
1070 params
.hFocusWindow
= hFocusWindow
;
1071 params
.BehaviorFlags
= BehaviorFlags
;
1073 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1074 pFullscreenDisplayMode
,
1075 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1076 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
);
1078 DBG("Failed to create device.\n");
1081 DBG("NineDevice9Ex created successfully.\n");
1086 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1087 (void *)NineUnknown_QueryInterface
,
1088 (void *)NineUnknown_AddRef
,
1089 (void *)NineUnknown_Release
,
1090 (void *)NineAdapter9_GetAdapterIdentifier
,
1091 (void *)NineAdapter9_CheckDeviceType
,
1092 (void *)NineAdapter9_CheckDeviceFormat
,
1093 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1094 (void *)NineAdapter9_CheckDepthStencilMatch
,
1095 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1096 (void *)NineAdapter9_GetDeviceCaps
,
1097 (void *)NineAdapter9_CreateDevice
,
1098 (void *)NineAdapter9_CreateDeviceEx
1101 static const GUID
*NineAdapter9_IIDs
[] = {
1108 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1109 struct NineAdapter9
**ppOut
)
1111 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);