Mesa (main): d3d12: Support RGBX formats mapped to RGBA
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Nov 19 23:20:52 UTC 2021
Module: Mesa
Branch: main
Commit: 218860701495c8013dc826a2f2197ab2fbed8644
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=218860701495c8013dc826a2f2197ab2fbed8644
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Wed Aug 11 14:43:52 2021 -0700
d3d12: Support RGBX formats mapped to RGBA
Reviewed-by: Bill Kristiansen <billkris at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13054>
---
src/gallium/drivers/d3d12/d3d12_blit.cpp | 3 ++-
src/gallium/drivers/d3d12/d3d12_context.cpp | 4 ++++
src/gallium/drivers/d3d12/d3d12_format.c | 12 ++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/d3d12/d3d12_blit.cpp b/src/gallium/drivers/d3d12/d3d12_blit.cpp
index 55a741a6bce..e87ef87e750 100644
--- a/src/gallium/drivers/d3d12/d3d12_blit.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_blit.cpp
@@ -69,7 +69,8 @@ resolve_supported(const struct pipe_blit_info *info)
return false;
} else {
if (util_format_get_mask(info->dst.format) != info->mask ||
- util_format_get_mask(info->src.format) != info->mask)
+ util_format_get_mask(info->src.format) != info->mask ||
+ util_format_has_alpha1(info->src.format))
return false;
}
diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp
index d09315a5093..7cac481de20 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_context.cpp
@@ -1697,6 +1697,10 @@ d3d12_clear_render_target(struct pipe_context *pctx,
clear_color[c] = color->f[c];
}
+ if (!(util_format_colormask(util_format_description(psurf->texture->format)) &
+ PIPE_MASK_A))
+ clear_color[3] = 1.0f;
+
D3D12_RECT rect = { (int)dstx, (int)dsty,
(int)dstx + (int)width,
(int)dsty + (int)height };
diff --git a/src/gallium/drivers/d3d12/d3d12_format.c b/src/gallium/drivers/d3d12/d3d12_format.c
index 1a871029f52..d49c3b00c1f 100644
--- a/src/gallium/drivers/d3d12/d3d12_format.c
+++ b/src/gallium/drivers/d3d12/d3d12_format.c
@@ -63,6 +63,16 @@ static const DXGI_FORMAT formats[PIPE_FORMAT_COUNT] = {
MAP_FORMAT_INT(R8G8B8A8)
MAP_FORMAT_SRGB(R8G8B8A8)
+ /* Since we report PIPE_CAP_RGB_OVERRIDE_DST_ALPHA_BLEND and other caps,
+ * we can rely on st/mesa to force the alpha to 1 for these, so we can
+ * just use RGBA. This is needed to support RGB configs, since some apps
+ * will only choose RGB (not RGBA) configs.
+ */
+ [PIPE_FORMAT_R8G8B8X8_UNORM] = DXGI_FORMAT_R8G8B8A8_UNORM,
+ [PIPE_FORMAT_R8G8B8X8_SNORM] = DXGI_FORMAT_R8G8B8A8_SNORM,
+ [PIPE_FORMAT_R8G8B8X8_UINT] = DXGI_FORMAT_R8G8B8A8_UINT,
+ [PIPE_FORMAT_R8G8B8X8_SINT] = DXGI_FORMAT_R8G8B8A8_SINT,
+
[PIPE_FORMAT_B8G8R8X8_UNORM] = DXGI_FORMAT_B8G8R8X8_UNORM,
[PIPE_FORMAT_B8G8R8A8_UNORM] = DXGI_FORMAT_B8G8R8A8_UNORM,
@@ -238,6 +248,8 @@ d3d12_get_format_info(enum pipe_format pformat, enum pipe_texture_target target)
* but the shader will read the x component so we need to adjust the swizzle. */
plane_slice = 1;
swizzle = STENCIL_SWIZZLE;
+ } else if (util_format_has_alpha1(pformat)) {
+ swizzle = RGB1_SWIZZLE;
}
}
More information about the mesa-commit
mailing list