diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2016-06-25 02:25:44 +0200 |
---|---|---|
committer | Martin Herkt <lachs0r@srsfckn.biz> | 2016-06-25 02:25:44 +0200 |
commit | ad56f2c46ac6deec86870ec10f2a11a644df07d4 (patch) | |
tree | 89f2d90c5586560911e67c872b530c77f151168d /video/out/opengl/hwdec_dxva2gldx.c | |
parent | 0536841647ef7931bffb4386d8ffbb5b2b568e8a (diff) | |
parent | 393bb2a565dc1e27812e1dd20747814892f80da2 (diff) | |
download | mpv-ad56f2c46ac6deec86870ec10f2a11a644df07d4.tar.bz2 mpv-ad56f2c46ac6deec86870ec10f2a11a644df07d4.tar.xz |
Merge branch 'master' into release/current
Diffstat (limited to 'video/out/opengl/hwdec_dxva2gldx.c')
-rw-r--r-- | video/out/opengl/hwdec_dxva2gldx.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/video/out/opengl/hwdec_dxva2gldx.c b/video/out/opengl/hwdec_dxva2gldx.c index 69be0ccd18..4cd8c1c0b2 100644 --- a/video/out/opengl/hwdec_dxva2gldx.c +++ b/video/out/opengl/hwdec_dxva2gldx.c @@ -15,14 +15,13 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ +#include <d3d9.h> #include <assert.h> #include "common/common.h" #include "osdep/windows_utils.h" #include "hwdec.h" #include "video/hwdec.h" -#include "video/d3d.h" -#include "video/dxva2.h" // for WGL_ACCESS_READ_ONLY_NV #include <GL/wglext.h> @@ -30,7 +29,7 @@ #define SHARED_SURFACE_D3DFMT D3DFMT_X8R8G8B8 #define SHARED_SURFACE_MPFMT IMGFMT_RGB0 struct priv { - struct mp_d3d_ctx ctx; + struct mp_hwdec_ctx hwctx; IDirect3DDevice9Ex *device; HANDLE device_h; @@ -74,6 +73,8 @@ static void destroy(struct gl_hwdec *hw) struct priv *p = hw->priv; destroy_objects(hw); + hwdec_devices_remove(hw->devs, &p->hwctx); + if (p->device) IDirect3DDevice9Ex_Release(p->device); } @@ -81,10 +82,8 @@ static void destroy(struct gl_hwdec *hw) static int create(struct gl_hwdec *hw) { GL *gl = hw->gl; - if (hw->hwctx || !gl->MPGetNativeDisplay || - !(gl->mpgl_caps & MPGL_CAP_DXINTEROP)) { + if (!gl->MPGetNativeDisplay || !(gl->mpgl_caps & MPGL_CAP_DXINTEROP)) return -1; - } struct priv *p = talloc_zero(hw, struct priv); hw->priv = p; @@ -100,13 +99,13 @@ static int create(struct gl_hwdec *hw) if (!p->device) return -1; IDirect3DDevice9Ex_AddRef(p->device); - p->ctx.d3d9_device = (IDirect3DDevice9 *)p->device; - - p->ctx.hwctx.type = HWDEC_DXVA2; - p->ctx.hwctx.d3d_ctx = &p->ctx; - hw->hwctx = &p->ctx.hwctx; - hw->converted_imgfmt = SHARED_SURFACE_MPFMT; + p->hwctx = (struct mp_hwdec_ctx){ + .type = HWDEC_DXVA2, + .driver_name = hw->driver->name, + .ctx = (IDirect3DDevice9 *)p->device, + }; + hwdec_devices_add(hw->devs, &p->hwctx); return 0; } @@ -118,8 +117,6 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) destroy_objects(hw); - assert(params->imgfmt == hw->driver->imgfmt); - HANDLE share_handle = NULL; hr = IDirect3DDevice9Ex_CreateRenderTarget( p->device, @@ -162,14 +159,16 @@ static int reinit(struct gl_hwdec *hw, struct mp_image_params *params) goto fail; } + params->imgfmt = SHARED_SURFACE_MPFMT; + return 0; fail: destroy_objects(hw); return -1; } -static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, - GLuint *out_textures) +static int map_frame(struct gl_hwdec *hw, struct mp_image *hw_image, + struct gl_hwdec_frame *out_frame) { assert(hw_image && hw_image->imgfmt == hw->driver->imgfmt); GL *gl = hw->gl; @@ -182,7 +181,7 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, return -1; } - IDirect3DSurface9* hw_surface = d3d9_surface_in_mp_image(hw_image); + IDirect3DSurface9* hw_surface = (IDirect3DSurface9 *)hw_image->planes[3]; RECT rc = {0, 0, hw_image->w, hw_image->h}; hr = IDirect3DDevice9Ex_StretchRect(p->device, hw_surface, &rc, @@ -199,7 +198,16 @@ static int map_image(struct gl_hwdec *hw, struct mp_image *hw_image, return -1; } - out_textures[0] = p->texture; + *out_frame = (struct gl_hwdec_frame){ + .planes = { + { + .gl_texture = p->texture, + .gl_target = GL_TEXTURE_2D, + .tex_w = hw_image->w, + .tex_h = hw_image->h, + }, + }, + }; return 0; } @@ -209,6 +217,6 @@ const struct gl_hwdec_driver gl_hwdec_dxva2gldx = { .imgfmt = IMGFMT_DXVA2, .create = create, .reinit = reinit, - .map_image = map_image, + .map_frame = map_frame, .destroy = destroy, }; |