Module: Mesa Branch: main Commit: fe3a800ad3def2261354bf0cba08ae6157a99210 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=fe3a800ad3def2261354bf0cba08ae6157a99210
Author: Jesse Natalie <[email protected]> Date: Fri Sep 24 08:47:32 2021 -0700 d3d12: Use overall resource format + plane format to get format info Reviewed-by: Sil Vilerino <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14123> --- src/gallium/drivers/d3d12/d3d12_context.cpp | 4 ++-- src/gallium/drivers/d3d12/d3d12_format.c | 9 ++++++++- src/gallium/drivers/d3d12/d3d12_format.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_context.cpp b/src/gallium/drivers/d3d12/d3d12_context.cpp index 7cac481de20..72aad42e34b 100644 --- a/src/gallium/drivers/d3d12/d3d12_context.cpp +++ b/src/gallium/drivers/d3d12/d3d12_context.cpp @@ -799,7 +799,7 @@ d3d12_init_sampler_view_descriptor(struct d3d12_sampler_view *sampler_view) struct d3d12_resource *res = d3d12_resource(texture); struct d3d12_screen *screen = d3d12_screen(texture->screen); - struct d3d12_format_info format_info = d3d12_get_format_info(state->format, state->target); + struct d3d12_format_info format_info = d3d12_get_format_info(res->overall_format, state->format, state->target); D3D12_SHADER_RESOURCE_VIEW_DESC desc = {}; desc.Format = d3d12_get_resource_srv_format(state->format, state->target); desc.ViewDimension = view_dimension(state->target, texture->nr_samples); @@ -914,7 +914,7 @@ d3d12_create_sampler_view(struct pipe_context *pctx, sampler_view->array_size = texture->array_size; sampler_view->texture_generation_id = p_atomic_read(&res->generation_id); - struct d3d12_format_info format_info = d3d12_get_format_info(state->format, state->target); + struct d3d12_format_info format_info = d3d12_get_format_info(res->overall_format, state->format, state->target); pipe_swizzle swizzle[4] = { format_info.swizzle[sampler_view->base.swizzle_r], format_info.swizzle[sampler_view->base.swizzle_g], diff --git a/src/gallium/drivers/d3d12/d3d12_format.c b/src/gallium/drivers/d3d12/d3d12_format.c index cee66c28dde..885d768d38e 100644 --- a/src/gallium/drivers/d3d12/d3d12_format.c +++ b/src/gallium/drivers/d3d12/d3d12_format.c @@ -302,7 +302,7 @@ d3d12_get_resource_srv_format(enum pipe_format f, enum pipe_texture_target targe PIPE_SWIZZLE_0, PIPE_SWIZZLE_1, PIPE_SWIZZLE_NONE } struct d3d12_format_info -d3d12_get_format_info(enum pipe_format pformat, enum pipe_texture_target target) +d3d12_get_format_info(enum pipe_format resource_format, enum pipe_format pformat, enum pipe_texture_target target) { DEF_SWIZZLE(IDENTITY, X, Y, Z, W); DEF_SWIZZLE(RGB1, X, Y, Z, 1); @@ -323,9 +323,16 @@ d3d12_get_format_info(enum pipe_format pformat, enum pipe_texture_target target) const struct util_format_description *format_desc = util_format_description(pformat); + unsigned plane_count = util_format_get_num_planes(resource_format); if (!util_format_is_srgb(pformat)) { if (target == PIPE_BUFFER && util_format_is_alpha(pformat)) { swizzle = BUFFER_SWIZZLE; + } else if (plane_count > 1) { + for (plane_slice = 0; plane_slice < plane_count; ++plane_slice) { + if (util_format_get_plane_format(resource_format, plane_slice) == pformat) + break; + } + assert(plane_slice < plane_count); } else if (pformat == PIPE_FORMAT_A8_UNORM) { /* no need to swizzle, it's natively supported */ } else if (util_format_is_intensity(pformat)) { diff --git a/src/gallium/drivers/d3d12/d3d12_format.h b/src/gallium/drivers/d3d12/d3d12_format.h index d9e0f99d8ef..e854120d301 100644 --- a/src/gallium/drivers/d3d12/d3d12_format.h +++ b/src/gallium/drivers/d3d12/d3d12_format.h @@ -61,7 +61,7 @@ struct d3d12_format_info { }; struct d3d12_format_info -d3d12_get_format_info(enum pipe_format format, enum pipe_texture_target); +d3d12_get_format_info(enum pipe_format resource_format, enum pipe_format format, enum pipe_texture_target); enum pipe_format d3d12_emulated_vtx_format(enum pipe_format fmt);
