d3d12: Add support for importing d3d12_video_buffer from handle
Reviewed-by: Giancarlo Devich <gdevich@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18328>
This commit is contained in:
@@ -2509,6 +2509,7 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
// Add d3d12 video functions entrypoints
|
||||
ctx->base.create_video_codec = d3d12_video_create_codec;
|
||||
ctx->base.create_video_buffer = d3d12_video_buffer_create;
|
||||
ctx->base.video_buffer_from_handle = d3d12_video_buffer_from_handle;
|
||||
#endif
|
||||
slab_create_child(&ctx->transfer_pool, &d3d12_screen(pscreen)->transfer_pool);
|
||||
slab_create_child(&ctx->transfer_pool_unsync, &d3d12_screen(pscreen)->transfer_pool);
|
||||
|
||||
@@ -32,12 +32,13 @@
|
||||
#include "util/u_video.h"
|
||||
#include "vl/vl_video_buffer.h"
|
||||
#include "util/u_sampler.h"
|
||||
#include "frontend/winsys_handle.h"
|
||||
|
||||
/**
|
||||
* creates a video buffer
|
||||
*/
|
||||
struct pipe_video_buffer *
|
||||
d3d12_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buffer *tmpl)
|
||||
static struct pipe_video_buffer *
|
||||
d3d12_video_buffer_create_impl(struct pipe_context *pipe,
|
||||
const struct pipe_video_buffer *tmpl,
|
||||
struct winsys_handle *handle,
|
||||
unsigned usage)
|
||||
{
|
||||
assert(pipe);
|
||||
assert(tmpl);
|
||||
@@ -46,7 +47,6 @@ d3d12_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buf
|
||||
/// Initialize d3d12_video_buffer
|
||||
///
|
||||
|
||||
|
||||
if (!(tmpl->buffer_format == PIPE_FORMAT_NV12)) {
|
||||
debug_printf("[d3d12_video_buffer] buffer_format is only supported as PIPE_FORMAT_NV12.\n");
|
||||
return nullptr;
|
||||
@@ -91,7 +91,16 @@ d3d12_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buf
|
||||
templ.flags = 0;
|
||||
|
||||
// This calls d3d12_create_resource as the function ptr is set in d3d12_screen.resource_create
|
||||
pD3D12VideoBuffer->texture = (struct d3d12_resource *) pipe->screen->resource_create(pipe->screen, &templ);
|
||||
if(handle)
|
||||
{
|
||||
// WINSYS_HANDLE_TYPE_D3D12_RES implies taking ownership of the reference
|
||||
if(handle->type == WINSYS_HANDLE_TYPE_D3D12_RES)
|
||||
((IUnknown *)handle->com_obj)->AddRef();
|
||||
pD3D12VideoBuffer->texture = (struct d3d12_resource *) pipe->screen->resource_from_handle(pipe->screen, &templ, handle, usage);
|
||||
}
|
||||
else
|
||||
pD3D12VideoBuffer->texture = (struct d3d12_resource *) pipe->screen->resource_create(pipe->screen, &templ);
|
||||
|
||||
d3d12_promote_to_permanent_residency((struct d3d12_screen*) pipe->screen, pD3D12VideoBuffer->texture);
|
||||
|
||||
if (pD3D12VideoBuffer->texture == nullptr) {
|
||||
@@ -110,6 +119,28 @@ failed:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* creates a video buffer from a handle
|
||||
*/
|
||||
struct pipe_video_buffer *
|
||||
d3d12_video_buffer_from_handle( struct pipe_context *pipe,
|
||||
const struct pipe_video_buffer *tmpl,
|
||||
struct winsys_handle *handle,
|
||||
unsigned usage)
|
||||
{
|
||||
return d3d12_video_buffer_create_impl(pipe, tmpl, handle, usage);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a video buffer
|
||||
*/
|
||||
struct pipe_video_buffer *
|
||||
d3d12_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buffer *tmpl)
|
||||
{
|
||||
return d3d12_video_buffer_create_impl(pipe, tmpl, NULL, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* destroy this video buffer
|
||||
*/
|
||||
|
||||
@@ -39,6 +39,14 @@
|
||||
struct pipe_video_buffer *
|
||||
d3d12_video_buffer_create(struct pipe_context *pipe, const struct pipe_video_buffer *tmpl);
|
||||
|
||||
/**
|
||||
* creates a video buffer from a handle
|
||||
*/
|
||||
struct pipe_video_buffer *
|
||||
d3d12_video_buffer_from_handle( struct pipe_context *pipe,
|
||||
const struct pipe_video_buffer *tmpl,
|
||||
struct winsys_handle *handle,
|
||||
unsigned usage);
|
||||
/**
|
||||
* destroy this video buffer
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "p_defines.h"
|
||||
#include "util/u_debug.h"
|
||||
#include <stdio.h>
|
||||
#include "frontend/winsys_handle.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -1192,6 +1193,15 @@ struct pipe_context {
|
||||
const struct pipe_video_buffer *templat,
|
||||
const uint64_t *modifiers,
|
||||
unsigned int modifiers_count);
|
||||
|
||||
/**
|
||||
* Creates a video buffer as decoding target, from external memory
|
||||
*/
|
||||
struct pipe_video_buffer *(*video_buffer_from_handle)( struct pipe_context *context,
|
||||
const struct pipe_video_buffer *templat,
|
||||
struct winsys_handle *handle,
|
||||
unsigned usage );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user