X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Fstate_tracker%2Fst_cb_eglimage.c;h=8531afb29a741b3bfbe27aa446bbdbe842be75ce;hb=52f748792393c681f35025be7d843e6426fa327d;hp=3c4fe32090ba65738a0a6d1e7555443a6410995b;hpb=1318848f782cce716d6376ca13aebf68b728e24c;p=mesa.git diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index 3c4fe32090b..8531afb29a7 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.9 * * Copyright (C) 2010 LunarG Inc. * @@ -27,18 +26,16 @@ */ #include "main/texobj.h" -#include "main/texfetch.h" #include "main/teximage.h" #include "util/u_inlines.h" #include "util/u_format.h" #include "st_cb_eglimage.h" #include "st_cb_fbo.h" +#include "st_context.h" #include "st_texture.h" #include "st_format.h" #include "st_manager.h" -#if FEATURE_OES_EGL_image - /** * Return the base format just like _mesa_base_fbo_format does. */ @@ -52,7 +49,7 @@ st_pipe_format_to_base_format(enum pipe_format format) base_format = GL_DEPTH_STENCIL; } else { - if (format == PIPE_FORMAT_S8_USCALED) + if (format == PIPE_FORMAT_S8_UINT) base_format = GL_STENCIL_INDEX; else base_format = GL_DEPTH_COMPONENT; @@ -70,22 +67,19 @@ st_pipe_format_to_base_format(enum pipe_format format) } static void -st_egl_image_target_renderbuffer_storage(GLcontext *ctx, +st_egl_image_target_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct st_renderbuffer *strb = st_renderbuffer(rb); struct pipe_surface *ps; - unsigned usage; - usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION; - ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); + ps = st_manager_get_egl_image_surface(st, (void *) image_handle); if (ps) { strb->Base.Width = ps->width; strb->Base.Height = ps->height; strb->Base.Format = st_pipe_format_to_mesa_format(ps->format); - strb->Base.DataType = st_format_datatype(ps->format); strb->Base._BaseFormat = st_pipe_format_to_base_format(ps->format); strb->Base.InternalFormat = strb->Base._BaseFormat; @@ -97,14 +91,16 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx, } static void -st_bind_surface(GLcontext *ctx, GLenum target, +st_bind_surface(struct gl_context *ctx, GLenum target, struct gl_texture_object *texObj, struct gl_texture_image *texImage, struct pipe_surface *ps) { + struct st_context *st = st_context(ctx); struct st_texture_object *stObj; struct st_texture_image *stImage; GLenum internalFormat; + mesa_format texFormat; /* map pipe format to base format */ if (util_format_get_component_bits(ps->format, UTIL_FORMAT_COLORSPACE_RGB, 3) > 0) @@ -121,30 +117,35 @@ st_bind_surface(GLcontext *ctx, GLenum target, stObj->surface_based = GL_TRUE; } - _mesa_init_teximage_fields(ctx, target, texImage, - ps->width, ps->height, 1, 0, internalFormat); - texImage->TexFormat = st_pipe_format_to_mesa_format(ps->format); - _mesa_set_fetch_functions(texImage, 2); + texFormat = st_pipe_format_to_mesa_format(ps->format); + + _mesa_init_teximage_fields(ctx, texImage, + ps->width, ps->height, 1, 0, internalFormat, + texFormat); - stObj->pipe = ctx->st->pipe; /* FIXME create a non-default sampler view from the pipe_surface? */ - pipe_resource_reference(&stImage->pt, ps->texture); + pipe_resource_reference(&stObj->pt, ps->texture); + st_texture_release_all_sampler_views(st, stObj); + pipe_resource_reference(&stImage->pt, stObj->pt); - _mesa_dirty_texobj(ctx, texObj, GL_TRUE); + stObj->width0 = ps->width; + stObj->height0 = ps->height; + stObj->depth0 = 1; + stObj->surface_format = ps->format; + + _mesa_dirty_texobj(ctx, texObj); } static void -st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target, +st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target, struct gl_texture_object *texObj, struct gl_texture_image *texImage, GLeglImageOES image_handle) { - struct st_context *st = ctx->st; + struct st_context *st = st_context(ctx); struct pipe_surface *ps; - unsigned usage; - usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE; - ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage); + ps = st_manager_get_egl_image_surface(st, (void *) image_handle); if (ps) { st_bind_surface(ctx, target, texObj, texImage, ps); pipe_surface_reference(&ps, NULL); @@ -157,5 +158,3 @@ st_init_eglimage_functions(struct dd_function_table *functions) functions->EGLImageTargetTexture2D = st_egl_image_target_texture_2d; functions->EGLImageTargetRenderbufferStorage = st_egl_image_target_renderbuffer_storage; } - -#endif /* FEATURE_OES_EGL_image */