summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Rothenpieler <[email protected]>2025-09-09 20:08:22 +0200
committerTimo Rothenpieler <[email protected]>2025-09-17 14:50:41 +0000
commit00ddb408c53c39b8462931a06b28f56bd64bf8af (patch)
treef55786aa11b7410bf9d80bdd221b3cc1ce00b7de
parenta0936b9769718f13662812eb9ea4ae377916c6a8 (diff)
avfilter/vsrc_ddagrab: support rendering mouse cursor onto array textures
-rw-r--r--libavfilter/vsrc_ddagrab.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c
index 6533e2b66e..e035ac9bc4 100644
--- a/libavfilter/vsrc_ddagrab.c
+++ b/libavfilter/vsrc_ddagrab.c
@@ -818,6 +818,8 @@ static av_cold int init_hwframes_ctx(AVFilterContext *avctx)
dda->frames_ctx->format = AV_PIX_FMT_D3D11;
dda->frames_ctx->width = dda->width;
dda->frames_ctx->height = dda->height;
+ if (avctx->extra_hw_frames > 0)
+ dda->frames_ctx->initial_pool_size = 8 + avctx->extra_hw_frames;
switch (dda->raw_format) {
case DXGI_FORMAT_B8G8R8A8_UNORM:
@@ -936,7 +938,7 @@ static int draw_mouse_pointer(AVFilterContext *avctx, AVFrame *frame)
D3D11_RENDER_TARGET_VIEW_DESC target_desc = { 0 };
ID3D11RenderTargetView* target_view = NULL;
ID3D11Buffer *mouse_vertex_buffer = NULL;
- D3D11_TEXTURE2D_DESC tex_desc;
+ D3D11_TEXTURE2D_DESC tex_desc, frame_desc;
int num_vertices = 0;
int x, y;
HRESULT hr;
@@ -946,6 +948,7 @@ static int draw_mouse_pointer(AVFilterContext *avctx, AVFrame *frame)
return 0;
ID3D11Texture2D_GetDesc(dda->mouse_texture, &tex_desc);
+ ID3D11Texture2D_GetDesc(frame_tex, &frame_desc);
x = dda->mouse_x - dda->offset_x;
y = dda->mouse_y - dda->offset_y;
@@ -954,9 +957,17 @@ static int draw_mouse_pointer(AVFilterContext *avctx, AVFrame *frame)
-x >= (int)tex_desc.Width || -y >= (int)tex_desc.Height)
return 0;
- target_desc.Format = dda->raw_format;
- target_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
- target_desc.Texture2D.MipSlice = 0;
+ target_desc.Format = frame_desc.Format;
+
+ if (frame_desc.ArraySize > 1) {
+ target_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+ target_desc.Texture2DArray.ArraySize = 1;
+ target_desc.Texture2DArray.FirstArraySlice = (uintptr_t)frame->data[1];
+ target_desc.Texture2DArray.MipSlice = 0;
+ } else {
+ target_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
+ target_desc.Texture2D.MipSlice = 0;
+ }
hr = ID3D11Device_CreateRenderTargetView(dda->device_hwctx->device,
(ID3D11Resource*)frame_tex,