summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2022-04-04 23:15:00 +0300
committerJan Ekström <jeebjp@gmail.com>2022-04-11 17:56:02 +0300
commitb5b5098d48f664d0141fab7e10e7177fecec9607 (patch)
treecf6efffb910f6349b5a7c221d005093c5b25b048 /video/out
parent26a3a0686179627de6c9bffd45ae4c15a0b37771 (diff)
downloadmpv-b5b5098d48f664d0141fab7e10e7177fecec9607.tar.bz2
mpv-b5b5098d48f664d0141fab7e10e7177fecec9607.tar.xz
vo_gpu/d3d11: add helper function to get ra_format from DXGI_FORMAT
Diffstat (limited to 'video/out')
-rw-r--r--video/out/d3d11/ra_d3d11.c12
-rw-r--r--video/out/d3d11/ra_d3d11.h4
2 files changed, 16 insertions, 0 deletions
diff --git a/video/out/d3d11/ra_d3d11.c b/video/out/d3d11/ra_d3d11.c
index ebf3ab9fba..44f0fbdcf3 100644
--- a/video/out/d3d11/ra_d3d11.c
+++ b/video/out/d3d11/ra_d3d11.c
@@ -202,6 +202,18 @@ DXGI_FORMAT ra_d3d11_get_format(const struct ra_format *fmt)
return d3d->fmt;
}
+const struct ra_format *ra_d3d11_get_ra_format(struct ra *ra, DXGI_FORMAT fmt)
+{
+ for (int i = 0; i < ra->num_formats; i++) {
+ struct ra_format *ra_fmt = ra->formats[i];
+
+ if (ra_d3d11_get_format(ra_fmt) == fmt)
+ return ra_fmt;
+ }
+
+ return NULL;
+}
+
static void setup_formats(struct ra *ra)
{
// All formats must be usable as a 2D texture
diff --git a/video/out/d3d11/ra_d3d11.h b/video/out/d3d11/ra_d3d11.h
index f9cada132c..6f62a7f23f 100644
--- a/video/out/d3d11/ra_d3d11.h
+++ b/video/out/d3d11/ra_d3d11.h
@@ -11,6 +11,10 @@
// Get the underlying DXGI format from an RA format
DXGI_FORMAT ra_d3d11_get_format(const struct ra_format *fmt);
+// Gets the matching ra_format for a given DXGI format.
+// Returns a nullptr in case of no known match.
+const struct ra_format *ra_d3d11_get_ra_format(struct ra *ra, DXGI_FORMAT fmt);
+
// Create an RA instance from a D3D11 device. This takes a reference to the
// device, which is released when the RA instance is destroyed.
struct ra *ra_d3d11_create(ID3D11Device *device, struct mp_log *log,