d3d12: Support R16G16B16A16_FLOAT display targets

Since GDI doesn't support this format, we need a fallback path to
get contents on-screen if we're not using DXGI. For that scenario,
we allocate a proxy display target and blit during frontbuffer flush.

Once we have that fallback in place, we can override the sw winsys
format support check for that format.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27512>
This commit is contained in:
Jesse Natalie
2024-02-07 10:59:59 -08:00
committed by Marge Bot
parent 6a60270336
commit 5c85cdd378
3 changed files with 48 additions and 9 deletions

View File

@@ -86,6 +86,8 @@ d3d12_resource_destroy(struct pipe_screen *pscreen,
screen->winsys->displaytarget_destroy(screen->winsys, resource->dt);
}
if (resource->dt_proxy)
pipe_resource_reference(&resource->dt_proxy, NULL);
threaded_resource_deinit(presource);
if (can_map_directly(presource))
util_range_destroy(&resource->valid_buffer_range);
@@ -369,14 +371,24 @@ init_texture(struct d3d12_screen *screen,
if (screen->winsys && (templ->bind & PIPE_BIND_DISPLAY_TARGET)) {
struct sw_winsys *winsys = screen->winsys;
res->dt = winsys->displaytarget_create(screen->winsys,
res->base.b.bind,
res->base.b.format,
templ->width0,
templ->height0,
64, NULL,
&res->dt_stride);
res->dt_refcount = 1;
if (winsys->is_displaytarget_format_supported(winsys, res->base.b.bind, res->base.b.format)) {
res->dt = winsys->displaytarget_create(screen->winsys,
res->base.b.bind,
res->base.b.format,
templ->width0,
templ->height0,
64, NULL,
&res->dt_stride);
res->dt_refcount = 1;
} else {
assert(res->base.b.format == PIPE_FORMAT_R16G16B16A16_FLOAT); /* The only format we proxy right now */
struct pipe_resource proxy_templ = *templ;
proxy_templ.format = PIPE_FORMAT_R8G8B8A8_UNORM;
res->dt_proxy = screen->base.resource_create(&screen->base, &proxy_templ);
if (!res->dt_proxy)
return false;
assert(d3d12_resource(res->dt_proxy)->dt);
}
}
res->bo = d3d12_bo_wrap_res(screen, d3d12_res, init_residency);