diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_draw.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_vdpau.c | 181 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_vdpau.h | 42 |
6 files changed, 237 insertions, 5 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 4e0d98cc3..2cc3567e0 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -65,6 +65,7 @@ #include "st_extensions.h" #include "st_gen_mipmap.h" #include "st_program.h" +#include "st_vdpau.h" #include "pipe/p_context.h" #include "util/u_inlines.h" #include "util/u_upload_mgr.h" @@ -360,5 +361,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_xformfb_functions(functions); st_init_syncobj_functions(functions); + st_init_vdpau_functions(functions); + functions->UpdateState = st_invalidate_state; } diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c index c35723087..51bb23807 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.c +++ b/mesalib/src/mesa/state_tracker/st_draw.c @@ -210,9 +210,6 @@ st_draw_vbo(struct gl_context *ctx, if (st->dirty.st || ctx->NewDriverState) { st_validate_state(st); - if (st->vertex_array_out_of_memory) - return; - #if 0 if (MESA_VERBOSE & VERBOSE_GLSL) { check_uniforms(ctx); @@ -222,6 +219,10 @@ st_draw_vbo(struct gl_context *ctx, #endif } + if (st->vertex_array_out_of_memory) { + return; + } + util_draw_init_info(&info); if (ib) { diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index 231bb395a..97c5d55e1 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -445,8 +445,7 @@ void st_init_extensions(struct st_context *st) { PIPE_FORMAT_Z32_FLOAT, PIPE_FORMAT_Z32_FLOAT_S8X24_UINT } }, - { { o(ARB_framebuffer_object), - o(EXT_packed_depth_stencil) }, + { { o(EXT_packed_depth_stencil) }, { PIPE_FORMAT_S8_UINT_Z24_UNORM, PIPE_FORMAT_Z24_UNORM_S8_UINT }, GL_TRUE }, /* at least one format must be supported */ @@ -565,6 +564,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.NV_fog_distance = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; ctx->Extensions.NV_texture_rectangle = GL_TRUE; + ctx->Extensions.NV_vdpau_interop = GL_TRUE; ctx->Extensions.OES_EGL_image = GL_TRUE; ctx->Extensions.OES_EGL_image_external = GL_TRUE; @@ -760,6 +760,10 @@ void st_init_extensions(struct st_context *st) PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW); } + if (screen->get_param(screen, PIPE_CAP_MIXED_FRAMEBUFFER_SIZES) && + ctx->Extensions.EXT_packed_depth_stencil) { + ctx->Extensions.ARB_framebuffer_object = GL_TRUE; + } /* Unpacking a varying in the fragment shader costs 1 texture indirection. * If the number of available texture indirections is very limited, then we diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 3e11cce24..0eaf7467b 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -993,6 +993,7 @@ type_size(const struct glsl_type *type) * at link time. */ return 1; + case GLSL_TYPE_ATOMIC_UINT: case GLSL_TYPE_INTERFACE: case GLSL_TYPE_VOID: case GLSL_TYPE_ERROR: diff --git a/mesalib/src/mesa/state_tracker/st_vdpau.c b/mesalib/src/mesa/state_tracker/st_vdpau.c new file mode 100644 index 000000000..9b165ee39 --- /dev/null +++ b/mesalib/src/mesa/state_tracker/st_vdpau.c @@ -0,0 +1,181 @@ +/************************************************************************** + * + * 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 "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 "state_tracker/vdpau_interop.h" + +#include "util/u_inlines.h" + +#include "st_vdpau.h" +#include "st_context.h" +#include "st_texture.h" +#include "st_format.h" + +static 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 GLvoid *vdpSurface, GLuint index) +{ + int (*getProcAddr)(uint32_t device, uint32_t id, void **ptr); + uint32_t device = (uintptr_t)ctx->vdpDevice; + + struct st_context *st = st_context(ctx); + struct st_texture_object *stObj = st_texture_object(texObj); + struct st_texture_image *stImage = st_texture_image(texImage); + + struct pipe_resource *res; + struct pipe_sampler_view *sv, templ; + gl_format texFormat; + + getProcAddr = ctx->vdpGetProcAddress; + if (output) { + VdpOutputSurfaceGallium *f; + + if (getProcAddr(device, VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM, (void**)&f)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + res = f((uintptr_t)vdpSurface); + + if (!res) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + } else { + VdpVideoSurfaceGallium *f; + + struct pipe_video_buffer *buffer; + struct pipe_sampler_view **samplers; + + if (getProcAddr(device, VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM, (void**)&f)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + buffer = f((uintptr_t)vdpSurface); + if (!buffer) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + samplers = buffer->get_sampler_view_planes(buffer); + if (!samplers) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + sv = samplers[index >> 1]; + if (!sv) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + res = sv->texture; + } + + if (!res) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + /* do we have different screen objects ? */ + if (res->screen != st->pipe->screen) { + _mesa_error(ctx, GL_INVALID_OPERATION, "VDPAUMapSurfacesNV"); + return; + } + + /* switch to surface based */ + if (!stObj->surface_based) { + _mesa_clear_texture_object(ctx, texObj); + stObj->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); + + pipe_resource_reference(&stObj->pt, res); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); + pipe_resource_reference(&stImage->pt, res); + + u_sampler_view_default_template(&templ, res, res->format); + templ.u.tex.first_layer = index & 1; + templ.u.tex.last_layer = index & 1; + templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0); + templ.swizzle_g = GET_SWZ(stObj->base._Swizzle, 1); + templ.swizzle_b = GET_SWZ(stObj->base._Swizzle, 2); + templ.swizzle_a = GET_SWZ(stObj->base._Swizzle, 3); + stObj->sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ); + + stObj->width0 = res->width0; + stObj->height0 = res->height0; + stObj->depth0 = 1; + stObj->surface_format = res->format; + + _mesa_dirty_texobj(ctx, texObj); +} + +static 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 GLvoid *vdpSurface, GLuint index) +{ + struct st_texture_object *stObj = st_texture_object(texObj); + struct st_texture_image *stImage = st_texture_image(texImage); + + pipe_resource_reference(&stObj->pt, NULL); + pipe_sampler_view_reference(&stObj->sampler_view, NULL); + pipe_resource_reference(&stImage->pt, NULL); + + _mesa_dirty_texobj(ctx, texObj); +} + +void +st_init_vdpau_functions(struct dd_function_table *functions) +{ + functions->VDPAUMapSurface = st_vdpau_map_surface; + functions->VDPAUUnmapSurface = st_vdpau_unmap_surface; +} diff --git a/mesalib/src/mesa/state_tracker/st_vdpau.h b/mesalib/src/mesa/state_tracker/st_vdpau.h new file mode 100644 index 000000000..59c744305 --- /dev/null +++ b/mesalib/src/mesa/state_tracker/st_vdpau.h @@ -0,0 +1,42 @@ +/************************************************************************** + * + * 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 + +struct dd_function_table; + +extern void +st_init_vdpau_functions(struct dd_function_table *functions); + +#endif /* ST_VDPAU_H */ |