- /* ZZZ1 -> 0Z01 (see end of docs/source/tgsi.rst)
- * XXX: but it's wrong
- swizzle[0] = PIPE_SWIZZLE_ZERO;
- swizzle[2] = PIPE_SWIZZLE_ZERO; */
- } else
- if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X &&
- desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_1) {
- /* R001/RG01 -> R111/RG11 */
- if (desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0)
- swizzle[1] = PIPE_SWIZZLE_ONE;
- if (desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0)
- swizzle[2] = PIPE_SWIZZLE_ONE;
+ /* msdn doc is incomplete here and wrong.
+ * The only formats that can be read directly here
+ * are DF16, DF24 and INTZ.
+ * Tested on win the swizzle is
+ * R = depth, G = B = 0, A = 1 for DF16 and DF24
+ * R = G = B = A = depth for INTZ
+ * For the other ZS formats that can't be read directly
+ * but can be used as shadow map, the result is duplicated on
+ * all channel */
+ if (This->format == D3DFMT_DF16 ||
+ This->format == D3DFMT_DF24) {
+ swizzle[1] = PIPE_SWIZZLE_ZERO;
+ swizzle[2] = PIPE_SWIZZLE_ZERO;
+ swizzle[3] = PIPE_SWIZZLE_ONE;
+ } else {
+ swizzle[1] = PIPE_SWIZZLE_RED;
+ swizzle[2] = PIPE_SWIZZLE_RED;
+ swizzle[3] = PIPE_SWIZZLE_RED;
+ }
+ } else if (resource->format != PIPE_FORMAT_A8_UNORM &&
+ resource->format != PIPE_FORMAT_RGTC1_UNORM) {
+ /* exceptions:
+ * A8 should have 0.0 as default values for RGB.
+ * ATI1/RGTC1 should be r 0 0 1 (tested on windows).
+ * It is already what gallium does. All the other ones
+ * should have 1.0 for non-defined values */
+ for (i = 0; i < 4; i++) {
+ if (SWIZZLE_TO_REPLACE(desc->swizzle[i]))
+ swizzle[i] = PIPE_SWIZZLE_ONE;
+ }