d3d12: Fix up resource import validation

Format on buffers is irrelevant and bind flag validation needs to be disabled.

Reviewed-by: Bill Kristiansen <billkris@microsoft.com>
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17446>
This commit is contained in:
Jesse Natalie
2022-07-11 15:55:35 -07:00
committed by Marge Bot
parent d119e6a46f
commit 333432310a

View File

@@ -568,6 +568,7 @@ d3d12_resource_from_handle(struct pipe_screen *pscreen,
res->base.b.last_level + 1, templ->last_level + 1); res->base.b.last_level + 1, templ->last_level + 1);
goto invalid; goto invalid;
} }
if (templ->target != PIPE_BUFFER) {
if ((footprint->Format != d3d12_get_format(templ->format) && if ((footprint->Format != d3d12_get_format(templ->format) &&
footprint->Format != d3d12_get_typeless_format(templ->format)) || footprint->Format != d3d12_get_typeless_format(templ->format)) ||
(incoming_res_desc.Format != d3d12_get_format((enum pipe_format)handle->format) && (incoming_res_desc.Format != d3d12_get_format((enum pipe_format)handle->format) &&
@@ -583,10 +584,15 @@ d3d12_resource_from_handle(struct pipe_screen *pscreen,
incoming_res_desc.Format); incoming_res_desc.Format);
goto invalid; goto invalid;
} }
}
/* In an ideal world we'd be able to validate this, but gallium's use of bind
* flags during resource creation is pretty bad: some bind flags are always set
* (like PIPE_BIND_RENDER_TARGET) while others are never set (PIPE_BIND_SHADER_BUFFER)
*
if (templ->bind & ~res->base.b.bind) { if (templ->bind & ~res->base.b.bind) {
debug_printf("d3d12: Imported resource doesn't have necessary bind flags\n"); debug_printf("d3d12: Imported resource doesn't have necessary bind flags\n");
goto invalid; goto invalid;
} } */
res->base.b.format = templ->format; res->base.b.format = templ->format;
res->overall_format = (enum pipe_format)handle->format; res->overall_format = (enum pipe_format)handle->format;