d3d12: Use overall resource format + plane format to get format info

Reviewed-by: Sil Vilerino <sivileri@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14123>
This commit is contained in:
Jesse Natalie
2021-09-24 08:47:32 -07:00
committed by Marge Bot
parent 0312142d96
commit fe3a800ad3
3 changed files with 11 additions and 4 deletions
+2 -2
View File
@@ -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],
+8 -1
View File
@@ -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)) {
+1 -1
View File
@@ -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);