From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4B08F40C38 for ; Wed, 9 Mar 2022 07:21:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5311768AED6; Wed, 9 Mar 2022 09:21:05 +0200 (EET) Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F30BC68A774 for ; Wed, 9 Mar 2022 09:20:58 +0200 (EET) Received: by mail-yb1-f173.google.com with SMTP id e186so2491185ybc.7 for ; Tue, 08 Mar 2022 23:20:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=kmqXxytHps9ewZKG6Cw7brReAP5AOKTkwn+2+bngoys=; b=D0PkEMAavK55n1LdS1q0wW90EJnDghW1z11WdHFc6DGsYoFi0PuPNHAqvxrKKFFm4Y V9H1v4zj6Bo9HimbrvUb5eYk9aCYmnkVM+h12uy/8h8Y8Y3U6hSFdB7+p7c3phGNaPcU WazWA+hcK0ZAzGgdP1DXpniYYMm5Eh6ya7vePZJwcQvpFNpNRgUyBCGKltBNnRb+nI+l ououlfreP9aSKGQa3t2iA5RXeQd3O6lMxy9OD7+IvAeFa6vGQhl9stDhSVi2zUbcoe57 PZQfZ1IgWLtRjZCEAcEV6FcEy2zMtnQ7vDQXSdCdk9iV5DJmo5feC9AsvIU/3/dMICTr NAng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=kmqXxytHps9ewZKG6Cw7brReAP5AOKTkwn+2+bngoys=; b=qv7Y0nUfVZG2BavGfYRQ909+vroXkcMAFhD7ygg3hP1XOiEEwZk4jCbC66zsRUMHUs m2tQIvSAxz+fPjbd1oxgXsDD2S53HZR+wghH6CkaoLafHg907PpsdYRQN+MvK6uLqx5/ capcKWn4Ng3UPr5+jhCVuiUz9Vqsx1xz1qgTLrEglTwqpKQh7lQA2XAjeXpnImrdZf8z 8k7N9cLhi/rgPAhZS0ybaqOu88LqQcIMFOoCHDQ2GrQ1D1PrX+TQ6P8WZHD12Nvi3Y49 iMvCsQPX4bqi5ljRWI1Z+kS2ZBYLc2eWqTPuZszVIKn+ZHSWEUzzIGIY+TVB53gUXZu+ ChYA== X-Gm-Message-State: AOAM530bczxqB8E4Pz08BzQuiGqlGaFQqkidDZQ4LpUnupQo8rIJYMus 2vz+Kj5zDL+YcHekB1JNQwDVVcpLFiGxVo1ZFMecOYX8S7M= X-Google-Smtp-Source: ABdhPJxFK4HTF7V1xL5pl7gcJJApaxRSBpqSxKizAjnQvSm+hKybOSwpCK57JwAIOPjHyYc9vvCE+iiWt9AQ7SKBuTk= X-Received: by 2002:a05:6902:108:b0:621:165e:5c1e with SMTP id o8-20020a056902010800b00621165e5c1emr14517374ybh.204.1646810457146; Tue, 08 Mar 2022 23:20:57 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Hendrik Leppkes Date: Wed, 9 Mar 2022 08:20:46 +0100 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] d3d11va: let user can create SRV from output X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Wed, Mar 9, 2022 at 7:56 AM Wang Chuan wrote: > > Starting from Windows 8, users can create SRV from video resource > and bind it to shaders directly. This can avoid unnecessary memcpy > (ID3D11DeviceContext::CopyResource, etc), so create texture with > [D3D11_BIND_SHADER_RESOURCE] as decoder's output if possible. > > Signed-off-by: Wang Chuan > --- > libavcodec/dxva2.c | 2 +- > libavutil/hwcontext_d3d11va.c | 10 ++++++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c > index 568d686f39..15b25d793c 100644 > --- a/libavcodec/dxva2.c > +++ b/libavcodec/dxva2.c > @@ -645,7 +645,7 @@ int ff_dxva2_common_frame_params(AVCodecContext *avctx, > if (frames_ctx->format == AV_PIX_FMT_D3D11) { > AVD3D11VAFramesContext *frames_hwctx = frames_ctx->hwctx; > - frames_hwctx->BindFlags |= D3D11_BIND_DECODER; > + frames_hwctx->BindFlags |= (D3D11_BIND_DECODER | > D3D11_BIND_SHADER_RESOURCE); > } > #endif > diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c > index 8ab96bad25..97ffd745bd 100644 > --- a/libavutil/hwcontext_d3d11va.c > +++ b/libavutil/hwcontext_d3d11va.c > @@ -203,6 +203,11 @@ static AVBufferRef > *d3d11va_alloc_single(AVHWFramesContext *ctx) > }; > hr = ID3D11Device_CreateTexture2D(device_hwctx->device, &texDesc, > NULL, &tex); > + if (FAILED(hr) && (texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE)) { > + av_log(ctx, AV_LOG_ERROR, "Could not create the texture with > [D3D11_BIND_SHADER_RESOURCE] flag"); > + texDesc.BindFlags &= ~D3D11_BIND_SHADER_RESOURCE; > + hr = ID3D11Device_CreateTexture2D(device_hwctx->device, > &texDesc, NULL, &tex); > + } > if (FAILED(hr)) { > av_log(ctx, AV_LOG_ERROR, "Could not create the texture > (%lx)\n", (long)hr); > return NULL; > @@ -278,6 +283,11 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx) > } > } else if (!(texDesc.BindFlags & D3D11_BIND_RENDER_TARGET) && > texDesc.ArraySize > 0) { > hr = ID3D11Device_CreateTexture2D(device_hwctx->device, > &texDesc, NULL, &hwctx->texture); > + if (FAILED(hr) && (texDesc.BindFlags & > D3D11_BIND_SHADER_RESOURCE)) { > + av_log(ctx, AV_LOG_ERROR, "Could not create the texture > with [D3D11_BIND_SHADER_RESOURCE] flag"); > + texDesc.BindFlags &= ~D3D11_BIND_SHADER_RESOURCE; > + hr = ID3D11Device_CreateTexture2D(device_hwctx->device, > &texDesc, NULL, &hwctx->texture); > + } I really don't like these fallbacks. If a caller requests a certain set of flags, it should fullfill these, or fail, and not change them. Especially special-casing this one flag just makes it extra iffy, and I know why you added it, but that doesn't help. IMHO, its also not entirely unreasonable that if you require anything but the default flags, to let the user just manage their own frames context, the effort required is not that high and there is never a set of flags you can set that'll cover every use case (for example, I use surface sharing, thats not set by default either). - Hendrik _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".