1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-03 21:42:18 +00:00

vo_gpu/d3d11: add helper function to get ra_format from DXGI_FORMAT

This commit is contained in:
Jan Ekström 2022-04-04 23:15:00 +03:00
parent 26a3a06861
commit b5b5098d48
2 changed files with 16 additions and 0 deletions

View File

@ -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

View File

@ -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,