diff --git a/meson.build b/meson.build index a7cb95314af..293ee16dae1 100644 --- a/meson.build +++ b/meson.build @@ -644,7 +644,6 @@ vdpau = get_option('gallium-vdpau') \ dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau) if dep_vdpau.found() dep_vdpau = dep_vdpau.partial_dependency(compile_args : true) - pre_args += '-DHAVE_ST_VDPAU' endif with_gallium_vdpau = dep_vdpau.found() diff --git a/src/mesa/glapi/glapi/gen/NV_vdpau_interop.xml b/src/mesa/glapi/glapi/gen/NV_vdpau_interop.xml deleted file mode 100644 index 1f53ac4a025..00000000000 --- a/src/mesa/glapi/glapi/gen/NV_vdpau_interop.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mesa/glapi/glapi/gen/gl_API.xml b/src/mesa/glapi/glapi/gen/gl_API.xml index 446f505991c..a592cfae909 100644 --- a/src/mesa/glapi/glapi/gen/gl_API.xml +++ b/src/mesa/glapi/glapi/gen/gl_API.xml @@ -11111,8 +11111,6 @@ - - diff --git a/src/mesa/glapi/glapi/gen/static_data.py b/src/mesa/glapi/glapi/gen/static_data.py index 0d128889870..1693e8f348e 100644 --- a/src/mesa/glapi/glapi/gen/static_data.py +++ b/src/mesa/glapi/glapi/gen/static_data.py @@ -1265,16 +1265,6 @@ all_functions = [ "GetPerfMonitorGroupsAMD", "SelectPerfMonitorCountersAMD", "TextureBarrierNV", - "VDPAUFiniNV", - "VDPAUGetSurfaceivNV", - "VDPAUInitNV", - "VDPAUIsSurfaceNV", - "VDPAUMapSurfacesNV", - "VDPAURegisterOutputSurfaceNV", - "VDPAURegisterVideoSurfaceNV", - "VDPAUSurfaceAccessNV", - "VDPAUUnmapSurfacesNV", - "VDPAUUnregisterSurfaceNV", "BeginPerfQueryINTEL", "CreatePerfQueryINTEL", "DeletePerfQueryINTEL", diff --git a/src/mesa/glapi/meson.build b/src/mesa/glapi/meson.build index 00cae4ebab9..cc938f5abd3 100644 --- a/src/mesa/glapi/meson.build +++ b/src/mesa/glapi/meson.build @@ -122,7 +122,6 @@ glapi_xml_py_deps = files( 'glapi/gen/NV_conditional_render.xml', 'glapi/gen/NV_primitive_restart.xml', 'glapi/gen/NV_texture_barrier.xml', - 'glapi/gen/NV_vdpau_interop.xml', 'glapi/gen/NV_viewport_swizzle.xml', 'glapi/gen/OES_EGL_image.xml', 'glapi/gen/OES_fixed_point.xml', diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h index 1988c668f3c..526078f9ce3 100644 --- a/src/mesa/main/consts_exts.h +++ b/src/mesa/main/consts_exts.h @@ -281,7 +281,6 @@ struct gl_extensions GLboolean NV_texture_barrier; GLboolean NV_texture_env_combine4; GLboolean NV_texture_rectangle; - GLboolean NV_vdpau_interop; GLboolean NV_conservative_raster; GLboolean NV_conservative_raster_dilate; GLboolean NV_conservative_raster_pre_snap_triangles; diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 585afa9b0c0..cc6244878e6 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -443,7 +443,6 @@ EXT(NV_texture_barrier , NV_texture_barrier EXT(NV_texture_env_combine4 , NV_texture_env_combine4 , GLL, x , x , x , 1999) EXT(NV_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2000) EXT(NV_timeline_semaphore , NV_timeline_semaphore , GLL, GLC, x , 32, 2020) -EXT(NV_vdpau_interop , NV_vdpau_interop , GLL, GLC, x , x , 2010) EXT(NV_viewport_array2 , NV_viewport_array2 , GLL, GLC, x , 31, 2015) EXT(NV_viewport_swizzle , NV_viewport_swizzle , GLL, GLC, x , 31, 2015) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index cf9c8cfd4b3..7214818f02e 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1050,9 +1050,8 @@ struct gl_texture_object /* When non-negative, samplers should use this layer instead of the one * specified by the GL state. * - * This is used for EGL images and VDPAU interop, where imported - * pipe_resources may be cube, 3D, or array textures (containing layers - * with different fields in the case of VDPAU) even though the GL state + * This is used for EGL images interop, where imported pipe_resources + * may be cube, 3D, or array textures even though the GL state * describes one non-array texture per field. */ int layer_override; @@ -3625,15 +3624,6 @@ struct gl_context /*@}*/ - /** - * \name NV_vdpau_interop - */ - /*@{*/ - const void *vdpDevice; - const void *vdpGetProcAddress; - struct set *vdpSurfaces; - /*@}*/ - /** * Has this context observed a GPU reset in any context in the share group? * diff --git a/src/mesa/main/tests/disable_windows_include.c b/src/mesa/main/tests/disable_windows_include.c index 3e67bd77b11..3f85d716881 100644 --- a/src/mesa/main/tests/disable_windows_include.c +++ b/src/mesa/main/tests/disable_windows_include.c @@ -178,7 +178,6 @@ #include #include #include -#include #include #include #include diff --git a/src/mesa/main/vdpau.c b/src/mesa/main/vdpau.c deleted file mode 100644 index a9d1e97fd31..00000000000 --- a/src/mesa/main/vdpau.c +++ /dev/null @@ -1,445 +0,0 @@ -/************************************************************************** - * - * Copyright 2013 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#include -#include "util/hash_table.h" -#include "util/set.h" -#include "util/u_memory.h" -#include "context.h" -#include "glformats.h" -#include "texobj.h" -#include "teximage.h" -#include "textureview.h" -#include "api_exec_decl.h" - -#include "state_tracker/st_cb_texture.h" -#include "state_tracker/st_vdpau.h" - -#define MAX_TEXTURES 4 - -struct vdp_surface -{ - GLenum target; - struct gl_texture_object *textures[MAX_TEXTURES]; - GLenum access, state; - GLboolean output; - const GLvoid *vdpSurface; -}; - -void GLAPIENTRY -_mesa_VDPAUInitNV(const GLvoid *vdpDevice, const GLvoid *getProcAddress) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!vdpDevice) { - _mesa_error(ctx, GL_INVALID_VALUE, "vdpDevice"); - return; - } - - if (!getProcAddress) { - _mesa_error(ctx, GL_INVALID_VALUE, "getProcAddress"); - return; - } - - if (ctx->vdpDevice || ctx->vdpGetProcAddress || ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUInitNV"); - return; - } - - ctx->vdpDevice = vdpDevice; - ctx->vdpGetProcAddress = getProcAddress; - ctx->vdpSurfaces = _mesa_set_create(NULL, _mesa_hash_pointer, - _mesa_key_pointer_equal); -} - -static void -unregister_surface(struct set_entry *entry) -{ - struct vdp_surface *surf = (struct vdp_surface *)entry->key; - GET_CURRENT_CONTEXT(ctx); - - if (surf->state == GL_SURFACE_MAPPED_NV) { - GLintptr surfaces[] = { (GLintptr)surf }; - _mesa_VDPAUUnmapSurfacesNV(1, surfaces); - } - - _mesa_set_remove(ctx->vdpSurfaces, entry); - FREE(surf); -} - -void GLAPIENTRY -_mesa_VDPAUFiniNV(void) -{ - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUFiniNV"); - return; - } - - _mesa_set_destroy(ctx->vdpSurfaces, unregister_surface); - - ctx->vdpDevice = 0; - ctx->vdpGetProcAddress = 0; - ctx->vdpSurfaces = NULL; -} - -static GLintptr -register_surface(struct gl_context *ctx, GLboolean isOutput, - const GLvoid *vdpSurface, GLenum target, - GLsizei numTextureNames, const GLuint *textureNames) -{ - struct vdp_surface *surf; - int i; - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAURegisterSurfaceNV"); - return (GLintptr)NULL; - } - - if (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE) { - _mesa_error(ctx, GL_INVALID_ENUM, "VDPAURegisterSurfaceNV"); - return (GLintptr)NULL; - } - - if (target == GL_TEXTURE_RECTANGLE && !ctx->Extensions.NV_texture_rectangle) { - _mesa_error(ctx, GL_INVALID_ENUM, "VDPAURegisterSurfaceNV"); - return (GLintptr)NULL; - } - - surf = CALLOC_STRUCT( vdp_surface ); - if (surf == NULL) { - _mesa_error_no_memory("VDPAURegisterSurfaceNV"); - return (GLintptr)NULL; - } - - surf->vdpSurface = vdpSurface; - surf->target = target; - surf->access = GL_READ_WRITE; - surf->state = GL_SURFACE_REGISTERED_NV; - surf->output = isOutput; - for (i = 0; i < numTextureNames; ++i) { - struct gl_texture_object *tex; - - tex = _mesa_lookup_texture_err(ctx, textureNames[i], - "VDPAURegisterSurfaceNV"); - if (tex == NULL) { - free(surf); - return (GLintptr)NULL; - } - - _mesa_lock_texture(ctx, tex); - - if (tex->Immutable) { - _mesa_unlock_texture(ctx, tex); - free(surf); - _mesa_error(ctx, GL_INVALID_OPERATION, - "VDPAURegisterSurfaceNV(texture is immutable)"); - return (GLintptr)NULL; - } - - if (tex->Target == 0) { - tex->Target = target; - tex->TargetIndex = _mesa_tex_target_to_index(ctx, target); - } else if (tex->Target != target) { - _mesa_unlock_texture(ctx, tex); - free(surf); - _mesa_error(ctx, GL_INVALID_OPERATION, - "VDPAURegisterSurfaceNV(target mismatch)"); - return (GLintptr)NULL; - } - - /* This will disallow respecifying the storage. */ - _mesa_set_texture_view_state(ctx, tex, target, 1); - _mesa_unlock_texture(ctx, tex); - - _mesa_reference_texobj(&surf->textures[i], tex); - } - - _mesa_set_add(ctx->vdpSurfaces, surf); - - return (GLintptr)surf; -} - -GLintptr GLAPIENTRY -_mesa_VDPAURegisterVideoSurfaceNV(const GLvoid *vdpSurface, GLenum target, - GLsizei numTextureNames, - const GLuint *textureNames) -{ - GET_CURRENT_CONTEXT(ctx); - - if (numTextureNames != 4) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAURegisterVideoSurfaceNV"); - return (GLintptr)NULL; - } - - return register_surface(ctx, false, vdpSurface, target, - numTextureNames, textureNames); -} - -GLintptr GLAPIENTRY -_mesa_VDPAURegisterOutputSurfaceNV(const GLvoid *vdpSurface, GLenum target, - GLsizei numTextureNames, - const GLuint *textureNames) -{ - GET_CURRENT_CONTEXT(ctx); - - if (numTextureNames != 1) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAURegisterVideoSurfaceNV"); - return (GLintptr)NULL; - } - - return register_surface(ctx, true, vdpSurface, target, - numTextureNames, textureNames); -} - -GLboolean GLAPIENTRY -_mesa_VDPAUIsSurfaceNV(GLintptr surface) -{ - struct vdp_surface *surf = (struct vdp_surface *)surface; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUIsSurfaceNV"); - return false; - } - - if (!_mesa_set_search(ctx->vdpSurfaces, surf)) { - return false; - } - - return true; -} - -void GLAPIENTRY -_mesa_VDPAUUnregisterSurfaceNV(GLintptr surface) -{ - struct vdp_surface *surf = (struct vdp_surface *)surface; - struct set_entry *entry; - int i; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUUnregisterSurfaceNV"); - return; - } - - /* according to the spec it's ok when this is zero */ - if (surface == 0) - return; - - entry = _mesa_set_search(ctx->vdpSurfaces, surf); - if (!entry) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUUnregisterSurfaceNV"); - return; - } - - for (i = 0; i < MAX_TEXTURES; i++) { - if (surf->textures[i]) { - surf->textures[i]->Immutable = GL_FALSE; - _mesa_reference_texobj(&surf->textures[i], NULL); - } - } - - _mesa_set_remove(ctx->vdpSurfaces, entry); - free(surf); -} - -void GLAPIENTRY -_mesa_VDPAUGetSurfaceivNV(GLintptr surface, GLenum pname, GLsizei bufSize, - GLsizei *length, GLint *values) -{ - struct vdp_surface *surf = (struct vdp_surface *)surface; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUGetSurfaceivNV"); - return; - } - - if (!_mesa_set_search(ctx->vdpSurfaces, surf)) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUGetSurfaceivNV"); - return; - } - - if (pname != GL_SURFACE_STATE_NV) { - _mesa_error(ctx, GL_INVALID_ENUM, "VDPAUGetSurfaceivNV"); - return; - } - - if (bufSize < 1) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUGetSurfaceivNV"); - return; - } - - values[0] = surf->state; - - if (length != NULL) - *length = 1; -} - -void GLAPIENTRY -_mesa_VDPAUSurfaceAccessNV(GLintptr surface, GLenum access) -{ - struct vdp_surface *surf = (struct vdp_surface *)surface; - GET_CURRENT_CONTEXT(ctx); - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUSurfaceAccessNV"); - return; - } - - if (!_mesa_set_search(ctx->vdpSurfaces, surf)) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV"); - return; - } - - if (access != GL_READ_ONLY && access != GL_WRITE_ONLY && - access != GL_READ_WRITE) { - - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV"); - return; - } - - if (surf->state == GL_SURFACE_MAPPED_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUSurfaceAccessNV"); - return; - } - - surf->access = access; -} - -void GLAPIENTRY -_mesa_VDPAUMapSurfacesNV(GLsizei numSurfaces, const GLintptr *surfaces) -{ - GET_CURRENT_CONTEXT(ctx); - int i; - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUUnmapSurfacesNV"); - return; - } - - for (i = 0; i < numSurfaces; ++i) { - struct vdp_surface *surf = (struct vdp_surface *)surfaces[i]; - - if (!_mesa_set_search(ctx->vdpSurfaces, surf)) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV"); - return; - } - - if (surf->state == GL_SURFACE_MAPPED_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUSurfaceAccessNV"); - return; - } - } - - for (i = 0; i < numSurfaces; ++i) { - struct vdp_surface *surf = (struct vdp_surface *)surfaces[i]; - unsigned numTextureNames = surf->output ? 1 : 4; - unsigned j; - - for (j = 0; j < numTextureNames; ++j) { - struct gl_texture_object *tex = surf->textures[j]; - struct gl_texture_image *image; - - _mesa_lock_texture(ctx, tex); - image = _mesa_get_tex_image(ctx, tex, surf->target, 0); - if (!image) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "VDPAUMapSurfacesNV"); - _mesa_unlock_texture(ctx, tex); - return; - } - - st_FreeTextureImageBuffer(ctx, image); - - st_vdpau_map_surface(ctx, surf->target, surf->access, - surf->output, tex, image, - surf->vdpSurface, j); - - _mesa_unlock_texture(ctx, tex); - } - surf->state = GL_SURFACE_MAPPED_NV; - } -} - -void GLAPIENTRY -_mesa_VDPAUUnmapSurfacesNV(GLsizei numSurfaces, const GLintptr *surfaces) -{ - GET_CURRENT_CONTEXT(ctx); - int i; - - if (!ctx->vdpDevice || !ctx->vdpGetProcAddress || !ctx->vdpSurfaces) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUUnmapSurfacesNV"); - return; - } - - for (i = 0; i < numSurfaces; ++i) { - struct vdp_surface *surf = (struct vdp_surface *)surfaces[i]; - - if (!_mesa_set_search(ctx->vdpSurfaces, surf)) { - _mesa_error(ctx, GL_INVALID_VALUE, "VDPAUSurfaceAccessNV"); - return; - } - - if (surf->state != GL_SURFACE_MAPPED_NV) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUSurfaceAccessNV"); - return; - } - } - - for (i = 0; i < numSurfaces; ++i) { - struct vdp_surface *surf = (struct vdp_surface *)surfaces[i]; - unsigned numTextureNames = surf->output ? 1 : 4; - unsigned j; - - for (j = 0; j < numTextureNames; ++j) { - struct gl_texture_object *tex = surf->textures[j]; - struct gl_texture_image *image; - - _mesa_lock_texture(ctx, tex); - - image = _mesa_select_tex_image(tex, surf->target, 0); - - st_vdpau_unmap_surface(ctx, surf->target, surf->access, - surf->output, tex, image, - surf->vdpSurface, j); - - if (image) - st_FreeTextureImageBuffer(ctx, image); - - _mesa_unlock_texture(ctx, tex); - } - surf->state = GL_SURFACE_REGISTERED_NV; - } -} diff --git a/src/mesa/meson.build b/src/mesa/meson.build index 263d9cde00f..962cf5a27fd 100644 --- a/src/mesa/meson.build +++ b/src/mesa/meson.build @@ -242,7 +242,6 @@ files_libmesa = files( 'main/uniforms.h', 'main/varray.c', 'main/varray.h', - 'main/vdpau.c', 'main/version.c', 'main/version.h', 'main/viewport.c', @@ -368,8 +367,6 @@ files_libmesa = files( 'state_tracker/st_texture.c', 'state_tracker/st_texture.h', 'state_tracker/st_util.h', - 'state_tracker/st_vdpau.c', - 'state_tracker/st_vdpau.h', 'vbo/vbo.h', 'vbo/vbo_attrib.h', 'vbo/vbo_attrib_tmp.h', @@ -468,6 +465,6 @@ libmesa = static_library( inc_libmesa_asm, include_directories('main'), ], link_with : [libmesa_sse41], - dependencies : [idep_libglsl, idep_nir, idep_vtn, dep_vdpau, idep_mesautil], + dependencies : [idep_libglsl, idep_nir, idep_vtn, idep_mesautil], build_by_default : false, ) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 565730f4c8b..02f9d4c523c 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1678,15 +1678,6 @@ void st_init_extensions(struct pipe_screen *screen, extensions->ARB_ES3_compatibility = GL_TRUE; } -#ifdef HAVE_ST_VDPAU - if (screen->get_video_param && - screen->get_video_param(screen, PIPE_VIDEO_PROFILE_UNKNOWN, - PIPE_VIDEO_ENTRYPOINT_BITSTREAM, - PIPE_VIDEO_CAP_SUPPORTS_INTERLACED)) { - extensions->NV_vdpau_interop = GL_TRUE; - } -#endif - if (screen->caps.doubles) { extensions->ARB_gpu_shader_fp64 = GL_TRUE; extensions->ARB_vertex_attrib_64bit = GL_TRUE; diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c deleted file mode 100644 index 25ddf209775..00000000000 --- a/src/mesa/state_tracker/st_vdpau.c +++ /dev/null @@ -1,285 +0,0 @@ -/************************************************************************** - * - * Copyright 2013 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#ifdef HAVE_ST_VDPAU - -#include "main/texobj.h" -#include "main/teximage.h" -#include "main/errors.h" -#include "program/prog_instruction.h" - -#include "pipe/p_state.h" -#include "pipe/p_video_codec.h" - -#include "util/u_inlines.h" - -#include "st_vdpau.h" -#include "st_context.h" -#include "st_sampler_view.h" -#include "st_texture.h" -#include "st_format.h" -#include "st_cb_flush.h" - -#include "frontend/vdpau_interop.h" -#include "frontend/vdpau_dmabuf.h" -#include "frontend/vdpau_funcs.h" -#include "frontend/drm_driver.h" - -#include "drm-uapi/drm_fourcc.h" - -static struct pipe_resource * -st_vdpau_video_surface_gallium(struct gl_context *ctx, const void *vdpSurface, - GLuint index) -{ - int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr); - uint32_t device = (uintptr_t)ctx->vdpDevice; - struct pipe_sampler_view *sv; - VdpVideoSurfaceGallium *f; - - struct pipe_video_buffer *buffer; - struct pipe_sampler_view **samplers; - struct pipe_resource *res = NULL; - - getProcAddr = (void *)ctx->vdpGetProcAddress; - if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM, (void**)&f)) - return NULL; - - buffer = f((uintptr_t)vdpSurface); - if (!buffer) - return NULL; - - samplers = buffer->get_sampler_view_planes(buffer); - if (!samplers) - return NULL; - - sv = samplers[index >> 1]; - if (!sv) - return NULL; - - pipe_resource_reference(&res, sv->texture); - return res; -} - -static struct pipe_resource * -st_vdpau_output_surface_gallium(struct gl_context *ctx, const void *vdpSurface) -{ - int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr); - uint32_t device = (uintptr_t)ctx->vdpDevice; - struct pipe_resource *res = NULL; - VdpOutputSurfaceGallium *f; - - getProcAddr = (void *)ctx->vdpGetProcAddress; - if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM, (void**)&f)) - return NULL; - - pipe_resource_reference(&res, f((uintptr_t)vdpSurface)); - return res; -} - -static struct pipe_resource * -st_vdpau_resource_from_description(struct gl_context *ctx, - const struct VdpSurfaceDMABufDesc *desc) -{ - struct st_context *st = st_context(ctx); - struct pipe_resource templ, *res; - struct winsys_handle whandle; - - if (desc->handle == -1) - return NULL; - - memset(&templ, 0, sizeof(templ)); - templ.target = PIPE_TEXTURE_2D; - templ.last_level = 0; - templ.depth0 = 1; - templ.array_size = 1; - templ.width0 = desc->width; - templ.height0 = desc->height; - templ.format = VdpFormatRGBAToPipe(desc->format); - templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; - templ.usage = PIPE_USAGE_DEFAULT; - - memset(&whandle, 0, sizeof(whandle)); - whandle.type = WINSYS_HANDLE_TYPE_FD; - whandle.handle = desc->handle; - whandle.modifier = DRM_FORMAT_MOD_INVALID; - whandle.offset = desc->offset; - whandle.stride = desc->stride; - whandle.format = VdpFormatRGBAToPipe(desc->format); - - res = st->screen->resource_from_handle(st->screen, &templ, &whandle, - PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE); - close(desc->handle); - - return res; -} - -static struct pipe_resource * -st_vdpau_output_surface_dma_buf(struct gl_context *ctx, const void *vdpSurface) -{ - int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr); - uint32_t device = (uintptr_t)ctx->vdpDevice; - - struct VdpSurfaceDMABufDesc desc; - VdpOutputSurfaceDMABuf *f; - - getProcAddr = (void *)ctx->vdpGetProcAddress; - if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF, (void**)&f)) - return NULL; - - if (f((uintptr_t)vdpSurface, &desc) != VDP_STATUS_OK) - return NULL; - - return st_vdpau_resource_from_description(ctx, &desc); -} - -static struct pipe_resource * -st_vdpau_video_surface_dma_buf(struct gl_context *ctx, const void *vdpSurface, - GLuint index) -{ - int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr); - uint32_t device = (uintptr_t)ctx->vdpDevice; - - struct VdpSurfaceDMABufDesc desc; - VdpVideoSurfaceDMABuf *f; - - getProcAddr = (void *)ctx->vdpGetProcAddress; - if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF, (void**)&f)) - return NULL; - - if (f((uintptr_t)vdpSurface, index, &desc) != VDP_STATUS_OK) - return NULL; - - return st_vdpau_resource_from_description(ctx, &desc); -} - -void -st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index) -{ - struct st_context *st = st_context(ctx); - struct pipe_screen *screen = st->screen; - - struct pipe_resource *res; - mesa_format texFormat; - int layer_override = -1; - - if (output) { - res = st_vdpau_output_surface_dma_buf(ctx, vdpSurface); - - if (!res) - res = st_vdpau_output_surface_gallium(ctx, vdpSurface); - - } else { - res = st_vdpau_video_surface_dma_buf(ctx, vdpSurface, index); - - if (!res) { - res = st_vdpau_video_surface_gallium(ctx, vdpSurface, index); - layer_override = index & 1; - } - } - - /* If the resource is from a different screen, try re-importing it */ - if (res && res->screen != screen) { - struct pipe_resource *new_res = NULL; - struct winsys_handle whandle = { .type = WINSYS_HANDLE_TYPE_FD }; - unsigned usage = PIPE_HANDLE_USAGE_FRAMEBUFFER_WRITE; - - if (screen->caps.dmabuf && - res->screen->caps.dmabuf && - res->screen->resource_get_handle(res->screen, NULL, res, &whandle, - usage)) { - whandle.modifier = DRM_FORMAT_MOD_INVALID; - new_res = screen->resource_from_handle(screen, res, &whandle, usage); - close(whandle.handle); - } - - pipe_resource_reference(&res, NULL); - res = new_res; - } - - if (!res) { - _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); - return; - } - - /* switch to surface based */ - if (!texObj->surface_based) { - _mesa_clear_texture_object(ctx, texObj, NULL); - texObj->surface_based = GL_TRUE; - } - - texFormat = st_pipe_format_to_mesa_format(res->format); - - _mesa_init_teximage_fields(ctx, texImage, - res->width0, res->height0, 1, 0, GL_RGBA, - texFormat); - _mesa_update_texture_object_swizzle(ctx, texObj); - - pipe_resource_reference(&texObj->pt, res); - st_texture_release_all_sampler_views(st, texObj); - pipe_resource_reference(&texImage->pt, res); - - texObj->surface_format = res->format; - texObj->level_override = -1; - texObj->layer_override = layer_override; - - _mesa_dirty_texobj(ctx, texObj); - pipe_resource_reference(&res, NULL); -} - -void -st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index) -{ - struct st_context *st = st_context(ctx); - - pipe_resource_reference(&texObj->pt, NULL); - st_texture_release_all_sampler_views(st, texObj); - pipe_resource_reference(&texImage->pt, NULL); - - texObj->level_override = -1; - texObj->layer_override = -1; - - _mesa_dirty_texobj(ctx, texObj); - - /* NV_vdpau_interop does not specify an explicit synchronization mechanism - * between the GL and VDPAU contexts. Provide automatic synchronization here. - */ - st_flush(st, NULL, 0); -} - -#endif diff --git a/src/mesa/state_tracker/st_vdpau.h b/src/mesa/state_tracker/st_vdpau.h deleted file mode 100644 index 6bc11fcec29..00000000000 --- a/src/mesa/state_tracker/st_vdpau.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** - * - * Copyright 2013 Advanced Micro Devices, Inc. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* - * Authors: - * Christian König - * - */ - -#ifndef ST_VDPAU_H -#define ST_VDPAU_H - -#ifdef HAVE_ST_VDPAU - -void -st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index); -void -st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index); -#else - -static inline void -st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index) {} -static inline void -st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, - GLboolean output, struct gl_texture_object *texObj, - struct gl_texture_image *texImage, - const void *vdpSurface, GLuint index) {} -#endif - -#endif /* ST_VDPAU_H */