mirror of
https://github.com/mpv-player/mpv
synced 2024-12-25 00:02:13 +00:00
d3d: merge angle_common.h into d3d.h
OK, this was dumb. The file didn't have much to do with ANGLE, and the functionality can simply be moved to d3d.c. That file contains helpers for decoding, but can always be present (on Windows) since it doesn't access any D3D specific libavcodec APIs. Thus it doesn't need to be conditionally built like the actual hwaccel wrappers.
This commit is contained in:
parent
d5615102d5
commit
17c5738cb4
@ -266,3 +266,15 @@ void copy_nv12(struct mp_image *dest, uint8_t *src_bits,
|
||||
buf.stride[1] = src_pitch;
|
||||
mp_image_copy_gpu(dest, &buf);
|
||||
}
|
||||
|
||||
// Test if Direct3D11 can be used by us. Basically, this prevents trying to use
|
||||
// D3D11 on Win7, and then failing somewhere in the process.
|
||||
bool d3d11_check_decoding(ID3D11Device *dev)
|
||||
{
|
||||
HRESULT hr;
|
||||
// We assume that NV12 is always supported, if hw decoding is supported at
|
||||
// all.
|
||||
UINT supported = 0;
|
||||
hr = ID3D11Device_CheckFormatSupport(dev, DXGI_FORMAT_NV12, &supported);
|
||||
return !FAILED(hr) && (supported & D3D11_BIND_DECODER);
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
#define MPV_DECODE_D3D_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d11.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
struct mp_image;
|
||||
@ -62,4 +65,6 @@ BOOL is_clearvideo(const GUID *mode_guid);
|
||||
void copy_nv12(struct mp_image *dest, uint8_t *src_bits,
|
||||
unsigned src_pitch, unsigned surf_height);
|
||||
|
||||
bool d3d11_check_decoding(ID3D11Device *dev);
|
||||
|
||||
#endif
|
||||
|
@ -1,13 +0,0 @@
|
||||
#include "angle_common.h"
|
||||
|
||||
// Test if Direct3D11 can be used by us. Basically, this prevents trying to use
|
||||
// D3D11 on Win7, and then failing somewhere in the process.
|
||||
bool d3d11_check_decoding(ID3D11Device *dev)
|
||||
{
|
||||
HRESULT hr;
|
||||
// We assume that NV12 is always supported, if hw decoding is supported at
|
||||
// all.
|
||||
UINT supported = 0;
|
||||
hr = ID3D11Device_CheckFormatSupport(dev, DXGI_FORMAT_NV12, &supported);
|
||||
return !FAILED(hr) && (supported & D3D11_BIND_DECODER);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
#ifndef MP_ANGLE_COMMON_H
|
||||
#define MP_ANGLE_COMMON_H
|
||||
|
||||
#include <initguid.h>
|
||||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <d3d11.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
bool d3d11_check_decoding(ID3D11Device *dev);
|
||||
|
||||
#endif
|
@ -23,7 +23,6 @@
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include "angle_common.h"
|
||||
#include "angle_dynamic.h"
|
||||
|
||||
#include "common/common.h"
|
||||
@ -31,6 +30,7 @@
|
||||
#include "osdep/windows_utils.h"
|
||||
#include "hwdec.h"
|
||||
#include "video/hwdec.h"
|
||||
#include "video/decode/d3d.h"
|
||||
|
||||
#ifndef EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE
|
||||
#define EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x3AAB
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include "angle_common.h"
|
||||
#include "angle_dynamic.h"
|
||||
|
||||
#include "common/common.h"
|
||||
@ -31,6 +30,7 @@
|
||||
#include "osdep/windows_utils.h"
|
||||
#include "hwdec.h"
|
||||
#include "video/hwdec.h"
|
||||
#include "video/decode/d3d.h"
|
||||
|
||||
#ifndef EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE
|
||||
#define EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE 0x3AAB
|
||||
@ -87,6 +87,8 @@ static int create(struct gl_hwdec *hw)
|
||||
if (!angle_load())
|
||||
return -1;
|
||||
|
||||
d3d_load_dlls();
|
||||
|
||||
EGLDisplay egl_display = eglGetCurrentDisplay();
|
||||
if (!egl_display)
|
||||
return -1;
|
||||
@ -104,7 +106,6 @@ static int create(struct gl_hwdec *hw)
|
||||
|
||||
p->egl_display = egl_display;
|
||||
|
||||
HANDLE d3d11_dll = GetModuleHandleW(L"d3d11.dll");
|
||||
if (!d3d11_dll) {
|
||||
if (!hw->probing)
|
||||
MP_ERR(hw, "Failed to load D3D11 library\n");
|
||||
|
@ -29,11 +29,11 @@
|
||||
#include "osdep/windows_utils.h"
|
||||
#include "hwdec.h"
|
||||
#include "video/hwdec.h"
|
||||
#include "video/decode/d3d.h"
|
||||
|
||||
struct priv {
|
||||
struct mp_hwdec_ctx hwctx;
|
||||
|
||||
HMODULE d3d9_dll;
|
||||
IDirect3D9Ex *d3d9ex;
|
||||
IDirect3DDevice9Ex *device9ex;
|
||||
IDirect3DQuery9 *query9;
|
||||
@ -89,9 +89,6 @@ static void destroy(struct gl_hwdec *hw)
|
||||
|
||||
if (p->d3d9ex)
|
||||
IDirect3D9Ex_Release(p->d3d9ex);
|
||||
|
||||
if (p->d3d9_dll)
|
||||
FreeLibrary(p->d3d9_dll);
|
||||
}
|
||||
|
||||
static int create(struct gl_hwdec *hw)
|
||||
@ -99,6 +96,8 @@ static int create(struct gl_hwdec *hw)
|
||||
if (!angle_load())
|
||||
return -1;
|
||||
|
||||
d3d_load_dlls();
|
||||
|
||||
EGLDisplay egl_display = eglGetCurrentDisplay();
|
||||
if (!egl_display)
|
||||
return -1;
|
||||
@ -118,15 +117,14 @@ static int create(struct gl_hwdec *hw)
|
||||
|
||||
p->egl_display = egl_display;
|
||||
|
||||
p->d3d9_dll = LoadLibraryW(L"d3d9.dll");
|
||||
if (!p->d3d9_dll) {
|
||||
if (!d3d9_dll) {
|
||||
MP_FATAL(hw, "Failed to load \"d3d9.dll\": %s\n",
|
||||
mp_LastError_to_str());
|
||||
goto fail;
|
||||
}
|
||||
|
||||
HRESULT (WINAPI *Direct3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
|
||||
Direct3DCreate9Ex = (void *)GetProcAddress(p->d3d9_dll, "Direct3DCreate9Ex");
|
||||
Direct3DCreate9Ex = (void *)GetProcAddress(d3d9_dll, "Direct3DCreate9Ex");
|
||||
if (!Direct3DCreate9Ex) {
|
||||
MP_FATAL(hw, "Direct3D 9Ex not supported\n");
|
||||
goto fail;
|
||||
|
@ -288,7 +288,7 @@ def build(ctx):
|
||||
( "video/decode/dec_video.c"),
|
||||
( "video/decode/dxva2.c", "d3d-hwaccel" ),
|
||||
( "video/decode/d3d11va.c", "d3d-hwaccel" ),
|
||||
( "video/decode/d3d.c", "d3d-hwaccel" ),
|
||||
( "video/decode/d3d.c", "win32" ),
|
||||
( "video/decode/vaapi.c", "vaapi-hwaccel" ),
|
||||
( "video/decode/vd_lavc.c" ),
|
||||
( "video/decode/videotoolbox.c", "videotoolbox-hwaccel" ),
|
||||
@ -327,7 +327,6 @@ def build(ctx):
|
||||
( "video/out/dither.c" ),
|
||||
( "video/out/filter_kernels.c" ),
|
||||
( "video/out/opengl/angle_dynamic.c", "egl-angle" ),
|
||||
( "video/out/opengl/angle_common.c", "egl-angle" ),
|
||||
( "video/out/opengl/common.c", "gl" ),
|
||||
( "video/out/opengl/context.c", "gl" ),
|
||||
( "video/out/opengl/context_angle.c", "egl-angle" ),
|
||||
|
Loading…
Reference in New Issue
Block a user