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 HRESULT hr
= NineUnknown_ctor(&This
->base
, pParams
);
43 if (FAILED(hr
)) { return hr
; }
45 DBG("This=%p pParams=%p pCTX=%p\n", This
, pParams
, pCTX
);
46 nine_dump_D3DADAPTER_IDENTIFIER9(DBG_CHANNEL
, &pCTX
->identifier
);
49 if (!This
->ctx
->hal
->get_param(This
->ctx
->hal
, PIPE_CAP_CLIP_HALFZ
)) {
50 ERR("Driver doesn't support d3d9 coordinates\n");
51 return D3DERR_DRIVERINTERNALERROR
;
54 !This
->ctx
->ref
->get_param(This
->ctx
->ref
, PIPE_CAP_CLIP_HALFZ
)) {
55 ERR("Warning: Sotware rendering driver doesn't support d3d9 coordinates\n");
62 NineAdapter9_dtor( struct NineAdapter9
*This
)
64 struct d3dadapter9_context
*ctx
= This
->ctx
;
66 DBG("This=%p\n", This
);
68 NineUnknown_dtor(&This
->base
);
70 /* special case, call backend-specific dtor AFTER destroying this object
73 if (ctx
->destroy
) { ctx
->destroy(ctx
); }
78 NineAdapter9_GetScreen( struct NineAdapter9
*This
,
80 struct pipe_screen
**ppScreen
)
82 const char *force_sw
= getenv("D3D_ALWAYS_SOFTWARE");
85 if (force_sw
&& !strcmp(force_sw
, "1") && This
->ctx
->ref
) {
86 *ppScreen
= This
->ctx
->ref
;
89 *ppScreen
= This
->ctx
->hal
;
93 case D3DDEVTYPE_NULLREF
:
95 if (force_sw
&& !strcmp(force_sw
, "0")) {
96 *ppScreen
= This
->ctx
->hal
;
99 *ppScreen
= This
->ctx
->ref
;
103 user_assert(!"Invalid device type", D3DERR_INVALIDCALL
);
106 if (!*ppScreen
) { return D3DERR_NOTAVAILABLE
; }
112 NineAdapter9_GetAdapterIdentifier( struct NineAdapter9
*This
,
114 D3DADAPTER_IDENTIFIER9
*pIdentifier
)
116 DBG("This=%p Flags=%x pIdentifier=%p\n", This
, Flags
, pIdentifier
);
118 /* regarding flags, MSDN has this to say:
119 * Flags sets the WHQLLevel member of D3DADAPTER_IDENTIFIER9. Flags can be
120 * set to either 0 or D3DENUM_WHQL_LEVEL. If D3DENUM_WHQL_LEVEL is
121 * specified, this call can connect to the Internet to download new
122 * Microsoft Windows Hardware Quality Labs (WHQL) certificates.
123 * so let's just ignore it. */
124 *pIdentifier
= This
->ctx
->identifier
;
128 static INLINE boolean
129 backbuffer_format( D3DFORMAT dfmt
,
133 if (dfmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
135 if ((dfmt
== D3DFMT_A2R10G10B10
&& bfmt
== dfmt
) ||
136 (dfmt
== D3DFMT_X8R8G8B8
&& (bfmt
== dfmt
||
137 bfmt
== D3DFMT_A8R8G8B8
)) ||
138 (dfmt
== D3DFMT_X1R5G5B5
&& (bfmt
== dfmt
||
139 bfmt
== D3DFMT_A1R5G5B5
)) ||
140 (dfmt
== D3DFMT_R5G6B5
&& bfmt
== dfmt
)) {
148 NineAdapter9_CheckDeviceType( struct NineAdapter9
*This
,
150 D3DFORMAT AdapterFormat
,
151 D3DFORMAT BackBufferFormat
,
154 struct pipe_screen
*screen
;
155 enum pipe_format dfmt
, bfmt
;
158 DBG("This=%p DevType=%s AdapterFormat=%s BackBufferFormat=%s "
159 "bWindowed=%i\n", This
, nine_D3DDEVTYPE_to_str(DevType
),
160 d3dformat_to_string(AdapterFormat
),
161 d3dformat_to_string(BackBufferFormat
), bWindowed
);
163 user_assert(backbuffer_format(AdapterFormat
, BackBufferFormat
, bWindowed
),
164 D3DERR_NOTAVAILABLE
);
166 hr
= NineAdapter9_GetScreen(This
, DevType
, &screen
);
167 if (FAILED(hr
)) { return hr
; }
169 dfmt
= d3d9_to_pipe_format(AdapterFormat
);
170 bfmt
= d3d9_to_pipe_format(BackBufferFormat
);
171 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
172 DBG("Invalid Adapter/BackBufferFormat.\n");
173 return D3DERR_NOTAVAILABLE
;
176 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 1,
177 PIPE_BIND_DISPLAY_TARGET
|
179 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 1,
180 PIPE_BIND_DISPLAY_TARGET
|
182 DBG("Unsupported Adapter/BackBufferFormat.\n");
183 return D3DERR_NOTAVAILABLE
;
189 static INLINE boolean
190 display_format( D3DFORMAT fmt
,
193 /* http://msdn.microsoft.com/en-us/library/bb172558(v=VS.85).aspx#BackBuffer_or_Display_Formats */
194 static const D3DFORMAT allowed
[] = {
202 if (fmt
== D3DFMT_A2R10G10B10
&& win
) { return FALSE
; }
204 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
205 if (fmt
== allowed
[i
]) { return TRUE
; }
211 NineAdapter9_CheckDeviceFormat( struct NineAdapter9
*This
,
212 D3DDEVTYPE DeviceType
,
213 D3DFORMAT AdapterFormat
,
215 D3DRESOURCETYPE RType
,
216 D3DFORMAT CheckFormat
)
218 struct pipe_screen
*screen
;
221 enum pipe_texture_target target
;
224 /* Check adapter format. */
226 /* Nicer output if we only have the line at the end. */
228 DBG("This=%p DeviceType=%s AdapterFormat=%s\n", This
,
229 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
));
231 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_INVALIDCALL
);
233 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
236 pf
= d3d9_to_pipe_format(AdapterFormat
);
237 if (pf
== PIPE_FORMAT_NONE
||
238 !screen
->is_format_supported(screen
, pf
, PIPE_TEXTURE_2D
, 0,
239 PIPE_BIND_DISPLAY_TARGET
|
241 DBG("AdapterFormat %s not available.\n",
242 d3dformat_to_string(AdapterFormat
));
243 return D3DERR_NOTAVAILABLE
;
246 /* Check actual format. */
249 case D3DRTYPE_SURFACE
: target
= PIPE_TEXTURE_2D
; break;
250 case D3DRTYPE_TEXTURE
: target
= PIPE_TEXTURE_2D
; break;
251 case D3DRTYPE_CUBETEXTURE
: target
= PIPE_TEXTURE_CUBE
; break;
252 case D3DRTYPE_VOLUME
: target
= PIPE_TEXTURE_3D
; break;
253 case D3DRTYPE_VOLUMETEXTURE
: target
= PIPE_TEXTURE_3D
; break;
254 case D3DRTYPE_VERTEXBUFFER
: target
= PIPE_BUFFER
; break;
255 case D3DRTYPE_INDEXBUFFER
: target
= PIPE_BUFFER
; break;
257 user_assert(0, D3DERR_INVALIDCALL
);
261 if (Usage
& D3DUSAGE_RENDERTARGET
) bind
|= PIPE_BIND_RENDER_TARGET
;
262 if (Usage
& D3DUSAGE_DEPTHSTENCIL
) bind
|= PIPE_BIND_DEPTH_STENCIL
;
264 /* API hack because setting RT[0] to NULL is forbidden */
265 if (CheckFormat
== D3DFMT_NULL
&& bind
== PIPE_BIND_RENDER_TARGET
&&
266 (RType
== D3DRTYPE_SURFACE
||
267 RType
== D3DRTYPE_TEXTURE
))
270 if (Usage
& D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING
)
271 bind
|= PIPE_BIND_BLENDABLE
;
273 if (Usage
& D3DUSAGE_DMAP
) {
274 DBG("D3DUSAGE_DMAP not available\n");
275 return D3DERR_NOTAVAILABLE
; /* TODO: displacement mapping */
279 case D3DRTYPE_TEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
280 case D3DRTYPE_CUBETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
281 case D3DRTYPE_VOLUMETEXTURE
: bind
|= PIPE_BIND_SAMPLER_VIEW
; break;
282 case D3DRTYPE_VERTEXBUFFER
: bind
|= PIPE_BIND_VERTEX_BUFFER
; break;
283 case D3DRTYPE_INDEXBUFFER
: bind
|= PIPE_BIND_INDEX_BUFFER
; break;
289 pf
= d3d9_to_pipe_format(CheckFormat
);
290 if (Usage
& (D3DUSAGE_QUERY_SRGBREAD
| D3DUSAGE_QUERY_SRGBWRITE
))
291 pf
= util_format_srgb(pf
);
293 DBG("Format=%s/%s Usage/Bind=%x/%d RType/Target=%u/%s\n", // replace %d to %s
294 d3dformat_to_string(CheckFormat
), util_format_name(pf
),
295 Usage
, bind
, // temporary simplified for merge, FIXME
296 /* Usage, util_dump_bind_flags(bind), */
297 RType
, util_dump_tex_target(target
, TRUE
));
299 if (pf
== PIPE_FORMAT_NONE
||
300 !screen
->is_format_supported(screen
, pf
, target
, 0, bind
)) {
301 DBG("NOT AVAILABLE\n");
302 return D3DERR_NOTAVAILABLE
;
305 /* if (Usage & D3DUSAGE_NONSECURE) { don't know the implications of this } */
306 /* if (Usage & D3DUSAGE_SOFTWAREPROCESSING) { we can always support this } */
308 if ((Usage
& D3DUSAGE_AUTOGENMIPMAP
) && !(bind
& PIPE_BIND_SAMPLER_VIEW
))
309 return D3DOK_NOAUTOGEN
;
314 NineAdapter9_CheckDeviceMultiSampleType( struct NineAdapter9
*This
,
315 D3DDEVTYPE DeviceType
,
316 D3DFORMAT SurfaceFormat
,
318 D3DMULTISAMPLE_TYPE MultiSampleType
,
319 DWORD
*pQualityLevels
)
321 struct pipe_screen
*screen
;
326 DBG("This=%p DeviceType=%s SurfaceFormat=%s Windowed=%i MultiSampleType=%u "
327 "pQualityLevels=%p\n", This
, nine_D3DDEVTYPE_to_str(DeviceType
),
328 d3dformat_to_string(SurfaceFormat
), Windowed
, MultiSampleType
,
331 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
335 pf
= d3d9_to_pipe_format(SurfaceFormat
);
336 bind
= util_format_is_depth_or_stencil(pf
) ?
337 PIPE_BIND_DEPTH_STENCIL
: PIPE_BIND_RENDER_TARGET
;
339 if (pf
== PIPE_FORMAT_NONE
||
340 !screen
->is_format_supported(screen
, pf
, PIPE_TEXTURE_2D
,
341 MultiSampleType
, bind
)) {
342 DBG("%s with %u samples not available.\n",
343 d3dformat_to_string(SurfaceFormat
), MultiSampleType
);
344 return D3DERR_NOTAVAILABLE
;
348 *pQualityLevels
= 1; /* gallium doesn't have quality levels */
353 static INLINE boolean
354 depth_stencil_format( D3DFORMAT fmt
)
356 static D3DFORMAT allowed
[] = {
364 D3DFMT_D32F_LOCKABLE
,
370 for (i
= 0; i
< sizeof(allowed
)/sizeof(D3DFORMAT
); i
++) {
371 if (fmt
== allowed
[i
]) { return TRUE
; }
377 NineAdapter9_CheckDepthStencilMatch( struct NineAdapter9
*This
,
378 D3DDEVTYPE DeviceType
,
379 D3DFORMAT AdapterFormat
,
380 D3DFORMAT RenderTargetFormat
,
381 D3DFORMAT DepthStencilFormat
)
383 struct pipe_screen
*screen
;
384 enum pipe_format dfmt
, bfmt
, zsfmt
;
387 DBG("This=%p DeviceType=%s AdapterFormat=%s "
388 "RenderTargetFormat=%s DepthStencilFormat=%s\n", This
,
389 nine_D3DDEVTYPE_to_str(DeviceType
), d3dformat_to_string(AdapterFormat
),
390 d3dformat_to_string(RenderTargetFormat
),
391 d3dformat_to_string(DepthStencilFormat
));
393 user_assert(display_format(AdapterFormat
, FALSE
), D3DERR_NOTAVAILABLE
);
394 user_assert(depth_stencil_format(DepthStencilFormat
), D3DERR_NOTAVAILABLE
);
396 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
397 if (FAILED(hr
)) { return hr
; }
399 dfmt
= d3d9_to_pipe_format(AdapterFormat
);
400 bfmt
= d3d9_to_pipe_format(RenderTargetFormat
);
401 if (RenderTargetFormat
== D3DFMT_NULL
)
403 zsfmt
= d3d9_to_pipe_format(DepthStencilFormat
);
404 if (dfmt
== PIPE_FORMAT_NONE
||
405 bfmt
== PIPE_FORMAT_NONE
||
406 zsfmt
== PIPE_FORMAT_NONE
) {
407 return D3DERR_NOTAVAILABLE
;
410 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 0,
411 PIPE_BIND_DISPLAY_TARGET
|
413 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 0,
414 PIPE_BIND_RENDER_TARGET
) ||
415 !screen
->is_format_supported(screen
, zsfmt
, PIPE_TEXTURE_2D
, 0,
416 PIPE_BIND_DEPTH_STENCIL
)) {
417 return D3DERR_NOTAVAILABLE
;
424 NineAdapter9_CheckDeviceFormatConversion( struct NineAdapter9
*This
,
425 D3DDEVTYPE DeviceType
,
426 D3DFORMAT SourceFormat
,
427 D3DFORMAT TargetFormat
)
429 /* MSDN says this tests whether a certain backbuffer format can be used in
430 * conjunction with a certain front buffer format. It's a little confusing
431 * but some one wiser might be able to figure this one out. XXX */
432 struct pipe_screen
*screen
;
433 enum pipe_format dfmt
, bfmt
;
436 DBG("This=%p DeviceType=%s SourceFormat=%s TargetFormat=%s\n", This
,
437 nine_D3DDEVTYPE_to_str(DeviceType
),
438 d3dformat_to_string(SourceFormat
), d3dformat_to_string(TargetFormat
));
440 user_assert(backbuffer_format(TargetFormat
, SourceFormat
, FALSE
),
441 D3DERR_NOTAVAILABLE
);
443 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
444 if (FAILED(hr
)) { return hr
; }
446 dfmt
= d3d9_to_pipe_format(TargetFormat
);
447 bfmt
= d3d9_to_pipe_format(SourceFormat
);
448 if (dfmt
== PIPE_FORMAT_NONE
|| bfmt
== PIPE_FORMAT_NONE
) {
449 return D3DERR_NOTAVAILABLE
;
451 if (!screen
->is_format_supported(screen
, dfmt
, PIPE_TEXTURE_2D
, 1,
452 PIPE_BIND_DISPLAY_TARGET
|
454 !screen
->is_format_supported(screen
, bfmt
, PIPE_TEXTURE_2D
, 1,
455 PIPE_BIND_DISPLAY_TARGET
|
457 DBG("%s to %s not supported.\n",
458 d3dformat_to_string(SourceFormat
),
459 d3dformat_to_string(TargetFormat
));
460 return D3DERR_NOTAVAILABLE
;
467 NineAdapter9_GetDeviceCaps( struct NineAdapter9
*This
,
468 D3DDEVTYPE DeviceType
,
471 struct pipe_screen
*screen
;
475 DBG("This=%p DeviceType=%s pCaps=%p\n", This
,
476 nine_D3DDEVTYPE_to_str(DeviceType
), pCaps
);
478 user_assert(pCaps
, D3DERR_INVALIDCALL
);
480 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
482 DBG("Failed to get pipe_screen.\n");
486 #define D3DPIPECAP(pcap, d3dcap) \
487 (screen->get_param(screen, PIPE_CAP_##pcap) ? (d3dcap) : 0)
489 #define D3DNPIPECAP(pcap, d3dcap) \
490 (screen->get_param(screen, PIPE_CAP_##pcap) ? 0 : (d3dcap))
492 sm3
= screen
->get_param(screen
, PIPE_CAP_SM3
);
493 vs
= !!(screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
494 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
));
496 pCaps
->DeviceType
= DeviceType
;
498 pCaps
->AdapterOrdinal
= 0;
502 pCaps
->Caps2
= D3DCAPS2_CANMANAGERESOURCE
|
503 /* D3DCAPS2_CANSHARERESOURCE | */
504 /* D3DCAPS2_CANCALIBRATEGAMMA | */
505 D3DCAPS2_DYNAMICTEXTURES
|
506 D3DCAPS2_FULLSCREENGAMMA
|
507 D3DCAPS2_CANAUTOGENMIPMAP
;
509 /* Note: D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD just means the
510 * backbuffer can be ARGB (instead of only XRGB) when we are fullscreen
511 * and in discard mode. */
512 pCaps
->Caps3
= D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD
|
513 D3DCAPS3_COPY_TO_VIDMEM
|
514 D3DCAPS3_COPY_TO_SYSTEMMEM
|
515 D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION
;
517 pCaps
->PresentationIntervals
= D3DPRESENT_INTERVAL_DEFAULT
|
518 D3DPRESENT_INTERVAL_ONE
|
519 D3DPRESENT_INTERVAL_TWO
|
520 D3DPRESENT_INTERVAL_THREE
|
521 D3DPRESENT_INTERVAL_FOUR
|
522 D3DPRESENT_INTERVAL_IMMEDIATE
;
523 pCaps
->CursorCaps
= D3DCURSORCAPS_COLOR
| D3DCURSORCAPS_LOWRES
;
525 pCaps
->DevCaps
= D3DDEVCAPS_CANBLTSYSTONONLOCAL
|
526 D3DDEVCAPS_CANRENDERAFTERFLIP
|
527 D3DDEVCAPS_DRAWPRIMITIVES2
|
528 D3DDEVCAPS_DRAWPRIMITIVES2EX
|
529 D3DDEVCAPS_DRAWPRIMTLVERTEX
|
530 D3DDEVCAPS_EXECUTESYSTEMMEMORY
|
531 D3DDEVCAPS_EXECUTEVIDEOMEMORY
|
532 D3DDEVCAPS_HWRASTERIZATION
|
533 D3DDEVCAPS_HWTRANSFORMANDLIGHT
|
534 /*D3DDEVCAPS_NPATCHES |*/
535 D3DDEVCAPS_PUREDEVICE
|
536 /*D3DDEVCAPS_QUINTICRTPATCHES |*/
537 /*D3DDEVCAPS_RTPATCHES |*/
538 /*D3DDEVCAPS_RTPATCHHANDLEZERO |*/
539 /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES |*/
540 /*D3DDEVCAPS_TEXTURENONLOCALVIDMEM |*/
541 D3DDEVCAPS_TEXTURESYSTEMMEMORY
|
542 D3DDEVCAPS_TEXTUREVIDEOMEMORY
|
543 D3DDEVCAPS_TLVERTEXSYSTEMMEMORY
|
544 D3DDEVCAPS_TLVERTEXVIDEOMEMORY
;
546 pCaps
->PrimitiveMiscCaps
= D3DPMISCCAPS_MASKZ
|
547 D3DPMISCCAPS_CULLNONE
| /* XXX */
548 D3DPMISCCAPS_CULLCW
|
549 D3DPMISCCAPS_CULLCCW
|
550 D3DPMISCCAPS_COLORWRITEENABLE
|
551 D3DPMISCCAPS_CLIPPLANESCALEDPOINTS
|
552 D3DPMISCCAPS_CLIPTLVERTS
|
553 D3DPMISCCAPS_TSSARGTEMP
|
554 D3DPMISCCAPS_BLENDOP
|
555 D3DPIPECAP(INDEP_BLEND_ENABLE
, D3DPMISCCAPS_INDEPENDENTWRITEMASKS
) |
556 /*D3DPMISCCAPS_PERSTAGECONSTANT |*/
557 /*D3DPMISCCAPS_POSTBLENDSRGBCONVERT |*/ /* TODO */
558 D3DPMISCCAPS_FOGANDSPECULARALPHA
|
559 D3DPIPECAP(BLEND_EQUATION_SEPARATE
, D3DPMISCCAPS_SEPARATEALPHABLEND
) |
560 D3DPIPECAP(MIXED_COLORBUFFER_FORMATS
, D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS
) |
561 D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING
|
562 /*D3DPMISCCAPS_FOGVERTEXCLAMPED*/0;
565 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPRASTERCAPS_ANISOTROPY
) |
566 /*D3DPRASTERCAPS_COLORPERSPECTIVE |*/
567 D3DPRASTERCAPS_DITHER
|
568 D3DPRASTERCAPS_DEPTHBIAS
|
569 /*D3DPRASTERCAPS_FOGRANGE |*/
570 /*D3DPRASTERCAPS_FOGTABLE |*/
571 /*D3DPRASTERCAPS_FOGVERTEX |*/
572 D3DPRASTERCAPS_MIPMAPLODBIAS
|
573 D3DPRASTERCAPS_MULTISAMPLE_TOGGLE
|
574 D3DPRASTERCAPS_SCISSORTEST
|
575 D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS
|
576 /*D3DPRASTERCAPS_WBUFFER |*/
577 /*D3DPRASTERCAPS_WFOG |*/
578 /*D3DPRASTERCAPS_ZBUFFERLESSHSR |*/
579 /*D3DPRASTERCAPS_ZFOG |*/
580 D3DPRASTERCAPS_ZTEST
;
582 pCaps
->ZCmpCaps
= D3DPCMPCAPS_NEVER
|
585 D3DPCMPCAPS_LESSEQUAL
|
586 D3DPCMPCAPS_GREATER
|
587 D3DPCMPCAPS_NOTEQUAL
|
588 D3DPCMPCAPS_GREATEREQUAL
|
591 pCaps
->SrcBlendCaps
= D3DPBLENDCAPS_ZERO
|
593 D3DPBLENDCAPS_SRCCOLOR
|
594 D3DPBLENDCAPS_INVSRCCOLOR
|
595 D3DPBLENDCAPS_SRCALPHA
|
596 D3DPBLENDCAPS_INVSRCALPHA
|
597 D3DPBLENDCAPS_DESTALPHA
|
598 D3DPBLENDCAPS_INVDESTALPHA
|
599 D3DPBLENDCAPS_DESTCOLOR
|
600 D3DPBLENDCAPS_INVDESTCOLOR
|
601 D3DPBLENDCAPS_SRCALPHASAT
|
602 D3DPBLENDCAPS_BOTHSRCALPHA
|
603 D3DPBLENDCAPS_BOTHINVSRCALPHA
|
604 D3DPBLENDCAPS_BLENDFACTOR
|
605 D3DPIPECAP(MAX_DUAL_SOURCE_RENDER_TARGETS
,
606 D3DPBLENDCAPS_INVSRCCOLOR2
|
607 D3DPBLENDCAPS_SRCCOLOR2
);
609 pCaps
->DestBlendCaps
= pCaps
->SrcBlendCaps
;
611 pCaps
->AlphaCmpCaps
= D3DPCMPCAPS_LESS
|
613 D3DPCMPCAPS_LESSEQUAL
|
614 D3DPCMPCAPS_GREATER
|
615 D3DPCMPCAPS_NOTEQUAL
|
616 D3DPCMPCAPS_GREATEREQUAL
|
619 /* FLAT caps not legal for D3D9. */
620 pCaps
->ShadeCaps
= D3DPSHADECAPS_COLORGOURAUDRGB
|
621 D3DPSHADECAPS_SPECULARGOURAUDRGB
|
622 D3DPSHADECAPS_ALPHAGOURAUDBLEND
|
623 D3DPSHADECAPS_FOGGOURAUD
;
626 D3DPTEXTURECAPS_ALPHA
|
627 D3DPTEXTURECAPS_ALPHAPALETTE
|
628 D3DPTEXTURECAPS_PERSPECTIVE
|
629 D3DPTEXTURECAPS_PROJECTED
|
630 /*D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE |*/
631 D3DPTEXTURECAPS_CUBEMAP
|
632 D3DPTEXTURECAPS_VOLUMEMAP
|
633 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_POW2
) |
634 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_NONPOW2CONDITIONAL
) |
635 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_CUBEMAP_POW2
) |
636 D3DNPIPECAP(NPOT_TEXTURES
, D3DPTEXTURECAPS_VOLUMEMAP_POW2
) |
637 D3DPIPECAP(MAX_TEXTURE_2D_LEVELS
, D3DPTEXTURECAPS_MIPMAP
) |
638 D3DPIPECAP(MAX_TEXTURE_3D_LEVELS
, D3DPTEXTURECAPS_MIPVOLUMEMAP
) |
639 D3DPIPECAP(MAX_TEXTURE_CUBE_LEVELS
, D3DPTEXTURECAPS_MIPCUBEMAP
);
641 pCaps
->TextureFilterCaps
=
642 D3DPTFILTERCAPS_MINFPOINT
|
643 D3DPTFILTERCAPS_MINFLINEAR
|
644 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MINFANISOTROPIC
) |
645 /*D3DPTFILTERCAPS_MINFPYRAMIDALQUAD |*/
646 /*D3DPTFILTERCAPS_MINFGAUSSIANQUAD |*/
647 D3DPTFILTERCAPS_MIPFPOINT
|
648 D3DPTFILTERCAPS_MIPFLINEAR
|
649 D3DPTFILTERCAPS_MAGFPOINT
|
650 D3DPTFILTERCAPS_MAGFLINEAR
|
651 D3DPIPECAP(ANISOTROPIC_FILTER
, D3DPTFILTERCAPS_MAGFANISOTROPIC
) |
652 /*D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD |*/
653 /*D3DPTFILTERCAPS_MAGFGAUSSIANQUAD*/0;
655 pCaps
->CubeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
656 pCaps
->VolumeTextureFilterCaps
= pCaps
->TextureFilterCaps
;
658 pCaps
->TextureAddressCaps
=
659 D3DPTADDRESSCAPS_BORDER
|
660 D3DPTADDRESSCAPS_INDEPENDENTUV
|
661 D3DPTADDRESSCAPS_WRAP
|
662 D3DPTADDRESSCAPS_MIRROR
|
663 D3DPTADDRESSCAPS_CLAMP
|
664 D3DPIPECAP(TEXTURE_MIRROR_CLAMP
, D3DPTADDRESSCAPS_MIRRORONCE
);
666 pCaps
->VolumeTextureAddressCaps
= pCaps
->TextureAddressCaps
;
669 D3DLINECAPS_ALPHACMP
|
671 D3DLINECAPS_TEXTURE
|
674 if (screen
->get_paramf(screen
, PIPE_CAPF_MAX_LINE_WIDTH_AA
) > 0.0) {
675 pCaps
->LineCaps
|= D3DLINECAPS_ANTIALIAS
;
678 pCaps
->MaxTextureWidth
=
679 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_2D_LEVELS
) - 1);
680 pCaps
->MaxTextureHeight
= pCaps
->MaxTextureWidth
;
681 pCaps
->MaxVolumeExtent
=
682 1 << (screen
->get_param(screen
, PIPE_CAP_MAX_TEXTURE_3D_LEVELS
) - 1);
683 /* XXX values from wine */
684 pCaps
->MaxTextureRepeat
= 32768;
685 pCaps
->MaxTextureAspectRatio
= pCaps
->MaxTextureWidth
;
687 pCaps
->MaxAnisotropy
=
688 (DWORD
)screen
->get_paramf(screen
, PIPE_CAPF_MAX_TEXTURE_ANISOTROPY
);
690 pCaps
->MaxVertexW
= 1.0f
; /* XXX */
691 pCaps
->GuardBandLeft
= screen
->get_paramf(screen
,
692 PIPE_CAPF_GUARD_BAND_LEFT
);
693 pCaps
->GuardBandTop
= screen
->get_paramf(screen
,
694 PIPE_CAPF_GUARD_BAND_TOP
);
695 pCaps
->GuardBandRight
= screen
->get_paramf(screen
,
696 PIPE_CAPF_GUARD_BAND_RIGHT
);
697 pCaps
->GuardBandBottom
= screen
->get_paramf(screen
,
698 PIPE_CAPF_GUARD_BAND_BOTTOM
);
699 pCaps
->ExtentsAdjust
= 0.0f
;
702 D3DSTENCILCAPS_KEEP
|
703 D3DSTENCILCAPS_ZERO
|
704 D3DSTENCILCAPS_REPLACE
|
705 D3DSTENCILCAPS_INCRSAT
|
706 D3DSTENCILCAPS_DECRSAT
|
707 D3DSTENCILCAPS_INVERT
|
708 D3DSTENCILCAPS_INCR
|
709 D3DSTENCILCAPS_DECR
|
710 D3DPIPECAP(TWO_SIDED_STENCIL
, D3DSTENCILCAPS_TWOSIDED
);
713 (D3DFVFCAPS_TEXCOORDCOUNTMASK
& 0xff) |
714 /*D3DFVFCAPS_DONOTSTRIPELEMENTS |*/
717 /* XXX: Some of these are probably not in SM2.0 so cap them when I figure
718 * them out. For now leave them all enabled. */
719 pCaps
->TextureOpCaps
= D3DTEXOPCAPS_DISABLE
|
720 D3DTEXOPCAPS_SELECTARG1
|
721 D3DTEXOPCAPS_SELECTARG2
|
722 D3DTEXOPCAPS_MODULATE
|
723 D3DTEXOPCAPS_MODULATE2X
|
724 D3DTEXOPCAPS_MODULATE4X
|
726 D3DTEXOPCAPS_ADDSIGNED
|
727 D3DTEXOPCAPS_ADDSIGNED2X
|
728 D3DTEXOPCAPS_SUBTRACT
|
729 D3DTEXOPCAPS_ADDSMOOTH
|
730 D3DTEXOPCAPS_BLENDDIFFUSEALPHA
|
731 D3DTEXOPCAPS_BLENDTEXTUREALPHA
|
732 D3DTEXOPCAPS_BLENDFACTORALPHA
|
733 D3DTEXOPCAPS_BLENDTEXTUREALPHAPM
|
734 D3DTEXOPCAPS_BLENDCURRENTALPHA
|
735 D3DTEXOPCAPS_PREMODULATE
|
736 D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
|
737 D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
|
738 D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
|
739 D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
|
740 D3DTEXOPCAPS_BUMPENVMAP
|
741 D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
742 D3DTEXOPCAPS_DOTPRODUCT3
|
743 D3DTEXOPCAPS_MULTIPLYADD
|
746 pCaps
->MaxTextureBlendStages
= 8; /* XXX wine */
747 (DWORD
)screen
->get_param(screen
, PIPE_CAP_BLEND_EQUATION_SEPARATE
);
748 pCaps
->MaxSimultaneousTextures
= screen
->get_shader_param(screen
,
749 PIPE_SHADER_FRAGMENT
, PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
);
750 if (pCaps
->MaxSimultaneousTextures
> NINE_MAX_SAMPLERS_PS
)
751 pCaps
->MaxSimultaneousTextures
= NINE_MAX_SAMPLERS_PS
;
753 pCaps
->VertexProcessingCaps
= D3DVTXPCAPS_TEXGEN
|
754 /*D3DVTXPCAPS_TEXGEN_SPHEREMAP |*/
755 D3DVTXPCAPS_MATERIALSOURCE7
|
756 D3DVTXPCAPS_DIRECTIONALLIGHTS
|
757 D3DVTXPCAPS_POSITIONALLIGHTS
|
758 D3DVTXPCAPS_LOCALVIEWER
|
759 D3DVTXPCAPS_TWEENING
|
760 /*D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER*/0;
762 pCaps
->MaxActiveLights
= NINE_MAX_LIGHTS_ACTIVE
; /* like GL_LIGHTi */
763 pCaps
->MaxUserClipPlanes
= PIPE_MAX_CLIP_PLANES
;
764 pCaps
->MaxVertexBlendMatrices
= 4; /* 1 vec4 BLENDWEIGHT/INDICES input */
765 pCaps
->MaxVertexBlendMatrixIndex
= 7; /* D3DTS_WORLDMATRIX(0..7) */
767 pCaps
->MaxPointSize
= screen
->get_paramf(screen
, PIPE_CAPF_MAX_POINT_WIDTH
);
769 pCaps
->MaxPrimitiveCount
= 0xFFFFF; /* <- wine, really 0xFFFFFFFF; */
770 pCaps
->MaxVertexIndex
= 0xFFFFF; /* <- wine, really 0xFFFFFFFF */
772 _min(screen
->get_shader_param(screen
,
773 PIPE_SHADER_VERTEX
, PIPE_SHADER_CAP_MAX_INPUTS
),
776 pCaps
->MaxStreamStride
= screen
->get_param(screen
,
777 PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE
);
779 pCaps
->VertexShaderVersion
= sm3
? D3DVS_VERSION(3,0) : D3DVS_VERSION(2,0);
781 /* VS 2 as well as 3.0 supports a minimum of 256 consts, no matter how
782 * much our architecture moans about it. The problem is that D3D9
783 * expects access to 16 int consts (i#), containing 3 components and
784 * 16 booleans (b#), containing only 1 component. This should be packed
785 * into 20 float vectors (16 for i# and 16/4 for b#), since gallium has
786 * removed support for the loop counter/boolean files. */
787 pCaps
->MaxVertexShaderConst
=
788 _min((screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
789 PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE
) /
790 sizeof(float[4])) - 20,
792 /* Fake the minimum cap for Windows. */
793 if (QUIRK(FAKE_CAPS
)) {
794 pCaps
->MaxVertexShaderConst
= 256;
797 pCaps
->MaxVertexShaderConst
= 0;
800 pCaps
->PixelShaderVersion
= sm3
? D3DPS_VERSION(3,0) : D3DPS_VERSION(2,0);
801 pCaps
->PixelShader1xMaxValue
= 8.0f
; /* XXX: wine */
803 pCaps
->DevCaps2
= D3DDEVCAPS2_STREAMOFFSET
|
804 D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET
|
805 D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES
|
806 /*D3DDEVCAPS2_DMAPNPATCH |*/
807 /*D3DDEVCAPS2_ADAPTIVETESSRTPATCH |*/
808 /*D3DDEVCAPS2_ADAPTIVETESSNPATCH |*/
809 /*D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH*/0;
811 pCaps
->MasterAdapterOrdinal
= 0;
812 pCaps
->AdapterOrdinalInGroup
= 0;
813 pCaps
->NumberOfAdaptersInGroup
= 1;
816 pCaps
->MaxNpatchTessellationLevel
= 0.0f
;
817 pCaps
->Reserved5
= 0;
819 /* XXX: use is_format_supported */
820 pCaps
->DeclTypes
= D3DDTCAPS_UBYTE4
|
828 D3DDTCAPS_FLOAT16_2
|
831 pCaps
->NumSimultaneousRTs
=
832 screen
->get_param(screen
, PIPE_CAP_MAX_RENDER_TARGETS
);
833 if (pCaps
->NumSimultaneousRTs
> NINE_MAX_SIMULTANEOUS_RENDERTARGETS
)
834 pCaps
->NumSimultaneousRTs
= NINE_MAX_SIMULTANEOUS_RENDERTARGETS
;
836 pCaps
->StretchRectFilterCaps
= D3DPTFILTERCAPS_MINFPOINT
|
837 D3DPTFILTERCAPS_MINFLINEAR
|
838 D3DPTFILTERCAPS_MAGFPOINT
|
839 D3DPTFILTERCAPS_MAGFLINEAR
;
842 pCaps
->VS20Caps
.Caps
= D3DVS20CAPS_PREDICATION
;
843 pCaps
->VS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
844 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
845 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
846 pCaps
->VS20Caps
.NumTemps
=
847 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
848 PIPE_SHADER_CAP_MAX_TEMPS
);
849 pCaps
->VS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
850 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
851 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
853 /* also check for values < 0, because get_shader_param may return unsigned */
854 if (pCaps
->VS20Caps
.DynamicFlowControlDepth
> D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
855 || pCaps
->VS20Caps
.DynamicFlowControlDepth
< 0)
856 pCaps
->VS20Caps
.DynamicFlowControlDepth
= D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
857 if (pCaps
->VS20Caps
.StaticFlowControlDepth
> D3DVS20_MAX_STATICFLOWCONTROLDEPTH
858 || pCaps
->VS20Caps
.StaticFlowControlDepth
< 0)
859 pCaps
->VS20Caps
.StaticFlowControlDepth
= D3DVS20_MAX_STATICFLOWCONTROLDEPTH
;
860 if (pCaps
->VS20Caps
.NumTemps
> D3DVS20_MAX_NUMTEMPS
)
861 pCaps
->VS20Caps
.NumTemps
= D3DVS20_MAX_NUMTEMPS
;
862 assert(pCaps
->VS20Caps
.DynamicFlowControlDepth
>= D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
863 assert(pCaps
->VS20Caps
.StaticFlowControlDepth
>= D3DVS20_MIN_STATICFLOWCONTROLDEPTH
);
864 assert(pCaps
->VS20Caps
.NumTemps
>= D3DVS20_MIN_NUMTEMPS
);
867 pCaps
->PS20Caps
.Caps
= D3DPS20CAPS_ARBITRARYSWIZZLE
|
868 D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
869 D3DPS20CAPS_PREDICATION
;
870 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
871 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
872 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
873 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
))
874 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT
;
875 if (screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
876 PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS
) ==
877 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
878 PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS
))
879 pCaps
->PS20Caps
.Caps
|= D3DPS20CAPS_NODEPENDENTREADLIMIT
;
880 pCaps
->PS20Caps
.DynamicFlowControlDepth
= /* XXX is this dynamic ? */
881 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
882 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
883 pCaps
->PS20Caps
.NumTemps
=
884 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
885 PIPE_SHADER_CAP_MAX_TEMPS
);
886 pCaps
->PS20Caps
.StaticFlowControlDepth
= /* XXX is this static ? */
887 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
888 PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH
);
889 pCaps
->PS20Caps
.NumInstructionSlots
=
890 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
891 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
893 if (pCaps
->PS20Caps
.DynamicFlowControlDepth
> D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
894 || pCaps
->PS20Caps
.DynamicFlowControlDepth
< 0)
895 pCaps
->PS20Caps
.DynamicFlowControlDepth
= D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH
;
896 if (pCaps
->PS20Caps
.StaticFlowControlDepth
> D3DPS20_MAX_STATICFLOWCONTROLDEPTH
897 || pCaps
->PS20Caps
.StaticFlowControlDepth
< 0)
898 pCaps
->PS20Caps
.StaticFlowControlDepth
= D3DPS20_MAX_STATICFLOWCONTROLDEPTH
;
899 if (pCaps
->PS20Caps
.NumTemps
> D3DPS20_MAX_NUMTEMPS
)
900 pCaps
->PS20Caps
.NumTemps
= D3DPS20_MAX_NUMTEMPS
;
901 if (pCaps
->PS20Caps
.NumInstructionSlots
> D3DPS20_MAX_NUMINSTRUCTIONSLOTS
)
902 pCaps
->PS20Caps
.NumInstructionSlots
= D3DPS20_MAX_NUMINSTRUCTIONSLOTS
;
903 assert(pCaps
->PS20Caps
.DynamicFlowControlDepth
>= D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH
);
904 assert(pCaps
->PS20Caps
.StaticFlowControlDepth
>= D3DPS20_MIN_STATICFLOWCONTROLDEPTH
);
905 assert(pCaps
->PS20Caps
.NumTemps
>= D3DPS20_MIN_NUMTEMPS
);
906 assert(pCaps
->PS20Caps
.NumInstructionSlots
>= D3DPS20_MIN_NUMINSTRUCTIONSLOTS
);
909 if (screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
910 PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS
))
911 pCaps
->VertexTextureFilterCaps
= pCaps
->TextureFilterCaps
&
912 ~(D3DPTFILTERCAPS_MIPFPOINT
|
913 D3DPTFILTERCAPS_MIPFPOINT
); /* XXX */
915 pCaps
->VertexTextureFilterCaps
= 0;
918 pCaps
->MaxVertexShader30InstructionSlots
=
919 screen
->get_shader_param(screen
, PIPE_SHADER_VERTEX
,
920 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
921 pCaps
->MaxPixelShader30InstructionSlots
=
922 screen
->get_shader_param(screen
, PIPE_SHADER_FRAGMENT
,
923 PIPE_SHADER_CAP_MAX_INSTRUCTIONS
);
924 if (pCaps
->MaxVertexShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
925 pCaps
->MaxVertexShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
926 if (pCaps
->MaxPixelShader30InstructionSlots
> D3DMAX30SHADERINSTRUCTIONS
)
927 pCaps
->MaxPixelShader30InstructionSlots
= D3DMAX30SHADERINSTRUCTIONS
;
928 assert(pCaps
->MaxVertexShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
929 assert(pCaps
->MaxPixelShader30InstructionSlots
>= D3DMIN30SHADERINSTRUCTIONS
);
931 pCaps
->MaxVertexShader30InstructionSlots
= 0;
932 pCaps
->MaxPixelShader30InstructionSlots
= 0;
935 /* 65535 is required, advertise more for GPUs with >= 2048 instruction slots */
936 pCaps
->MaxVShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxVertexShader30InstructionSlots
* 32);
937 pCaps
->MaxPShaderInstructionsExecuted
= MAX2(65535, pCaps
->MaxPixelShader30InstructionSlots
* 32);
939 if (debug_get_bool_option("NINE_DUMP_CAPS", FALSE
))
940 nine_dump_D3DCAPS9(DBG_CHANNEL
, pCaps
);
946 NineAdapter9_CreateDevice( struct NineAdapter9
*This
,
948 D3DDEVTYPE DeviceType
,
951 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
953 ID3DPresentGroup
*pPresentationGroup
,
954 IDirect3DDevice9
**ppReturnedDeviceInterface
)
956 struct pipe_screen
*screen
;
957 D3DDEVICE_CREATION_PARAMETERS params
;
962 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
963 "BehaviourFlags=%x " "pD3D9=%p pPresentationGroup=%p "
964 "ppReturnedDeviceInterface=%p\n", This
,
965 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
966 BehaviorFlags
, pD3D9
, pPresentationGroup
, ppReturnedDeviceInterface
);
968 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
970 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
972 return D3DERR_NOTAVAILABLE
;
975 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
977 DBG("Failed to get pipe_screen.\n");
981 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
983 DBG("Failed to get device caps.\n");
987 params
.AdapterOrdinal
= RealAdapter
;
988 params
.DeviceType
= DeviceType
;
989 params
.hFocusWindow
= hFocusWindow
;
990 params
.BehaviorFlags
= BehaviorFlags
;
992 hr
= NineDevice9_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
993 pD3D9
, pPresentationGroup
, This
->ctx
,
994 (struct NineDevice9
**)ppReturnedDeviceInterface
);
996 DBG("Failed to create device.\n");
999 DBG("NineDevice9 created successfully.\n");
1005 NineAdapter9_CreateDeviceEx( struct NineAdapter9
*This
,
1007 D3DDEVTYPE DeviceType
,
1009 DWORD BehaviorFlags
,
1010 D3DPRESENT_PARAMETERS
*pPresentationParameters
,
1011 D3DDISPLAYMODEEX
*pFullscreenDisplayMode
,
1012 IDirect3D9Ex
*pD3D9Ex
,
1013 ID3DPresentGroup
*pPresentationGroup
,
1014 IDirect3DDevice9Ex
**ppReturnedDeviceInterface
)
1016 struct pipe_screen
*screen
;
1017 D3DDEVICE_CREATION_PARAMETERS params
;
1022 DBG("This=%p RealAdapter=%u DeviceType=%s hFocusWindow=%p "
1023 "BehaviourFlags=%x " "pD3D9Ex=%p pPresentationGroup=%p "
1024 "ppReturnedDeviceInterface=%p\n", This
,
1025 RealAdapter
, nine_D3DDEVTYPE_to_str(DeviceType
), hFocusWindow
,
1026 BehaviorFlags
, pD3D9Ex
, pPresentationGroup
, ppReturnedDeviceInterface
);
1028 ID3DPresentGroup_GetVersion(pPresentationGroup
, &major
, &minor
);
1030 ERR("Doesn't support the ID3DPresentGroup version %d %d. Expected 1\n",
1032 return D3DERR_NOTAVAILABLE
;
1035 hr
= NineAdapter9_GetScreen(This
, DeviceType
, &screen
);
1037 DBG("Failed to get pipe_screen.\n");
1041 hr
= NineAdapter9_GetDeviceCaps(This
, DeviceType
, &caps
);
1043 DBG("Failed to get device caps.\n");
1047 params
.AdapterOrdinal
= RealAdapter
;
1048 params
.DeviceType
= DeviceType
;
1049 params
.hFocusWindow
= hFocusWindow
;
1050 params
.BehaviorFlags
= BehaviorFlags
;
1052 hr
= NineDevice9Ex_new(screen
, ¶ms
, &caps
, pPresentationParameters
,
1053 pFullscreenDisplayMode
,
1054 pD3D9Ex
, pPresentationGroup
, This
->ctx
,
1055 (struct NineDevice9Ex
**)ppReturnedDeviceInterface
);
1057 DBG("Failed to create device.\n");
1060 DBG("NineDevice9Ex created successfully.\n");
1065 ID3DAdapter9Vtbl NineAdapter9_vtable
= {
1066 (void *)NineUnknown_QueryInterface
,
1067 (void *)NineUnknown_AddRef
,
1068 (void *)NineUnknown_Release
,
1069 (void *)NineAdapter9_GetAdapterIdentifier
,
1070 (void *)NineAdapter9_CheckDeviceType
,
1071 (void *)NineAdapter9_CheckDeviceFormat
,
1072 (void *)NineAdapter9_CheckDeviceMultiSampleType
,
1073 (void *)NineAdapter9_CheckDepthStencilMatch
,
1074 (void *)NineAdapter9_CheckDeviceFormatConversion
,
1075 (void *)NineAdapter9_GetDeviceCaps
,
1076 (void *)NineAdapter9_CreateDevice
,
1077 (void *)NineAdapter9_CreateDeviceEx
1080 static const GUID
*NineAdapter9_IIDs
[] = {
1087 NineAdapter9_new( struct d3dadapter9_context
*pCTX
,
1088 struct NineAdapter9
**ppOut
)
1090 NINE_NEW(Adapter9
, ppOut
, FALSE
, /* args */ pCTX
);