2 * Copyright 2011 Joakim Sindholt <opensource@zhasha.com>
3 * Copyright 2013 Christoph Bumiller
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
25 #include "nine_pipe.h"
27 #include "cso_cache/cso_context.h"
30 nine_convert_dsa_state(struct cso_context
*ctx
, const DWORD
*rs
)
32 struct pipe_depth_stencil_alpha_state dsa
;
34 memset(&dsa
, 0, sizeof(dsa
)); /* memcmp safety */
36 if (rs
[D3DRS_ZENABLE
]) {
37 dsa
.depth
.enabled
= 1;
38 dsa
.depth
.writemask
= !!rs
[D3DRS_ZWRITEENABLE
];
39 dsa
.depth
.func
= d3dcmpfunc_to_pipe_func(rs
[D3DRS_ZFUNC
]);
42 if (rs
[D3DRS_STENCILENABLE
]) {
43 dsa
.stencil
[0].enabled
= 1;
44 dsa
.stencil
[0].func
= d3dcmpfunc_to_pipe_func(rs
[D3DRS_STENCILFUNC
]);
45 dsa
.stencil
[0].fail_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_STENCILFAIL
]);
46 dsa
.stencil
[0].zpass_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_STENCILPASS
]);
47 dsa
.stencil
[0].zfail_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_STENCILZFAIL
]);
48 dsa
.stencil
[0].valuemask
= rs
[D3DRS_STENCILMASK
];
49 dsa
.stencil
[0].writemask
= rs
[D3DRS_STENCILWRITEMASK
];
51 if (rs
[D3DRS_TWOSIDEDSTENCILMODE
]) {
52 dsa
.stencil
[1].enabled
= 1;
53 dsa
.stencil
[1].func
= d3dcmpfunc_to_pipe_func(rs
[D3DRS_CCW_STENCILFUNC
]);
54 dsa
.stencil
[1].fail_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_CCW_STENCILFAIL
]);
55 dsa
.stencil
[1].zpass_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_CCW_STENCILPASS
]);
56 dsa
.stencil
[1].zfail_op
= d3dstencilop_to_pipe_stencil_op(rs
[D3DRS_CCW_STENCILZFAIL
]);
57 dsa
.stencil
[1].valuemask
= dsa
.stencil
[0].valuemask
;
58 dsa
.stencil
[1].writemask
= dsa
.stencil
[0].writemask
;
62 if (rs
[D3DRS_ALPHATESTENABLE
]) {
63 dsa
.alpha
.enabled
= 1;
64 dsa
.alpha
.func
= d3dcmpfunc_to_pipe_func(rs
[D3DRS_ALPHAFUNC
]);
65 dsa
.alpha
.ref_value
= (float)rs
[D3DRS_ALPHAREF
] / 255.0f
;
68 cso_set_depth_stencil_alpha(ctx
, &dsa
);
71 /* TODO: Keep a static copy in device so we don't have to memset every time ? */
73 nine_convert_rasterizer_state(struct cso_context
*ctx
, const DWORD
*rs
)
75 struct pipe_rasterizer_state rast
;
77 memset(&rast
, 0, sizeof(rast
)); /* memcmp safety */
79 rast
.flatshade
= rs
[D3DRS_SHADEMODE
] == D3DSHADE_FLAT
;
80 /* rast.light_twoside = 0; */
81 /* rast.clamp_fragment_color = 0; */
82 /* rast.clamp_vertex_color = 0; */
83 /* rast.front_ccw = 0; */
84 rast
.cull_face
= d3dcull_to_pipe_face(rs
[D3DRS_CULLMODE
]);
85 rast
.fill_front
= d3dfillmode_to_pipe_polygon_mode(rs
[D3DRS_FILLMODE
]);
86 rast
.fill_back
= rast
.fill_front
;
87 rast
.offset_tri
= !!(rs
[D3DRS_DEPTHBIAS
] | rs
[D3DRS_SLOPESCALEDEPTHBIAS
]);
88 rast
.offset_line
= rast
.offset_tri
; /* triangles in wireframe mode */
89 rast
.offset_point
= 0; /* XXX ? */
90 rast
.scissor
= !!rs
[D3DRS_SCISSORTESTENABLE
];
91 /* rast.poly_smooth = 0; */
92 /* rast.poly_stipple_enable = 0; */
93 /* rast.point_smooth = 0; */
94 rast
.sprite_coord_mode
= PIPE_SPRITE_COORD_UPPER_LEFT
;
95 rast
.point_quad_rasterization
= !!rs
[D3DRS_POINTSPRITEENABLE
];
96 rast
.point_size_per_vertex
= rs
[NINED3DRS_VSPOINTSIZE
];
97 rast
.multisample
= !!rs
[D3DRS_MULTISAMPLEANTIALIAS
];
98 rast
.line_smooth
= !!rs
[D3DRS_ANTIALIASEDLINEENABLE
];
99 /* rast.line_stipple_enable = 0; */
100 rast
.line_last_pixel
= !!rs
[D3DRS_LASTPIXEL
];
101 rast
.flatshade_first
= 1;
102 /* rast.half_pixel_center = 0; */
103 /* rast.lower_left_origin = 0; */
104 /* rast.bottom_edge_rule = 0; */
105 /* rast.rasterizer_discard = 0; */
108 rast
.clip_plane_enable
= rs
[D3DRS_CLIPPLANEENABLE
];
109 /* rast.line_stipple_factor = 0; */
110 /* rast.line_stipple_pattern = 0; */
111 rast
.sprite_coord_enable
= rs
[D3DRS_POINTSPRITEENABLE
] ? 0xff : 0x00;
112 rast
.line_width
= 1.0f
;
113 rast
.point_size
= rs
[NINED3DRS_VSPOINTSIZE
] ? 1.0f
: asfloat(rs
[D3DRS_POINTSIZE
]); /* XXX: D3DRS_POINTSIZE_MIN/MAX */
114 rast
.offset_units
= asfloat(rs
[D3DRS_DEPTHBIAS
]) * asfloat(rs
[NINED3DRS_ZBIASSCALE
]);
115 rast
.offset_scale
= asfloat(rs
[D3DRS_SLOPESCALEDEPTHBIAS
]);
116 /* rast.offset_clamp = 0.0f; */
118 cso_set_rasterizer(ctx
, &rast
);
122 nine_convert_blend_state_fixup(struct pipe_blend_state
*blend
, const DWORD
*rs
)
124 if (unlikely(rs
[D3DRS_SRCBLEND
] == D3DBLEND_BOTHSRCALPHA
||
125 rs
[D3DRS_SRCBLEND
] == D3DBLEND_BOTHINVSRCALPHA
)) {
126 blend
->rt
[0].rgb_dst_factor
= (rs
[D3DRS_SRCBLEND
] == D3DBLEND_BOTHSRCALPHA
) ?
127 PIPE_BLENDFACTOR_INV_SRC_ALPHA
: PIPE_BLENDFACTOR_SRC_ALPHA
;
128 if (!rs
[D3DRS_SEPARATEALPHABLENDENABLE
])
129 blend
->rt
[0].alpha_dst_factor
= blend
->rt
[0].rgb_dst_factor
;
131 if (unlikely(rs
[D3DRS_SEPARATEALPHABLENDENABLE
] &&
132 (rs
[D3DRS_SRCBLENDALPHA
] == D3DBLEND_BOTHSRCALPHA
||
133 rs
[D3DRS_SRCBLENDALPHA
] == D3DBLEND_BOTHINVSRCALPHA
))) {
134 blend
->rt
[0].alpha_dst_factor
= (rs
[D3DRS_SRCBLENDALPHA
] == D3DBLEND_BOTHSRCALPHA
) ?
135 PIPE_BLENDFACTOR_INV_SRC_ALPHA
: PIPE_BLENDFACTOR_SRC_ALPHA
;
140 nine_convert_blend_state(struct cso_context
*ctx
, const DWORD
*rs
)
142 struct pipe_blend_state blend
;
144 memset(&blend
, 0, sizeof(blend
)); /* memcmp safety */
146 blend
.dither
= !!rs
[D3DRS_DITHERENABLE
];
148 /* blend.alpha_to_one = 0; */
149 /* blend.alpha_to_coverage = 0; */ /* XXX */
151 blend
.rt
[0].blend_enable
= !!rs
[D3DRS_ALPHABLENDENABLE
];
152 if (blend
.rt
[0].blend_enable
) {
153 blend
.rt
[0].rgb_func
= d3dblendop_to_pipe_blend(rs
[D3DRS_BLENDOP
]);
154 blend
.rt
[0].rgb_src_factor
= d3dblend_color_to_pipe_blendfactor(rs
[D3DRS_SRCBLEND
]);
155 blend
.rt
[0].rgb_dst_factor
= d3dblend_color_to_pipe_blendfactor(rs
[D3DRS_DESTBLEND
]);
156 if (rs
[D3DRS_SEPARATEALPHABLENDENABLE
]) {
157 blend
.rt
[0].alpha_func
= d3dblendop_to_pipe_blend(rs
[D3DRS_BLENDOPALPHA
]);
158 blend
.rt
[0].alpha_src_factor
= d3dblend_alpha_to_pipe_blendfactor(rs
[D3DRS_SRCBLENDALPHA
]);
159 blend
.rt
[0].alpha_dst_factor
= d3dblend_alpha_to_pipe_blendfactor(rs
[D3DRS_DESTBLENDALPHA
]);
161 /* TODO: Just copy the rgb values ? SRC1_x may differ ... */
162 blend
.rt
[0].alpha_func
= blend
.rt
[0].rgb_func
;
163 blend
.rt
[0].alpha_src_factor
= d3dblend_alpha_to_pipe_blendfactor(rs
[D3DRS_SRCBLEND
]);
164 blend
.rt
[0].alpha_dst_factor
= d3dblend_alpha_to_pipe_blendfactor(rs
[D3DRS_DESTBLEND
]);
166 nine_convert_blend_state_fixup(&blend
, rs
); /* for BOTH[INV]SRCALPHA */
168 blend
.rt
[0].colormask
= rs
[D3DRS_COLORWRITEENABLE
];
170 if (rs
[D3DRS_COLORWRITEENABLE1
] != rs
[D3DRS_COLORWRITEENABLE
] ||
171 rs
[D3DRS_COLORWRITEENABLE2
] != rs
[D3DRS_COLORWRITEENABLE
] ||
172 rs
[D3DRS_COLORWRITEENABLE3
] != rs
[D3DRS_COLORWRITEENABLE
]) {
174 blend
.independent_blend_enable
= TRUE
;
175 for (i
= 1; i
< 4; ++i
)
176 blend
.rt
[i
] = blend
.rt
[0];
177 blend
.rt
[1].colormask
= rs
[D3DRS_COLORWRITEENABLE1
];
178 blend
.rt
[2].colormask
= rs
[D3DRS_COLORWRITEENABLE2
];
179 blend
.rt
[3].colormask
= rs
[D3DRS_COLORWRITEENABLE3
];
182 /* blend.force_srgb = !!rs[D3DRS_SRGBWRITEENABLE]; */
184 cso_set_blend(ctx
, &blend
);
188 nine_convert_sampler_state(struct cso_context
*ctx
, int idx
, const DWORD
*ss
)
190 struct pipe_sampler_state samp
;
193 (idx
< NINE_MAX_SAMPLERS_PS
|| idx
>= NINE_SAMPLER_VS(0)) &&
194 (idx
< NINE_MAX_SAMPLERS
));
196 memset(&samp
, 0, sizeof(samp
)); /* memcmp safety */
198 if (ss
[D3DSAMP_MIPFILTER
] != D3DTEXF_NONE
) {
199 samp
.lod_bias
= asfloat(ss
[D3DSAMP_MIPMAPLODBIAS
]);
200 samp
.min_lod
= ss
[NINED3DSAMP_MINLOD
];
201 samp
.min_mip_filter
= (ss
[D3DSAMP_MIPFILTER
] == D3DTEXF_POINT
) ? PIPE_TEX_FILTER_NEAREST
: PIPE_TEX_FILTER_LINEAR
;
203 samp
.min_mip_filter
= PIPE_TEX_MIPFILTER_NONE
;
205 samp
.max_lod
= 15.0f
;
206 samp
.wrap_s
= d3dtextureaddress_to_pipe_tex_wrap(ss
[D3DSAMP_ADDRESSU
]);
207 samp
.wrap_t
= d3dtextureaddress_to_pipe_tex_wrap(ss
[D3DSAMP_ADDRESSV
]);
208 samp
.wrap_r
= d3dtextureaddress_to_pipe_tex_wrap(ss
[D3DSAMP_ADDRESSW
]);
209 samp
.min_img_filter
= ss
[D3DSAMP_MINFILTER
] == D3DTEXF_POINT
? PIPE_TEX_FILTER_NEAREST
: PIPE_TEX_FILTER_LINEAR
;
210 samp
.mag_img_filter
= ss
[D3DSAMP_MAGFILTER
] == D3DTEXF_POINT
? PIPE_TEX_FILTER_NEAREST
: PIPE_TEX_FILTER_LINEAR
;
211 if (ss
[D3DSAMP_MINFILTER
] == D3DTEXF_ANISOTROPIC
||
212 ss
[D3DSAMP_MAGFILTER
] == D3DTEXF_ANISOTROPIC
)
213 samp
.max_anisotropy
= ss
[D3DSAMP_MAXANISOTROPY
];
214 samp
.compare_mode
= ss
[NINED3DSAMP_SHADOW
] ? PIPE_TEX_COMPARE_R_TO_TEXTURE
: PIPE_TEX_COMPARE_NONE
;
215 samp
.compare_func
= PIPE_FUNC_LEQUAL
;
216 samp
.normalized_coords
= 1;
217 samp
.seamless_cube_map
= 1;
218 d3dcolor_to_pipe_color_union(&samp
.border_color
, ss
[D3DSAMP_BORDERCOLOR
]);
220 /* see nine_state.h */
221 if (idx
< NINE_MAX_SAMPLERS_PS
)
222 cso_single_sampler(ctx
, PIPE_SHADER_FRAGMENT
, idx
- NINE_SAMPLER_PS(0), &samp
);
224 cso_single_sampler(ctx
, PIPE_SHADER_VERTEX
, idx
- NINE_SAMPLER_VS(0), &samp
);
228 nine_pipe_context_clear(struct NineDevice9
*This
)
230 struct pipe_context
*pipe
= This
->pipe
;
231 struct cso_context
*cso
= This
->cso
;
232 pipe
->bind_vs_state(pipe
, NULL
);
233 pipe
->bind_fs_state(pipe
, NULL
);
235 /* Don't unbind constant buffers, they're device-private and
236 * do not change on Reset.
239 cso_set_samplers(cso
, PIPE_SHADER_VERTEX
, 0, NULL
);
240 cso_set_samplers(cso
, PIPE_SHADER_FRAGMENT
, 0, NULL
);
242 pipe
->set_sampler_views(pipe
, PIPE_SHADER_FRAGMENT
, 0, 0, NULL
);
243 pipe
->set_sampler_views(pipe
, PIPE_SHADER_VERTEX
, 0, 0, NULL
);
245 pipe
->set_vertex_buffers(pipe
, 0, This
->caps
.MaxStreams
, NULL
);
246 pipe
->set_index_buffer(pipe
, NULL
);
249 const enum pipe_format nine_d3d9_to_pipe_format_map
[120] =
251 [D3DFMT_UNKNOWN
] = PIPE_FORMAT_NONE
,
252 [D3DFMT_R8G8B8
] = PIPE_FORMAT_NONE
,
253 [D3DFMT_A8R8G8B8
] = PIPE_FORMAT_B8G8R8A8_UNORM
,
254 [D3DFMT_X8R8G8B8
] = PIPE_FORMAT_B8G8R8X8_UNORM
,
255 [D3DFMT_R5G6B5
] = PIPE_FORMAT_B5G6R5_UNORM
,
256 [D3DFMT_X1R5G5B5
] = PIPE_FORMAT_B5G5R5X1_UNORM
,
257 [D3DFMT_A1R5G5B5
] = PIPE_FORMAT_B5G5R5A1_UNORM
,
258 [D3DFMT_A4R4G4B4
] = PIPE_FORMAT_B4G4R4A4_UNORM
,
259 [D3DFMT_R3G3B2
] = PIPE_FORMAT_B2G3R3_UNORM
,
260 [D3DFMT_A8
] = PIPE_FORMAT_A8_UNORM
,
261 [D3DFMT_A8R3G3B2
] = PIPE_FORMAT_NONE
262 [D3DFMT_X4R4G4B4
] = PIPE_FORMAT_B4G4R4X4_UNORM
,
263 [D3DFMT_A2B10G10R10
] = PIPE_FORMAT_R10G10B10A2_UNORM
,
264 [D3DFMT_A8B8G8R8
] = PIPE_FORMAT_R8G8B8A8_UNORM
,
265 [D3DFMT_X8B8G8R8
] = PIPE_FORMAT_R8G8B8X8_UNORM
,
266 [D3DFMT_G16R16
] = PIPE_FORMAT_R16G16_UNORM
,
267 [D3DFMT_A2R10G10B10
] = PIPE_FORMAT_B10G10R10A2_UNORM
,
268 [D3DFMT_A16B16G16R16
] = PIPE_FORMAT_R16G16B16A16_UNORM
,
269 [D3DFMT_A8P8
] = PIPE_FORMAT_NONE
,
270 [D3DFMT_P8
] = PIPE_FORMAT_NONE
,
271 [D3DFMT_L8
] = PIPE_FORMAT_L8_UNORM
,
272 [D3DFMT_A8L8
] = PIPE_FORMAT_L8A8_UNORM
,
273 [D3DFMT_A4L4
] = PIPE_FORMAT_L4A4_UNORM
,
274 [D3DFMT_V8U8
] = PIPE_FORMAT_R8G8_SNORM
,
275 [D3DFMT_L6V5U5
] = PIPE_FORMAT_NONE
,
276 [D3DFMT_X8L8V8U8
] = PIPE_FORMAT_NONE
,
277 [D3DFMT_Q8W8V8U8
] = PIPE_FORMAT_R8G8B8A8_SNORM
,
278 [D3DFMT_V16U16
] = PIPE_FORMAT_R16G16_SNORM
,
279 [D3DFMT_A2W10V10U10
] = PIPE_FORMAT_R10SG10SB10SA2U_NORM
,
280 [D3DFMT_D16_LOCKABLE
] = PIPE_FORMAT_Z16_UNORM
,
281 [D3DFMT_D32
] = PIPE_FORMAT_Z32_UNORM
,
282 [D3DFMT_D15S1
] = PIPE_FORMAT_Z24_UNORM_S8_UINT
,
283 [D3DFMT_D24S8
] = PIPE_FORMAT_S8_UINT_Z24_UNORM
,
284 [D3DFMT_D24X8
] = PIPE_FORMAT_X8Z24_UNORM
,
285 [D3DFMT_D24X4S4
] = PIPE_FORMAT_Z24_UNORM_S8_UINT
,
286 [D3DFMT_D16
] = PIPE_FORMAT_Z16_UNORM
,
287 [D3DFMT_D32F_LOCKABLE
] = PIPE_FORMAT_Z32_FLOAT
,
288 [D3DFMT_D24FS8
] = PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
,
289 [D3DFMT_D32_LOCKABLE
] = PIPE_FORMAT_NONE
,
290 [D3DFMT_S8_LOCKABLE
] = PIPE_FORMAT_NONE
,
291 [D3DFMT_L16
] = PIPE_FORMAT_L16_UNORM
,
292 [D3DFMT_VERTEXDATA
] = PIPE_FORMAT_NONE
,
293 [D3DFMT_INDEX16
] = PIPE_FORMAT_R16_UINT
,
294 [D3DFMT_INDEX32
] = PIPE_FORMAT_R32_UINT
,
295 [D3DFMT_Q16W16V16U16
] = PIPE_FORMAT_R16G16B16A16_SNORM
,
296 [D3DFMT_R16F
] = PIPE_FORMAT_R16_FLOAT
,
297 [D3DFMT_G16R16F
] = PIPE_FORMAT_R16G16_FLOAT
,
298 [D3DFMT_A16B16G16R16F
] = PIPE_FORMAT_R16G16B16A16_FLOAT
,
299 [D3DFMT_R32F
] = PIPE_FORMAT_R32_FLOAT
,
300 [D3DFMT_G32R32F
] = PIPE_FORMAT_R32G32_FLOAT
,
301 [D3DFMT_A32B32G32R32F
] = PIPE_FORMAT_R32G32B32A32_FLOAT
,
302 [D3DFMT_CxV8U8
] = PIPE_FORMAT_NONE
,
303 [D3DFMT_A1
] = PIPE_FORMAT_NONE
,
304 [D3DFMT_A2B10G10R10_XR_BIAS
] = PIPE_FORMAT_NONE
,
307 const D3DFORMAT nine_pipe_to_d3d9_format_map
[PIPE_FORMAT_COUNT
] =
309 [PIPE_FORMAT_NONE
] = D3DFMT_UNKNOWN
,
311 /* [PIPE_FORMAT_B8G8R8_UNORM] = D3DFMT_R8G8B8, */
312 [PIPE_FORMAT_B8G8R8A8_UNORM
] = D3DFMT_A8R8G8B8
,
313 [PIPE_FORMAT_B8G8R8X8_UNORM
] = D3DFMT_X8R8G8B8
,
314 [PIPE_FORMAT_B5G6R5_UNORM
] = D3DFMT_R5G6B5
,
315 [PIPE_FORMAT_B5G5R5X1_UNORM
] = D3DFMT_X1R5G5B5
,
316 [PIPE_FORMAT_B5G5R5A1_UNORM
] = D3DFMT_A1R5G5B5
,
317 [PIPE_FORMAT_B4G4R4A4_UNORM
] = D3DFMT_A4R4G4B4
,
318 [PIPE_FORMAT_B2G3R3_UNORM
] = D3DFMT_R3G3B2
,
319 [PIPE_FORMAT_A8_UNORM
] = D3DFMT_A8
,
320 /* [PIPE_FORMAT_B2G3R3A8_UNORM] = D3DFMT_A8R3G3B2, */
321 [PIPE_FORMAT_B4G4R4X4_UNORM
] = D3DFMT_X4R4G4B4
,
322 [PIPE_FORMAT_R10G10B10A2_UNORM
] = D3DFMT_A2B10G10R10
,
323 [PIPE_FORMAT_R8G8B8A8_UNORM
] = D3DFMT_A8B8G8R8
,
324 [PIPE_FORMAT_R8G8B8X8_UNORM
] = D3DFMT_X8B8G8R8
,
325 [PIPE_FORMAT_R16G16_UNORM
] = D3DFMT_G16R16
,
326 [PIPE_FORMAT_B10G10R10A2_UNORM
] = D3DFMT_A2R10G10B10
,
327 [PIPE_FORMAT_R16G16B16A16_UNORM
] = D3DFMT_A16B16G16R16
,
329 [PIPE_FORMAT_R8_UINT
] = D3DFMT_P8
,
330 [PIPE_FORMAT_R8A8_UINT
] = D3DFMT_A8P8
,
332 [PIPE_FORMAT_L8_UNORM
] = D3DFMT_L8
,
333 [PIPE_FORMAT_L8A8_UNORM
] = D3DFMT_A8L8
,
334 [PIPE_FORMAT_L4A4_UNORM
] = D3DFMT_A4L4
,
336 [PIPE_FORMAT_R8G8_SNORM
] = D3DFMT_V8U8
,
337 /* [PIPE_FORMAT_?] = D3DFMT_L6V5U5, */
338 /* [PIPE_FORMAT_?] = D3DFMT_X8L8V8U8, */
339 [PIPE_FORMAT_R8G8B8A8_SNORM
] = D3DFMT_Q8W8V8U8
,
340 [PIPE_FORMAT_R16G16_SNORM
] = D3DFMT_V16U16
,
341 [PIPE_FORMAT_R10SG10SB10SA2U_NORM
] = D3DFMT_A2W10V10U10
,
343 [PIPE_FORMAT_YUYV
] = D3DFMT_UYVY
,
344 /* [PIPE_FORMAT_YUY2] = D3DFMT_YUY2, */
345 [PIPE_FORMAT_DXT1_RGBA
] = D3DFMT_DXT1
,
346 /* [PIPE_FORMAT_DXT2_RGBA] = D3DFMT_DXT2, */
347 [PIPE_FORMAT_DXT3_RGBA
] = D3DFMT_DXT3
,
348 /* [PIPE_FORMAT_DXT4_RGBA] = D3DFMT_DXT4, */
349 [PIPE_FORMAT_DXT5_RGBA
] = D3DFMT_DXT5
,
350 /* [PIPE_FORMAT_?] = D3DFMT_MULTI2_ARGB8, (MET) */
351 [PIPE_FORMAT_R8G8_B8G8_UNORM
] = D3DFMT_R8G8_B8G8
, /* XXX: order */
352 [PIPE_FORMAT_G8R8_G8B8_UNORM
] = D3DFMT_G8R8_G8B8
,
354 [PIPE_FORMAT_Z16_UNORM
] = D3DFMT_D16_LOCKABLE
,
355 [PIPE_FORMAT_Z32_UNORM
] = D3DFMT_D32
,
356 /* [PIPE_FORMAT_Z15_UNORM_S1_UINT] = D3DFMT_D15S1, */
357 [PIPE_FORMAT_S8_UINT_Z24_UNORM
] = D3DFMT_D24S8
,
358 [PIPE_FORMAT_X8Z24_UNORM
] = D3DFMT_D24X8
,
359 [PIPE_FORMAT_L16_UNORM
] = D3DFMT_L16
,
360 [PIPE_FORMAT_Z32_FLOAT
] = D3DFMT_D32F_LOCKABLE
,
361 /* [PIPE_FORMAT_Z24_FLOAT_S8_UINT] = D3DFMT_D24FS8, */
363 [PIPE_FORMAT_R16_UINT
] = D3DFMT_INDEX16
,
364 [PIPE_FORMAT_R32_UINT
] = D3DFMT_INDEX32
,
365 [PIPE_FORMAT_R16G16B16A16_SNORM
] = D3DFMT_Q16W16V16U16
,
367 [PIPE_FORMAT_R16_FLOAT
] = D3DFMT_R16F
,
368 [PIPE_FORMAT_R32_FLOAT
] = D3DFMT_R32F
,
369 [PIPE_FORMAT_R16G16_FLOAT
] = D3DFMT_G16R16F
,
370 [PIPE_FORMAT_R32G32_FLOAT
] = D3DFMT_G32R32F
,
371 [PIPE_FORMAT_R16G16B16A16_FLOAT
] = D3DFMT_A16B16G16R16F
,
372 [PIPE_FORMAT_R32G32B32A32_FLOAT
] = D3DFMT_A32B32G32R32F
,
374 /* [PIPE_FORMAT_?] = D3DFMT_CxV8U8, */