mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-20 13:50:11 +01:00
mesa: Remove NV_vdpau_interop
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36632>
This commit is contained in:
parent
272bde24a3
commit
e7ea1233b1
14 changed files with 3 additions and 905 deletions
|
|
@ -644,7 +644,6 @@ vdpau = get_option('gallium-vdpau') \
|
||||||
dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau)
|
dep_vdpau = dependency('vdpau', version : '>= 1.5', required : vdpau)
|
||||||
if dep_vdpau.found()
|
if dep_vdpau.found()
|
||||||
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
|
dep_vdpau = dep_vdpau.partial_dependency(compile_args : true)
|
||||||
pre_args += '-DHAVE_ST_VDPAU'
|
|
||||||
endif
|
endif
|
||||||
with_gallium_vdpau = dep_vdpau.found()
|
with_gallium_vdpau = dep_vdpau.found()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
|
|
||||||
|
|
||||||
<OpenGLAPI>
|
|
||||||
|
|
||||||
<category name="GL_NV_vdpau_interop" number="396">
|
|
||||||
|
|
||||||
<function name="VDPAUInitNV">
|
|
||||||
<param name="vdpDevice" type="const GLvoid *"/>
|
|
||||||
<param name="getProcAddress" type="const GLvoid *"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUFiniNV"/>
|
|
||||||
|
|
||||||
<function name="VDPAURegisterVideoSurfaceNV">
|
|
||||||
<return type="GLintptr"/>
|
|
||||||
<param name="vdpSurface" type="const GLvoid *"/>
|
|
||||||
<param name="target" type="GLenum"/>
|
|
||||||
<param name="numTextureNames" type="GLsizei"/>
|
|
||||||
<param name="textureNames" type="const GLuint *"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAURegisterOutputSurfaceNV">
|
|
||||||
<return type="GLintptr"/>
|
|
||||||
<param name="vdpSurface" type="const GLvoid *"/>
|
|
||||||
<param name="target" type="GLenum"/>
|
|
||||||
<param name="numTextureNames" type="GLsizei"/>
|
|
||||||
<param name="textureNames" type="const GLuint *"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUIsSurfaceNV">
|
|
||||||
<return type="GLboolean"/>
|
|
||||||
<param name="surface" type="GLintptr"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUUnregisterSurfaceNV">
|
|
||||||
<param name="surface" type="GLintptr"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUGetSurfaceivNV">
|
|
||||||
<param name="surface" type="GLintptr"/>
|
|
||||||
<param name="pname" type="GLenum"/>
|
|
||||||
<param name="bufSize" type="GLsizei"/>
|
|
||||||
<param name="length" type="GLsizei *"/>
|
|
||||||
<param name="values" type="GLint *"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUSurfaceAccessNV">
|
|
||||||
<param name="surface" type="GLintptr"/>
|
|
||||||
<param name="access" type="GLenum"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUMapSurfacesNV" marshal="sync">
|
|
||||||
<param name="numSurfaces" type="GLsizei"/>
|
|
||||||
<param name="surfaces" type="const GLintptr *" count="numSurfaces"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<function name="VDPAUUnmapSurfacesNV" marshal="sync">
|
|
||||||
<param name="numSurfaces" type="GLsizei"/>
|
|
||||||
<param name="surfaces" type="const GLintptr *" count="numSurfaces"/>
|
|
||||||
</function>
|
|
||||||
|
|
||||||
<enum name="SURFACE_STATE_NV" value="0x86EB"/>
|
|
||||||
<enum name="SURFACE_REGISTERED_NV" value="0x86FD"/>
|
|
||||||
<enum name="SURFACE_MAPPED_NV" value="0x8700"/>
|
|
||||||
<enum name="WRITE_DISCARD_NV" value="0x88BE"/>
|
|
||||||
|
|
||||||
</category>
|
|
||||||
|
|
||||||
</OpenGLAPI>
|
|
||||||
|
|
@ -11111,8 +11111,6 @@
|
||||||
|
|
||||||
<xi:include href="EXT_transform_feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
<xi:include href="EXT_transform_feedback.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||||
|
|
||||||
<xi:include href="NV_vdpau_interop.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
|
||||||
|
|
||||||
<xi:include href="EXT_external_objects.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
<xi:include href="EXT_external_objects.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||||
<xi:include href="EXT_external_objects_fd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
<xi:include href="EXT_external_objects_fd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||||
<xi:include href="EXT_external_objects_win32.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
<xi:include href="EXT_external_objects_win32.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||||
|
|
|
||||||
|
|
@ -1265,16 +1265,6 @@ all_functions = [
|
||||||
"GetPerfMonitorGroupsAMD",
|
"GetPerfMonitorGroupsAMD",
|
||||||
"SelectPerfMonitorCountersAMD",
|
"SelectPerfMonitorCountersAMD",
|
||||||
"TextureBarrierNV",
|
"TextureBarrierNV",
|
||||||
"VDPAUFiniNV",
|
|
||||||
"VDPAUGetSurfaceivNV",
|
|
||||||
"VDPAUInitNV",
|
|
||||||
"VDPAUIsSurfaceNV",
|
|
||||||
"VDPAUMapSurfacesNV",
|
|
||||||
"VDPAURegisterOutputSurfaceNV",
|
|
||||||
"VDPAURegisterVideoSurfaceNV",
|
|
||||||
"VDPAUSurfaceAccessNV",
|
|
||||||
"VDPAUUnmapSurfacesNV",
|
|
||||||
"VDPAUUnregisterSurfaceNV",
|
|
||||||
"BeginPerfQueryINTEL",
|
"BeginPerfQueryINTEL",
|
||||||
"CreatePerfQueryINTEL",
|
"CreatePerfQueryINTEL",
|
||||||
"DeletePerfQueryINTEL",
|
"DeletePerfQueryINTEL",
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,6 @@ glapi_xml_py_deps = files(
|
||||||
'glapi/gen/NV_conditional_render.xml',
|
'glapi/gen/NV_conditional_render.xml',
|
||||||
'glapi/gen/NV_primitive_restart.xml',
|
'glapi/gen/NV_primitive_restart.xml',
|
||||||
'glapi/gen/NV_texture_barrier.xml',
|
'glapi/gen/NV_texture_barrier.xml',
|
||||||
'glapi/gen/NV_vdpau_interop.xml',
|
|
||||||
'glapi/gen/NV_viewport_swizzle.xml',
|
'glapi/gen/NV_viewport_swizzle.xml',
|
||||||
'glapi/gen/OES_EGL_image.xml',
|
'glapi/gen/OES_EGL_image.xml',
|
||||||
'glapi/gen/OES_fixed_point.xml',
|
'glapi/gen/OES_fixed_point.xml',
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,6 @@ struct gl_extensions
|
||||||
GLboolean NV_texture_barrier;
|
GLboolean NV_texture_barrier;
|
||||||
GLboolean NV_texture_env_combine4;
|
GLboolean NV_texture_env_combine4;
|
||||||
GLboolean NV_texture_rectangle;
|
GLboolean NV_texture_rectangle;
|
||||||
GLboolean NV_vdpau_interop;
|
|
||||||
GLboolean NV_conservative_raster;
|
GLboolean NV_conservative_raster;
|
||||||
GLboolean NV_conservative_raster_dilate;
|
GLboolean NV_conservative_raster_dilate;
|
||||||
GLboolean NV_conservative_raster_pre_snap_triangles;
|
GLboolean NV_conservative_raster_pre_snap_triangles;
|
||||||
|
|
|
||||||
|
|
@ -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_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_texture_rectangle , NV_texture_rectangle , GLL, x , x , x , 2000)
|
||||||
EXT(NV_timeline_semaphore , NV_timeline_semaphore , GLL, GLC, x , 32, 2020)
|
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_array2 , NV_viewport_array2 , GLL, GLC, x , 31, 2015)
|
||||||
EXT(NV_viewport_swizzle , NV_viewport_swizzle , GLL, GLC, x , 31, 2015)
|
EXT(NV_viewport_swizzle , NV_viewport_swizzle , GLL, GLC, x , 31, 2015)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1050,9 +1050,8 @@ struct gl_texture_object
|
||||||
/* When non-negative, samplers should use this layer instead of the one
|
/* When non-negative, samplers should use this layer instead of the one
|
||||||
* specified by the GL state.
|
* specified by the GL state.
|
||||||
*
|
*
|
||||||
* This is used for EGL images and VDPAU interop, where imported
|
* This is used for EGL images interop, where imported pipe_resources
|
||||||
* pipe_resources may be cube, 3D, or array textures (containing layers
|
* may be cube, 3D, or array textures even though the GL state
|
||||||
* with different fields in the case of VDPAU) even though the GL state
|
|
||||||
* describes one non-array texture per field.
|
* describes one non-array texture per field.
|
||||||
*/
|
*/
|
||||||
int layer_override;
|
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?
|
* Has this context observed a GPU reset in any context in the share group?
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,6 @@
|
||||||
#include <mesa/state_tracker/st_shader_cache.h>
|
#include <mesa/state_tracker/st_shader_cache.h>
|
||||||
#include <mesa/state_tracker/st_texture.h>
|
#include <mesa/state_tracker/st_texture.h>
|
||||||
#include <mesa/state_tracker/st_util.h>
|
#include <mesa/state_tracker/st_util.h>
|
||||||
#include <mesa/state_tracker/st_vdpau.h>
|
|
||||||
#include <mesa/vbo/vbo.h>
|
#include <mesa/vbo/vbo.h>
|
||||||
#include <mesa/vbo/vbo_attrib.h>
|
#include <mesa/vbo/vbo_attrib.h>
|
||||||
#include <mesa/vbo/vbo_exec.h>
|
#include <mesa/vbo/vbo_exec.h>
|
||||||
|
|
|
||||||
|
|
@ -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 <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -242,7 +242,6 @@ files_libmesa = files(
|
||||||
'main/uniforms.h',
|
'main/uniforms.h',
|
||||||
'main/varray.c',
|
'main/varray.c',
|
||||||
'main/varray.h',
|
'main/varray.h',
|
||||||
'main/vdpau.c',
|
|
||||||
'main/version.c',
|
'main/version.c',
|
||||||
'main/version.h',
|
'main/version.h',
|
||||||
'main/viewport.c',
|
'main/viewport.c',
|
||||||
|
|
@ -368,8 +367,6 @@ files_libmesa = files(
|
||||||
'state_tracker/st_texture.c',
|
'state_tracker/st_texture.c',
|
||||||
'state_tracker/st_texture.h',
|
'state_tracker/st_texture.h',
|
||||||
'state_tracker/st_util.h',
|
'state_tracker/st_util.h',
|
||||||
'state_tracker/st_vdpau.c',
|
|
||||||
'state_tracker/st_vdpau.h',
|
|
||||||
'vbo/vbo.h',
|
'vbo/vbo.h',
|
||||||
'vbo/vbo_attrib.h',
|
'vbo/vbo_attrib.h',
|
||||||
'vbo/vbo_attrib_tmp.h',
|
'vbo/vbo_attrib_tmp.h',
|
||||||
|
|
@ -468,6 +465,6 @@ libmesa = static_library(
|
||||||
inc_libmesa_asm, include_directories('main'),
|
inc_libmesa_asm, include_directories('main'),
|
||||||
],
|
],
|
||||||
link_with : [libmesa_sse41],
|
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,
|
build_by_default : false,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1678,15 +1678,6 @@ void st_init_extensions(struct pipe_screen *screen,
|
||||||
extensions->ARB_ES3_compatibility = GL_TRUE;
|
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) {
|
if (screen->caps.doubles) {
|
||||||
extensions->ARB_gpu_shader_fp64 = GL_TRUE;
|
extensions->ARB_gpu_shader_fp64 = GL_TRUE;
|
||||||
extensions->ARB_vertex_attrib_64bit = GL_TRUE;
|
extensions->ARB_vertex_attrib_64bit = GL_TRUE;
|
||||||
|
|
|
||||||
|
|
@ -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 <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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
|
|
||||||
|
|
@ -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 <christian.koenig@amd.com>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#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 */
|
|
||||||
Loading…
Add table
Reference in a new issue