Re: [Mesa-dev] [PATCH mesa 4/7] Add the EGL_MESA_configless_context extension
This commit results in garbage output for r600g when building with OpenGL (not ES) as enabled by my patches: https://github.com/Zoxc/weston/commits/gl-rebase. (--enable-opengl on configure) It works on i965 so I was wondering how well tested this is on Gallium drivers? On Fri, Mar 7, 2014 at 7:05 PM, Neil Roberts wrote: > This extension provides a way for an application to render to multiple > surfaces with different buffer formats without having to use multiple > contexts. An EGLContext can be created without an EGLConfig by passing > EGL_NO_CONFIG_MESA. In that case there are no restrictions on the surfaces > that can be used with the context apart from that they must be using the same > EGLDisplay. > > _mesa_initialze_context can now take a NULL gl_config which will mark the > context as ‘configless’. It will memset the visual to zero in that case. > Previously the i965 and i915 drivers were explicitly creating a zeroed visual > whenever 0 is passed for the EGLConfig. Mesa needs to be aware that the > context is configless because it affects the initial value to use for > glDrawBuffer. The first time the context is bound it will set the initial > value for configless contexts depending on whether the framebuffer used is > double-buffered. > --- > docs/specs/MESA_configless_context.spec | 120 > ++ > include/EGL/eglext.h | 5 ++ > src/egl/drivers/dri2/egl_dri2.c | 1 + > src/egl/main/eglapi.c | 2 +- > src/egl/main/eglcontext.c | 20 - > src/egl/main/egldisplay.h | 1 + > src/egl/main/eglmisc.c| 1 + > src/mesa/drivers/dri/i915/intel_context.c | 6 -- > src/mesa/drivers/dri/i965/brw_context.c | 6 -- > src/mesa/main/context.c | 82 +++- > src/mesa/main/mtypes.h| 6 ++ > 11 files changed, 213 insertions(+), 37 deletions(-) > create mode 100644 docs/specs/MESA_configless_context.spec > > diff --git a/docs/specs/MESA_configless_context.spec > b/docs/specs/MESA_configless_context.spec > new file mode 100644 > index 000..8bed90d > --- /dev/null > +++ b/docs/specs/MESA_configless_context.spec > @@ -0,0 +1,120 @@ > +Name > + > +MESA_configless_context > + > +Name Strings > + > +EGL_MESA_configless_context > + > +Contact > + > +Neil Roberts > + > +Status > + > +Proposal > + > +Version > + > +Version 1, February 28, 2014 > + > +Number > + > +EGL Extension #not assigned > + > +Dependencies > + > +Requires EGL 1.4 or later. This extension is written against the > +wording of the EGL 1.4 specification. > + > +Overview > + > +This extension provides a means to use a single context to render to > +multiple surfaces which have different EGLConfigs. Without this extension > +the EGLConfig for every surface used by the context must be compatible > +with the one used by the context. The only way to render to surfaces with > +different formats would be to create multiple contexts but this is > +inefficient with modern GPUs where this restriction is unnecessary. > + > +IP Status > + > +Open-source; freely implementable. > + > +New Procedures and Functions > + > +None. > + > +New Tokens > + > +Accepted as in eglCreateContext > + > +EGL_NO_CONFIG_MESA ((EGLConfig)0) > + > +Additions to the EGL Specification section "2.2 Rendering Contexts and > Drawing > +Surfaces" > + > +Add the following to the 3rd paragraph: > + > + "EGLContexts can also optionally be created with respect to an EGLConfig > +depending on the parameters used at creation time. If a config is > provided > +then additional restrictions apply on what surfaces can be used with the > +context." > + > +Replace the last sentence of the 6th paragraph with: > + > + "In order for a context to be compatible with a surface they both must > have > +been created with respect to the same EGLDisplay. If the context was > +created without respect to an EGLConfig then there are no further > +constraints. Otherwise they are only compatible if:" > + > +Remove the last bullet point in the list of constraints. > + > +Additions to the EGL Specification section "3.7.1 Creating Rendering > Contexts" > + > +Replace the paragraph starting "If config is not a valid EGLConfig..." > +with > + > + "The config argument can either be a valid EGLConfig or > EGL_NO_CONFIG_MESA. > +If it is neither of these then an EGL_BAD_CONFIG error is generated. If a > +valid config is passed then the error will also be generated if the > config > +does not support the requested client API (this includes requesting > +creation of an OpenGL ES 1.x context when the EGL_RENDERABLE_TYPE > +attribute of config does not contain EGL_OPENGL_ES_BIT, or creation of an > +OpenGL ES 2.x context when the attribute does not contai
Re: [Mesa-dev] [PATCH v3 1/5] Add MESA_image_sRGB spec.
I don't have commit access and would like to see this series merged. On Sat, Apr 26, 2014 at 4:25 PM, John Kåre Alsaker wrote: > --- > docs/specs/MESA_image_sRGB.spec | 155 > > 1 file changed, 155 insertions(+) > create mode 100644 docs/specs/MESA_image_sRGB.spec > > diff --git a/docs/specs/MESA_image_sRGB.spec b/docs/specs/MESA_image_sRGB.spec > new file mode 100644 > index 000..7b29e7e > --- /dev/null > +++ b/docs/specs/MESA_image_sRGB.spec > @@ -0,0 +1,155 @@ > +Name > + > +MESA_image_sRGB > + > +Name Strings > + > +EGL_MESA_image_sRGB > + > +Contact > + > +John Kåre Alsaker > + > +Status > + > +Complete > + > +Version > + > +Version 3, March 3, 2013 > + > +Number > + > +EGL Extension #not assigned > + > +Dependencies > + > +EGL 1.2 or later is required. > + > +EGL_KHR_image_base is required. > + > +This extension is written against the wording of the EGL 1.2 > +specification. > + > +Overview > + > +This extension provides a way for applications to allocate sRGB > +or linear gamma views for EGLImage sources. This means that > +sampling from the resulting EGLImage should convert from sRGB's > +gamma into linear gamma. > + > +IP Status > + > +Open-source; freely implementable. > + > +New Tokens > + > +Accepted in the parameter of eglCreateImageKHR: > + > +EGL_GAMMA_MESA 0x3290 > + > +Accepted as values for the EGL_GAMMA_MESA attribute: > + > +EGL_DEFAULT_MESA 0x3291 > + > +Error states: > + > +EGL_BAD_VIEW_MESA 0x3292 > + > +Additions to the EGL 1.2 Specification: > + > +Add to section 2.5.1 "EGLImage Specification" (as defined by the > +EGL_KHR_image_base specification), in the description of > +eglCreateImageKHR: > + > + "Attributes names accepted in are shown in Table bbb > + > + ++-+--+ > + | Attribute | Description | Default Value| > + ++-+--+ > + | EGL_GAMMA_MESA | Specifies the gamma | EGL_DEFAULT_MESA | > + || view of the | | > + || EGLImage created. | | > + ++-+--+ > + Table bbb. Legal attributes for eglCreateImageKHR > +parameter > + > +... > + > +If the value of attribute EGL_GAMMA_MESA is EGL_DEFAULT_MESA (the > +default), then the gamma view of the resulting EGLImage will be > +the same as the EGLImage source. > + > +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_LINEAR, > +then the gamma view of the resulting EGLImage will be linear > +and no gamma conversions will be done when sampling the image > +in client APIs. > + > +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_sRGB, > +then the gamma view of the resulting EGLImage will be an sRGB > +view and the red, green and blue color components will be > +converted from sRGB gamma to linear gamma when sampling the image > +in client APIs. This conversion should ideally take place before > +any filtering, but that is not required. The conversion from an > +sRGB gamma component, cs, to a linear gamma component, cl, is as > +follows. > + > +{ cs / 12.92, cs <= 0.04045 > + cl = { > +{ ((cs + 0.055)/1.055)^2.4, cs > 0.04045 > + > +Assume cs is the sRGB gamma component in the range [0,1]." > + > +Add to the list of error conditions for eglCreateImageKHR: > + > + "* If the value specified in for EGL_GAMMA_MESA > + is not EGL_DEFAULT_MESA, and the implementation does not > + support creating the specified gamma view, the error > + EGL_BAD_VIEW_MESA is generated. > + > + * If the value specified in for EGL_GAMMA_MESA > + is EGL_COLORSPACE_sRGB, and the EGLImage source does not have > + red, green and blue color components, the error > + EGL_BAD_VIEW_MESA is generated." > + > +Conformance Tests > + > +1. Test that specifying EGL_DEFAULT_MESA as EGL_GAMMA_MESA does > + not affect the creation of EGL images. > + > +2. Test that specifying an non-gamma EGL attribute as EGL_GAMMA_MESA > + results in the error EGL_BAD_VIEW_MESA being generated. >
[Mesa-dev] [PATCH v3 3/5] gallium: Implement DRIimageExtension.duplicateImage
--- src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/common/dri_screen.c | 1 + src/gallium/state_trackers/dri/common/dri_screen.h | 1 + src/gallium/state_trackers/dri/drm/dri2.c | 42 -- src/mesa/state_tracker/st_manager.c| 4 +++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 9dcb76f..28ac9aa 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -203,6 +203,7 @@ struct st_egl_image { /* this is owned by the caller */ struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index 7a6dcb2..996d150 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -326,6 +326,7 @@ dri_get_egl_image(struct st_manager *smapi, stimg->texture = NULL; pipe_resource_reference(&stimg->texture, img->texture); + stimg->format = img->format; stimg->level = img->level; stimg->layer = img->layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 7c8e582..cc09d18 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -89,6 +89,7 @@ dri_screen(__DRIscreen * sPriv) struct __DRIimageRec { struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; uint32_t dri_format; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 4f2a87e..fedeba5 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -817,6 +817,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate) img->level = image->level; img->layer = image->layer; img->dri_format = image->dri_format; + img->format = image->format; /* This should be 0 for sub images, but dup is also used for base images. */ img->dri_components = image->dri_components; img->loader_private = loaderPrivate; @@ -1025,6 +1026,41 @@ dri2_from_dma_bufs(__DRIscreen *screen, img->dri_components = dri_components; *error = __DRI_IMAGE_ERROR_SUCCESS; + + return img; +} + +static __DRIimage * +dri2_duplicate_image(__DRIscreen *_screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate) +{ + enum pipe_format format; + struct dri_screen *screen = dri_screen(_screen); + __DRIimage *img = NULL; + + if ((flags & __DRI_IMAGE_FLAG_SRGB_VIEW) && (flags & __DRI_IMAGE_FLAG_LINEAR_VIEW)) + return NULL; + + if (flags & (__DRI_IMAGE_FLAG_SRGB_VIEW | __DRI_IMAGE_FLAG_LINEAR_VIEW)) { + if (!image->texture) + return NULL; + + if (flags & __DRI_IMAGE_FLAG_SRGB_VIEW) + format = util_format_srgb(image->texture->format); + else + format = util_format_linear(image->texture->format); + + if (!screen->base.screen->is_format_supported(screen->base.screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) + return NULL; + + img = dri2_dup_image(image, loaderPrivate); + + if (img) + img->format = format; + } else if (flags == 0) { + img = dri2_dup_image(image, loaderPrivate); + } + return img; } @@ -1036,7 +1072,7 @@ dri2_destroy_image(__DRIimage *img) } static struct __DRIimageExtensionRec dri2ImageExtension = { -{ __DRI_IMAGE, 6 }, +{ __DRI_IMAGE, 9 }, dri2_create_image_from_name, dri2_create_image_from_renderbuffer, dri2_destroy_image, @@ -1047,6 +1083,9 @@ static struct __DRIimageExtensionRec dri2ImageExtension = { dri2_from_names, dri2_from_planar, dri2_create_from_texture, +NULL, +NULL, +dri2_duplicate_image, }; /* @@ -1102,7 +1141,6 @@ dri2_init_screen(__DRIscreen * sPriv) if (drmGetCap(sPriv->fd, DRM_CAP_PRIME, &cap) == 0 && (cap & DRM_PRIME_CAP_IMPORT)) { - dri2ImageExtension.base.version = 8; dri2ImageExtension.createImageFromFds = dri2_from_fds; dri2ImageExtension.createImageFromDmaBufs = dri2_from_dma_bufs; } diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 314d342..5708e90 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -835,6 +835,10 @@ st_manager_get_egl_image_surface(struct st_context *st, void *eglimg) return NULL; u_surface_default_template(&surf_tmpl, stimg.texture); + + if (stimg.format != PIPE_FORMAT_NONE) + surf_tmpl.format = stimg.format; + surf_tmpl.u.tex.level = stimg.level; surf_tmpl.u.tex.first_layer = stimg.la
[Mesa-dev] [PATCH v3 4/5] i965: Implement DRIimageExtension.duplicateImage
--- src/mesa/drivers/dri/i965/intel_screen.c | 46 ++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 8cb1260..bfa93c6 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -591,6 +591,47 @@ intel_dup_image(__DRIimage *orig_image, void *loaderPrivate) return image; } +static __DRIimage * +intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate); + +static __DRIimage * +intel_duplicate_image(__DRIscreen *_screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate) +{ + __DRIimage *img; + + if ((flags & __DRI_IMAGE_FLAG_SRGB_VIEW) && (flags & __DRI_IMAGE_FLAG_LINEAR_VIEW)) + return NULL; + + if (flags & (__DRI_IMAGE_FLAG_SRGB_VIEW | __DRI_IMAGE_FLAG_LINEAR_VIEW)) { + + if (image->dri_format != __DRI_IMAGE_FORMAT_SARGB8 && image->dri_format != __DRI_IMAGE_FORMAT_ARGB) + return NULL; + + if (image->planar_format) + img = intel_from_planar(image, 0, loaderPrivate); + else + img = intel_dup_image(image, loaderPrivate); + + if (!img) + return NULL; + + if (flags & __DRI_IMAGE_FLAG_SRGB_VIEW) + img->dri_format = __DRI_IMAGE_FORMAT_SARGB8; + else + img->dri_format = __DRI_IMAGE_FORMAT_ARGB; + + img->format = driImageFormatToGLFormat(img->dri_format); + img->internal_format = _mesa_get_format_base_format(image->format); + + return img; + } else if (flags == 0) { + return intel_dup_image(image, loaderPrivate); + } else { + return NULL; + } +} + static GLboolean intel_validate_usage(__DRIimage *image, unsigned int use) { @@ -797,7 +838,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate) } static struct __DRIimageExtensionRec intelImageExtension = { -.base = { __DRI_IMAGE, 8 }, +.base = { __DRI_IMAGE, 9 }, .createImageFromName= intel_create_image_from_name, .createImageFromRenderbuffer= intel_create_image_from_renderbuffer, @@ -810,7 +851,8 @@ static struct __DRIimageExtensionRec intelImageExtension = { .fromPlanar = intel_from_planar, .createImageFromTexture = intel_create_image_from_texture, .createImageFromFds = intel_create_image_from_fds, -.createImageFromDmaBufs = intel_create_image_from_dma_bufs +.createImageFromDmaBufs = intel_create_image_from_dma_bufs, +.duplicateImage = intel_duplicate_image }; static int -- 1.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 2/5] dri: Add another duplicateImage to DRIimageExtension
duplicateImage will allow you to create a linear or sRGB view into a DRIimage you have access to. This is useful because compositors may want a specific view which doesn't correspond to the one used by applications. --- include/GL/internal/dri_interface.h | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index d028d05..17af117 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1005,7 +1005,7 @@ struct __DRIdri2ExtensionRec { * extensions. */ #define __DRI_IMAGE "DRI_IMAGE" -#define __DRI_IMAGE_VERSION 8 +#define __DRI_IMAGE_VERSION 9 /** * These formats correspond to the similarly named MESA_FORMAT_* @@ -1081,6 +1081,15 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 +/** + * Flags for duplicateImage. + * + * \since 9 + */ + +#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001 +#define __DRI_IMAGE_FLAG_LINEAR_VIEW 0x0002 + /** * queryImage attributes @@ -1239,6 +1248,15 @@ struct __DRIimageExtensionRec { enum __DRIChromaSiting vert_siting, unsigned *error, void *loaderPrivate); + + /** +* The new __DRIimage will share the raw content with the old one, +* but it might have a different format. +* +* \since 9 +*/ +__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate); }; -- 1.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v3 5/5] egl: Add MESA_image_sRGB extension.
This gives applications access to use DRIimage.duplicateImage to create sRGB and linear views from EGL images. --- include/EGL/eglmesaext.h| 7 ++ src/egl/drivers/dri2/egl_dri2.c | 201 +++- src/egl/drivers/dri2/egl_dri2.h | 11 +- src/egl/drivers/dri2/platform_android.c | 36 +++--- src/egl/drivers/dri2/platform_drm.c | 36 +++--- src/egl/drivers/dri2/platform_wayland.c | 2 +- src/egl/drivers/dri2/platform_x11.c | 37 +++--- src/egl/main/eglcurrent.c | 3 + src/egl/main/egldisplay.h | 1 + src/egl/main/eglimage.c | 6 + src/egl/main/eglimage.h | 3 + src/egl/main/eglmisc.c | 1 + 12 files changed, 192 insertions(+), 152 deletions(-) diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h index 5fcc527..740f676 100644 --- a/include/EGL/eglmesaext.h +++ b/include/EGL/eglmesaext.h @@ -109,6 +109,13 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd); #endif #endif +#ifndef EGL_MESA_image_sRGB +#define EGL_MESA_image_sRGB 1 +#define EGL_GAMMA_MESA 0x3290 /* eglCreateImageKHR attribute */ +#define EGL_DEFAULT_MESA 0x3291 +#define EGL_BAD_VIEW_MESA 0x3292 +#endif + #ifndef EGL_WL_bind_wayland_display #define EGL_WL_bind_wayland_display 1 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index a132964..5b421ac 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -529,6 +529,10 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE; disp->Extensions.KHR_gl_texture_cubemap_image = EGL_TRUE; } + if (dri2_dpy->image->base.version >= 9 && + dri2_dpy->image->duplicateImage) { + disp->Extensions.MESA_image_sRGB = EGL_TRUE; + } #ifdef HAVE_DRM_PLATFORM if (dri2_dpy->image->base.version >= 8 && dri2_dpy->image->createImageFromDmaBufs) { @@ -1218,6 +1222,47 @@ dri2_release_tex_image(_EGLDriver *drv, return EGL_TRUE; } +static EGLBoolean +dri2_process_dri_image(_EGLDisplay *disp, __DRIimage **dri_image, + const _EGLImageAttribs *attrs) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + __DRIimage *result; + + if (attrs->GammaMESA == EGL_DEFAULT_MESA) { + return EGL_TRUE; + } + + if (!disp->Extensions.MESA_image_sRGB) { + goto bad_view; + } + + if (attrs->GammaMESA != EGL_COLORSPACE_sRGB && + attrs->GammaMESA != EGL_COLORSPACE_LINEAR) { + goto bad_view; + } + + result = dri2_dpy->image->duplicateImage(dri2_dpy->dri_screen, + *dri_image, + attrs->GammaMESA == EGL_COLORSPACE_sRGB ? + __DRI_IMAGE_FLAG_SRGB_VIEW : + __DRI_IMAGE_FLAG_LINEAR_VIEW, NULL); + + if (result == NULL) { + goto bad_view; + } + + dri2_dpy->image->destroyImage(*dri_image); + + *dri_image = result; + + return EGL_TRUE; + +bad_view: + _eglError(EGL_BAD_VIEW_MESA, "dri2_create_image"); + return EGL_FALSE; +} + static _EGLImage* dri2_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, @@ -1228,9 +1273,11 @@ dri2_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, attr_list); } -static _EGLImage * -dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image) +_EGLImage * +dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image, + const _EGLImageAttribs *attrs) { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img; if (dri_image == NULL) { @@ -1238,26 +1285,35 @@ dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image) return NULL; } + if (!dri2_process_dri_image(disp, &dri_image, attrs)) { + goto error; + } + dri2_img = malloc(sizeof *dri2_img); if (!dri2_img) { _eglError(EGL_BAD_ALLOC, "dri2_create_image"); - return NULL; + goto error; } if (!_eglInitImage(&dri2_img->base, disp)) { + _eglError(EGL_BAD_ALLOC, "dri2_create_image"); free(dri2_img); - return NULL; + goto error; } dri2_img->dri_image = dri_image; return &dri2_img->base; + +error: + dri2_dpy->image->destroyImage(dri_image); + return NULL; } static _EGLImage * dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, - const EGLint *attr_list) + const _EGLImageAttribs *attrs) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); @@ -1273,36 +1329,32 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext
[Mesa-dev] [PATCH v3 1/5] Add MESA_image_sRGB spec.
--- docs/specs/MESA_image_sRGB.spec | 155 1 file changed, 155 insertions(+) create mode 100644 docs/specs/MESA_image_sRGB.spec diff --git a/docs/specs/MESA_image_sRGB.spec b/docs/specs/MESA_image_sRGB.spec new file mode 100644 index 000..7b29e7e --- /dev/null +++ b/docs/specs/MESA_image_sRGB.spec @@ -0,0 +1,155 @@ +Name + +MESA_image_sRGB + +Name Strings + +EGL_MESA_image_sRGB + +Contact + +John Kåre Alsaker + +Status + +Complete + +Version + +Version 3, March 3, 2013 + +Number + +EGL Extension #not assigned + +Dependencies + +EGL 1.2 or later is required. + +EGL_KHR_image_base is required. + +This extension is written against the wording of the EGL 1.2 +specification. + +Overview + +This extension provides a way for applications to allocate sRGB +or linear gamma views for EGLImage sources. This means that +sampling from the resulting EGLImage should convert from sRGB's +gamma into linear gamma. + +IP Status + +Open-source; freely implementable. + +New Tokens + +Accepted in the parameter of eglCreateImageKHR: + +EGL_GAMMA_MESA 0x3290 + +Accepted as values for the EGL_GAMMA_MESA attribute: + +EGL_DEFAULT_MESA 0x3291 + +Error states: + +EGL_BAD_VIEW_MESA 0x3292 + +Additions to the EGL 1.2 Specification: + +Add to section 2.5.1 "EGLImage Specification" (as defined by the +EGL_KHR_image_base specification), in the description of +eglCreateImageKHR: + + "Attributes names accepted in are shown in Table bbb + + ++-+--+ + | Attribute | Description | Default Value| + ++-+--+ + | EGL_GAMMA_MESA | Specifies the gamma | EGL_DEFAULT_MESA | + || view of the | | + || EGLImage created. | | + ++-+--+ + Table bbb. Legal attributes for eglCreateImageKHR +parameter + +... + +If the value of attribute EGL_GAMMA_MESA is EGL_DEFAULT_MESA (the +default), then the gamma view of the resulting EGLImage will be +the same as the EGLImage source. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_LINEAR, +then the gamma view of the resulting EGLImage will be linear +and no gamma conversions will be done when sampling the image +in client APIs. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_sRGB, +then the gamma view of the resulting EGLImage will be an sRGB +view and the red, green and blue color components will be +converted from sRGB gamma to linear gamma when sampling the image +in client APIs. This conversion should ideally take place before +any filtering, but that is not required. The conversion from an +sRGB gamma component, cs, to a linear gamma component, cl, is as +follows. + +{ cs / 12.92, cs <= 0.04045 + cl = { +{ ((cs + 0.055)/1.055)^2.4, cs > 0.04045 + +Assume cs is the sRGB gamma component in the range [0,1]." + +Add to the list of error conditions for eglCreateImageKHR: + + "* If the value specified in for EGL_GAMMA_MESA + is not EGL_DEFAULT_MESA, and the implementation does not + support creating the specified gamma view, the error + EGL_BAD_VIEW_MESA is generated. + + * If the value specified in for EGL_GAMMA_MESA + is EGL_COLORSPACE_sRGB, and the EGLImage source does not have + red, green and blue color components, the error + EGL_BAD_VIEW_MESA is generated." + +Conformance Tests + +1. Test that specifying EGL_DEFAULT_MESA as EGL_GAMMA_MESA does + not affect the creation of EGL images. + +2. Test that specifying an non-gamma EGL attribute as EGL_GAMMA_MESA + results in the error EGL_BAD_VIEW_MESA being generated. + +Issues + +1) Should creating multiple EGLImages from the same source +with a different gamma view be allowed? + +RESOLVED: Yes. + +This is so applications can easily switch between using +an sRGB and a linear gamma view for a single EGLImage +source. + +2) What reasons may an implementation have for not supporting a +texture view? + +RESOLVED: Any reason. + +For example, it may not support an sRGB gamma view for bit-depths +other than 32 bpp or the current driver may not support sRGB gamma +views at all. + +If no drivers support an sRGB gamma view at all, then this extension +should not be exposed. + +Revision History + +Version 3, March 3, 2013 +Added issue 2 and Con
[Mesa-dev] [PATCH] Cut down false positives when running the Clang Analyzer.
--- src/mapi/glapi/gen/gl_table.py | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index fd38468..d4075ff 100644 --- a/src/mapi/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py @@ -101,10 +101,22 @@ class PrintRemapTable(gl_XML.gl_print_base): return def printBody(self, api): +print '#ifndef __has_feature' +print '#define __has_feature(x) 0' +print '#endif' +print '' +print '#if __has_feature(attribute_analyzer_noreturn)' +print 'static inline _glapi_proc gl_table_null() __attribute__((analyzer_noreturn));' +print '#endif' +print '' +print 'static inline _glapi_proc gl_table_null() {' +print ' return NULL;' +print '}' +print '' print '#define CALL_by_offset(disp, cast, offset, parameters) \\' print '(*(cast (GET_by_offset(disp, offset parameters' print '#define GET_by_offset(disp, offset) \\' -print '(offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL' +print '(offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : gl_table_null()' print '#define SET_by_offset(disp, offset, fn) \\' print 'do { \\' print 'if ( (offset) < 0 ) { \\' -- 1.9.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 2/5] dri: Add another duplicateImage to DRIimageExtension which allows you to create a sRGB view of a DRI image
On Sun, Mar 3, 2013 at 4:43 PM, Jakob Bornecrantz wrote: > These really should just be another set of formats, since that is > how they are handled gallium anyways. I think I was going that route, but changed by mind for some reason. Probably because I didn't want to add lots of sRGB formats and it doesn't interact well with planar/fourcc formats. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH v2 3/5] gallium: Implement DRIimageExtension.duplicateImage
On Sun, Mar 3, 2013 at 4:52 PM, Jakob Bornecrantz wrote: > Have you tested if this actually works? I would guess it would > render in the right colorspace but for sampling the state tracker > might just drop the format on the floor. It works for sampling, but I'm not sure what the current or desired behavior for render targets should be. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/5 fixed] dri: Add another duplicateImage to DRIimageExtension
duplicateImage will allow you to create a linear or sRGB view into a DRIimage you have access to. This is useful because compositors may want a specific view which doesn't correspond to the one used by applications. --- include/GL/internal/dri_interface.h | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 42147e9..2921293 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -938,7 +938,7 @@ struct __DRIdri2ExtensionRec { * extensions. */ #define __DRI_IMAGE "DRI_IMAGE" -#define __DRI_IMAGE_VERSION 6 +#define __DRI_IMAGE_VERSION 7 /** * These formats correspond to the similarly named MESA_FORMAT_* @@ -1009,6 +1009,15 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 +/** + * Flags for duplicateImage. + * + * \since 7 + */ + +#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001 +#define __DRI_IMAGE_FLAG_LINEAR_VIEW 0x0002 + /** * queryImage attributes @@ -1117,6 +1126,15 @@ struct __DRIimageExtensionRec { int level, unsigned *error, void *loaderPrivate); + + /** +* The new __DRIimage will share the raw content with the old one, +* but it might have a different format. +* +* \since 7 +*/ +__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate); }; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 piglit 5/5] egl: Add test for MESA_image_srgb
--- tests/egl/CMakeLists.gl.txt | 2 + tests/egl/egl-mesa-image-srgb.c | 111 2 files changed, 113 insertions(+) create mode 100644 tests/egl/egl-mesa-image-srgb.c diff --git a/tests/egl/CMakeLists.gl.txt b/tests/egl/CMakeLists.gl.txt index 03b2ae0..7d163ab 100644 --- a/tests/egl/CMakeLists.gl.txt +++ b/tests/egl/CMakeLists.gl.txt @@ -16,6 +16,8 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") target_link_libraries(egl-nok-swap-region pthread ${X11_X11_LIB}) piglit_add_executable (egl-nok-texture-from-pixmap egl-util.c egl-nok-texture-from-pixmap.c) target_link_libraries(egl-nok-texture-from-pixmap pthread ${X11_X11_LIB}) + piglit_add_executable (egl-mesa-image-srgb egl-util.c egl-mesa-image-srgb.c) + target_link_libraries(egl-mesa-image-srgb pthread ${X11_X11_LIB}) piglit_add_executable (egl-create-surface egl-util.c egl-create-surface.c) target_link_libraries(egl-create-surface pthread ${X11_X11_LIB}) piglit_add_executable (egl-query-surface egl-util.c egl-query-surface.c) diff --git a/tests/egl/egl-mesa-image-srgb.c b/tests/egl/egl-mesa-image-srgb.c new file mode 100644 index 000..4e04be4 --- /dev/null +++ b/tests/egl/egl-mesa-image-srgb.c @@ -0,0 +1,111 @@ +/* + * Copyright © 2010 Intel Corporation + * + * 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, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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: + *John Kåre Alsaker + *Kristian Høgsberg + */ + +/** @file egl-mesa-image-srgb.c + * + * Test EGL_MESA_image_sRGB + */ + +#include "piglit-util-gl-common.h" +#include "egl-util.h" + +#if defined(EGL_MESA_image_sRGB) && defined(EGL_KHR_image_pixmap) + +const char *extensions[] = { "EGL_MESA_image_sRGB", "EGL_KHR_image_pixmap", NULL }; + +static const EGLint default_attribs[] = { + EGL_GAMMA_MESA, EGL_DEFAULT_MESA, + EGL_NONE +}; + +static const EGLint bad_attribs[] = { + EGL_GAMMA_MESA, EGL_BAD_ATTRIBUTE, + EGL_NONE +}; + +static enum piglit_result +draw(struct egl_state *state) +{ + Pixmap pixmap; + EGLImageKHR img; + PFNEGLCREATEIMAGEKHRPROC create_image_khr; + + create_image_khr = (PFNEGLCREATEIMAGEKHRPROC) + eglGetProcAddress("eglCreateImageKHR"); + + if (create_image_khr == NULL) { + fprintf(stderr, "could not getproc eglCreateImageKHR"); + piglit_report_result(PIGLIT_FAIL); + } + + pixmap = XCreatePixmap(state->dpy, state->win, 1, 1, state->depth); + + img = create_image_khr(state->egl_dpy, state->ctx, + EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)pixmap, + default_attribs); + if (!img) { + fprintf(stderr, "default view eglCreateImageKHR() failed\n"); + piglit_report_result(PIGLIT_FAIL); + } + + img = create_image_khr(state->egl_dpy, state->ctx, + EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer)pixmap, + bad_attribs); + + if (img || (eglGetError() != EGL_BAD_VIEW_MESA)) { + fprintf(stderr, "unsupported view eglCreateImageKHR() failed\n"); + piglit_report_result(PIGLIT_FAIL); + } + + return PIGLIT_PASS; +} + +int +main(int argc, char *argv[]) +{ + struct egl_test test; + + egl_init_test(&test); + test.extensions = extensions; + test.draw = draw; + + return egl_util_run(&test, argc, argv); +} + +#else + +int +main(int argc, char *argv[]) +{ + piglit_report_result(PIGLIT_SKIP); + + return 0; +} + +#endif -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 4/5] egl: Add MESA_image_sRGB extension.
This gives applications access to use DRIimage.duplicateImage to create sRGB and linear views from EGL images. --- include/EGL/eglmesaext.h| 7 ++ src/egl/drivers/dri2/egl_dri2.c | 168 src/egl/drivers/dri2/egl_dri2.h | 6 +- src/egl/drivers/dri2/platform_android.c | 36 +++ src/egl/drivers/dri2/platform_drm.c | 36 +++ src/egl/drivers/dri2/platform_x11.c | 37 +++ src/egl/main/eglcurrent.c | 3 + src/egl/main/egldisplay.h | 1 + src/egl/main/eglimage.c | 6 ++ src/egl/main/eglimage.h | 3 + src/egl/main/eglmisc.c | 1 + 11 files changed, 173 insertions(+), 131 deletions(-) diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h index d476d18..59f903a 100644 --- a/include/EGL/eglmesaext.h +++ b/include/EGL/eglmesaext.h @@ -109,6 +109,13 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd); #endif #endif +#ifndef EGL_MESA_image_sRGB +#define EGL_MESA_image_sRGB 1 +#define EGL_GAMMA_MESA 0x3290 /* eglCreateImageKHR attribute */ +#define EGL_DEFAULT_MESA 0x3291 +#define EGL_BAD_VIEW_MESA 0x3292 +#endif + #ifndef EGL_WL_bind_wayland_display #define EGL_WL_bind_wayland_display 1 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index b774919..9e0658f 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -507,6 +507,10 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE; disp->Extensions.KHR_gl_texture_cubemap_image = EGL_TRUE; } + if (dri2_dpy->image->base.version >= 7 && + dri2_dpy->image->duplicateImage) { + disp->Extensions.MESA_image_sRGB = EGL_TRUE; + } } } @@ -1077,9 +1081,52 @@ dri2_release_tex_image(_EGLDriver *drv, return EGL_TRUE; } -static _EGLImage * -dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image) +static EGLBoolean +dri2_process_dri_image(_EGLDisplay *disp, __DRIimage **dri_image, + const _EGLImageAttribs *attrs) +{ + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); + __DRIimage *result; + + if (attrs->GammaMESA == EGL_DEFAULT_MESA) { + return EGL_TRUE; + } + + if(!disp->Extensions.MESA_image_sRGB) { + goto bad_view; + } + + if (attrs->GammaMESA != EGL_COLORSPACE_sRGB && + attrs->GammaMESA != EGL_COLORSPACE_LINEAR) { + goto bad_view; + } + + result = dri2_dpy->image->duplicateImage(dri2_dpy->dri_screen, + *dri_image, + attrs->GammaMESA == EGL_COLORSPACE_sRGB ? + __DRI_IMAGE_FLAG_SRGB_VIEW : + __DRI_IMAGE_FLAG_LINEAR_VIEW, NULL); + + if (result == NULL) { + goto bad_view; + } + + dri2_dpy->image->destroyImage(*dri_image); + + *dri_image = result; + + return EGL_TRUE; + +bad_view: + _eglError(EGL_BAD_VIEW_MESA, "dri2_create_image"); + return EGL_FALSE; +} + +_EGLImage * +dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image, + const _EGLImageAttribs *attrs) { + struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img; if (dri_image == NULL) { @@ -1087,26 +1134,35 @@ dri2_create_image(_EGLDisplay *disp, __DRIimage *dri_image) return NULL; } + if (!dri2_process_dri_image(disp, &dri_image, attrs)) { + goto error; + } + dri2_img = malloc(sizeof *dri2_img); if (!dri2_img) { _eglError(EGL_BAD_ALLOC, "dri2_create_image"); - return NULL; + goto error; } if (!_eglInitImage(&dri2_img->base, disp)) { + _eglError(EGL_BAD_ALLOC, "dri2_create_image"); free(dri2_img); - return NULL; + goto error; } dri2_img->dri_image = dri_image; return &dri2_img->base; + +error: + dri2_dpy->image->destroyImage(dri_image); + return NULL; } static _EGLImage * dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, EGLClientBuffer buffer, - const EGLint *attr_list) + const _EGLImageAttribs *attrs) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); @@ -1122,35 +1178,31 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context, renderbuffer, NULL); - return dri2_create_image(disp, dri_image); + return dri2_create_image(disp, dri_image, attrs); } static _EGLImage * dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx, - EGLClientBuffer buffer, const EGLint *attr_list) + EGLClientBuffer buffer
[Mesa-dev] [PATCH v2 3/5] gallium: Implement DRIimageExtension.duplicateImage
--- src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/common/dri_screen.c | 1 + src/gallium/state_trackers/dri/common/dri_screen.h | 1 + src/gallium/state_trackers/dri/drm/dri2.c | 39 +- src/mesa/state_tracker/st_manager.c| 4 +++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 9f3d2a1..1e63ed3 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -203,6 +203,7 @@ struct st_egl_image { /* this is owned by the caller */ struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index a908e28..92abaf9 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -315,6 +315,7 @@ dri_get_egl_image(struct st_manager *smapi, stimg->texture = NULL; pipe_resource_reference(&stimg->texture, img->texture); + stimg->format = img->format; stimg->level = img->level; stimg->layer = img->layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 181b22f..d37c393 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -84,6 +84,7 @@ dri_screen(__DRIscreen * sPriv) struct __DRIimageRec { struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; uint32_t dri_format; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index f8d311c..54339fe 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -658,6 +658,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate) pipe_resource_reference(&img->texture, image->texture); img->level = image->level; img->layer = image->layer; + img->format = image->format; /* This should be 0 for sub images, but dup is also used for base images. */ img->dri_components = image->dri_components; img->loader_private = loaderPrivate; @@ -749,6 +750,40 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate) return img; } +static __DRIimage * +dri2_duplicate_image(__DRIscreen *_screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate) +{ + enum pipe_format format; + struct dri_screen *screen = dri_screen(_screen); + __DRIimage *img = NULL; + + if((flags & __DRI_IMAGE_FLAG_SRGB_VIEW) && (flags & __DRI_IMAGE_FLAG_LINEAR_VIEW)) + return NULL; + + if(flags & (__DRI_IMAGE_FLAG_SRGB_VIEW | __DRI_IMAGE_FLAG_LINEAR_VIEW)) { + if(!image->texture) + return NULL; + + if(flags & __DRI_IMAGE_FLAG_SRGB_VIEW) + format = util_format_srgb(image->texture->format); + else + format = util_format_linear(image->texture->format); + + if(!screen->base.screen->is_format_supported(screen->base.screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) + return NULL; + + img = dri2_dup_image(image, loaderPrivate); + + if (img) + img->format = format; + } else if (flags == 0) { + img = dri2_dup_image(image, loaderPrivate); + } + + return img; +} + static void dri2_destroy_image(__DRIimage *img) { @@ -757,7 +792,7 @@ dri2_destroy_image(__DRIimage *img) } static struct __DRIimageExtensionRec dri2ImageExtension = { -{ __DRI_IMAGE, 5 }, +{ __DRI_IMAGE, 7 }, dri2_create_image_from_name, dri2_create_image_from_renderbuffer, dri2_destroy_image, @@ -767,6 +802,8 @@ static struct __DRIimageExtensionRec dri2ImageExtension = { dri2_validate_usage, dri2_from_names, dri2_from_planar, +NULL, +dri2_duplicate_image, }; /* diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index a3a6771..3659499 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -810,6 +810,10 @@ st_manager_get_egl_image_surface(struct st_context *st, void *eglimg) return NULL; u_surface_default_template(&surf_tmpl, stimg.texture); + + if(stimg.format != PIPE_FORMAT_NONE) + surf_tmpl.format = stimg.format; + surf_tmpl.u.tex.level = stimg.level; surf_tmpl.u.tex.first_layer = stimg.layer; surf_tmpl.u.tex.last_layer = stimg.layer; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 2/5] dri: Add another duplicateImage to DRIimageExtension which allows you to create a sRGB view of a DRI image
duplicateImage will allow you to create a linear or sRGB view into a DRIimage you have access to. This is useful because compositors may want a specific view which doesn't correspond to the one used by applications. --- include/GL/internal/dri_interface.h | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 42147e9..f4948a8 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -938,7 +938,7 @@ struct __DRIdri2ExtensionRec { * extensions. */ #define __DRI_IMAGE "DRI_IMAGE" -#define __DRI_IMAGE_VERSION 6 +#define __DRI_IMAGE_VERSION 7 /** * These formats correspond to the similarly named MESA_FORMAT_* @@ -1009,6 +1009,15 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 +/** + * Flags for duplicateImage. + * + * \since 7 + */ + +#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001 +#define __DRI_IMAGE_FLAG_LINEAR_VIEW 0x0002 + /** * queryImage attributes @@ -1105,6 +1114,7 @@ struct __DRIimageExtensionRec { __DRIimage *(*fromPlanar)(__DRIimage *image, int plane, void *loaderPrivate); + /** * Create image from texture. * @@ -1117,6 +1127,15 @@ struct __DRIimageExtensionRec { int level, unsigned *error, void *loaderPrivate); + + /** +* The new __DRIimage will share the raw content with the old one, +* but it might have a different format. +* +* \since 7 +*/ +__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate); }; -- 1.8.1.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH v2 1/5] Add MESA_image_sRGB spec.
--- docs/MESA_image_sRGB.spec | 155 ++ 1 file changed, 155 insertions(+) create mode 100644 docs/MESA_image_sRGB.spec diff --git a/docs/MESA_image_sRGB.spec b/docs/MESA_image_sRGB.spec new file mode 100644 index 000..86c0975 --- /dev/null +++ b/docs/MESA_image_sRGB.spec @@ -0,0 +1,155 @@ +Name + +MESA_image_sRGB + +Name Strings + +EGL_MESA_image_sRGB + +Contact + +John Kåre Alsaker + +Status + +Complete + +Version + +Version 2, February 23, 2013 + +Number + +EGL Extension #not assigned + +Dependencies + +EGL 1.2 or later is required. + +EGL_KHR_image_base is required. + +This extension is written against the wording of the EGL 1.2 +specification. + +Overview + +This extension provides a way for applications to allocate sRGB +or linear gamma views for EGLImage sources. This means that +sampling from the resulting EGLImage should convert from sRGB's +gamma into linear gamma. + +IP Status + +Open-source; freely implementable. + +New Tokens + +Accepted in the parameter of eglCreateImageKHR: + +EGL_GAMMA_MESA 0x3290 + +Accepted as values for the EGL_GAMMA_MESA attribute: + +EGL_DEFAULT_MESA 0x3291 + +Error states: + +EGL_BAD_VIEW_MESA 0x3292 + +Additions to the EGL 1.2 Specification: + +Add to section 2.5.1 "EGLImage Specification" (as defined by the +EGL_KHR_image_base specification), in the description of +eglCreateImageKHR: + + "Attributes names accepted in are shown in Table bbb + + ++-+--+ + | Attribute | Description | Default Value| + ++-+--+ + | EGL_GAMMA_MESA | Specifies the gamma | EGL_DEFAULT_MESA | + || view of the | | + || EGLImage created. | | + ++-+--+ + Table bbb. Legal attributes for eglCreateImageKHR +parameter + +... + +If the value of attribute EGL_GAMMA_MESA is EGL_DEFAULT_MESA (the +default), then the gamma view of the resulting EGLImage will be +the same as the EGLImage source. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_LINEAR, +then the gamma view of the resulting EGLImage will be linear +and no gamma conversions will be done when sampling the image +in client APIs. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_sRGB, +then the gamma view of the resulting EGLImage will be an sRGB +view and the red, green and blue color components will be +converted from sRGB gamma to linear gamma when sampling the image +in client APIs. This conversion should ideally take place before +any filtering, but that is not required. The conversion from an +sRGB gamma component, cs, to a linear gamma component, cl, is as +follows. + +{ cs / 12.92, cs <= 0.04045 + cl = { +{ ((cs + 0.055)/1.055)^2.4, cs > 0.04045 + +Assume cs is the sRGB gamma component in the range [0,1]." + +Add to the list of error conditions for eglCreateImageKHR: + + "* If the value specified in for EGL_GAMMA_MESA + is not EGL_DEFAULT_MESA, and the implementation does not + support creating the specified gamma view, the error + EGL_BAD_VIEW_MESA is generated. + + * If the value specified in for EGL_GAMMA_MESA + is EGL_COLORSPACE_sRGB, and the EGLImage source does not have + red, green and blue color components, the error + EGL_BAD_VIEW_MESA is generated." + +Conformance Tests + +1. Test that specifying EGL_DEFAULT_MESA as EGL_GAMMA_MESA does + not affect the creation of EGL images. + +2. Test that specifying an non-gamma EGL attribute as EGL_GAMMA_MESA + results in the error EGL_BAD_VIEW_MESA being generated. + +Issues + +1) Should creating multiple EGLImages from the same source +with a different gamma view be allowed? + +RESOLVED: Yes. + +This is so applications can easily switch between using +an sRGB and a linear gamma view for a single EGLImage +source. + +2) What reasons may an implementation have for not supporting a +texture view? + +RESOLVED: Any reason. + +For example, it may not support an sRGB gamma view for bit-depths +other than 32 bpp or the current driver may not support sRGB gamma +views at all. + +If no drivers support an sRGB gamma view at all, then this extension +should not be exposed. + +Revision History + +Version 3, March 3, 2013 +Added issue 2 and Conformance Tests sec
Re: [Mesa-dev] [PATCH 3/3] egl: Add MESA_image_sRGB extension.
On Fri, Mar 1, 2013 at 10:01 PM, Ian Romanick wrote: > On 02/27/2013 10:19 PM, John Kåre Alsaker wrote: >> >> On Mon, Feb 25, 2013 at 8:55 PM, Ian Romanick wrote: >>> >>> Also... are there piglit tests coming? >> >> Not unless you convince me otherwise. I don't think I'll be able to >> verify that said tests work however. >> >>> More recent versions of the spec template include a section for >>> describing >>> conformance tests. This would be a good place to document piglit tests. >>> It >>> also helps app developers know how things should work. >> >> Where is this template? > > > I don't think the template is officially available anywhere, but the > ARB_internalformat_query spec is a good example: > > http://www.opengl.org/registry/specs/ARB/internalformat_query.txt > > I'm uncomfortable adding new functionality that has zero tests. Every time > we've done this, we've gotten bitten by it. At the minimum it should be > possible to have tests that verify: > > - Calling eglCreateImageKHR with {EGL_GAMMA_MESA, EGL_DEFAULT_MESA} always > works. > > - Calling eglCreateImageKHR with {EGL_GAMMA_MESA, } > always generates EGL_BAD_VIEW_MESA. That sounds possible. >>> What if the underlying driver doesn't support sRGB? >> >> It should just return EGL_BAD_VIEW_MESA then. > > > Isn't it better to not expose the extension at all in that case? If the > only operations you ever want to do with the extension will always fail, > what's the point? :) Otherwise, I suspect we'll get spurious bug reports. I'm not sure how to tell if the driver supports sRGB without actually trying it, but I should at least make it depend on the DRIimage version it needs. >>> Shouldn't attrs sill be const? >> >> If Mesa does const by default, then sure. > > > The parameters were const before your patch. That's why I was asking. It's a new parameter, the old one is gone. > > >>> Why can't I create an sRGB view of a pixmap? It's just a reinterpretation >>> of the bits. >> >> Because it's not implemented. I prefer not to touch code I won't even >> manually test after (no pixmaps in Wayland). > > > In that case, since this is likely the only implementation, the spec should > just disallow it. Principle of least surprise and all that. Looking over I think it's probably best to move the code into dri2_create_image and expose that to the platform_*.c files. Then it will work for all EGL images. > > >>> The spec doesn't give much guidance about why the >>> implementation may not "support creating the specified gamma view". At >>> least mentioning something in the issues section would be helpful. >> >> I could probably add something. >> >>> I know the ifdef stuff is used other places, but since this comes from >>> our >>> own header file, I don't think it's necessary. >> >> Surrounding code had it. > > > I understand that. I don't think it's necessary in this case, and it's > probably not necessary in the other cases either. I'll remove it then. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 3/3] egl: Add MESA_image_sRGB extension.
On Mon, Feb 25, 2013 at 8:55 PM, Ian Romanick wrote: > Also... are there piglit tests coming? Not unless you convince me otherwise. I don't think I'll be able to verify that said tests work however. > More recent versions of the spec template include a section for describing > conformance tests. This would be a good place to document piglit tests. It > also helps app developers know how things should work. Where is this template? > Interactions with GL_ARB_texture_view? Really, texture views seem like the > right way to do this. GL_ARB_texture_view doesn't interact with EGL images at all from what I can see. > What if the underlying driver doesn't support sRGB? It should just return EGL_BAD_VIEW_MESA then. > Since this extension > depends on KHR_image_base, the enable needs to at least depend on > dri2_dpy->image. > Shouldn't attrs sill be const? If Mesa does const by default, then sure. > Why can't I create an sRGB view of a pixmap? It's just a reinterpretation > of the bits. Because it's not implemented. I prefer not to touch code I won't even manually test after (no pixmaps in Wayland). > The spec doesn't give much guidance about why the > implementation may not "support creating the specified gamma view". At > least mentioning something in the issues section would be helpful. I could probably add something. > I know the ifdef stuff is used other places, but since this comes from our > own header file, I don't think it's necessary. Surrounding code had it. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/3] egl: Add MESA_image_sRGB extension.
This gives applications access to use DRIimage.duplicateImage to create sRGB and linear views from EGL images. --- docs/MESA_image_sRGB.spec | 132 include/EGL/eglmesaext.h| 7 ++ src/egl/drivers/dri2/egl_dri2.c | 115 +++- src/egl/drivers/dri2/egl_dri2.h | 2 +- src/egl/drivers/dri2/platform_android.c | 19 - src/egl/drivers/dri2/platform_drm.c | 18 - src/egl/drivers/dri2/platform_x11.c | 18 - src/egl/main/eglcurrent.c | 5 ++ src/egl/main/egldisplay.h | 1 + src/egl/main/eglimage.c | 6 ++ src/egl/main/eglimage.h | 3 + src/egl/main/eglmisc.c | 1 + 12 files changed, 281 insertions(+), 46 deletions(-) create mode 100644 docs/MESA_image_sRGB.spec diff --git a/docs/MESA_image_sRGB.spec b/docs/MESA_image_sRGB.spec new file mode 100644 index 000..f8a0bea --- /dev/null +++ b/docs/MESA_image_sRGB.spec @@ -0,0 +1,132 @@ +Name + +MESA_image_sRGB + +Name Strings + +EGL_MESA_image_sRGB + +Contact + +John Kåre Alsaker + +Status + +Complete + +Version + +Version 2, February 23, 2013 + +Number + +EGL Extension #not assigned + +Dependencies + +EGL 1.2 or later is required. + +EGL_KHR_image_base is required. + +This extension is written against the wording of the EGL 1.2 +specification. + +Overview + +This extension provides a way for applications to allocate sRGB +or linear gamma views for EGLImage sources. This means that +sampling from the resulting EGLImage should convert from sRGB's +gamma into linear gamma. + +IP Status + +Open-source; freely implementable. + +New Tokens + +Accepted in the parameter of eglCreateImageKHR: + +EGL_GAMMA_MESA 0x3290 + +Accepted as values for the EGL_GAMMA_MESA attribute: + +EGL_DEFAULT_MESA 0x3291 + +Error states: + +EGL_BAD_VIEW_MESA 0x3292 + +Additions to the EGL 1.2 Specification: + +Add to section 2.5.1 "EGLImage Specification" (as defined by the +EGL_KHR_image_base specification), in the description of +eglCreateImageKHR: + + "Attributes names accepted in are shown in Table bbb + + ++-+--+ + | Attribute | Description | Default Value| + ++-+--+ + | EGL_GAMMA_MESA | Specifies the gamma | EGL_DEFAULT_MESA | + || view of the | | + || EGLImage created. | | + ++-+--+ + Table bbb. Legal attributes for eglCreateImageKHR +parameter + +... + +If the value of attribute EGL_GAMMA_MESA is EGL_DEFAULT_MESA (the +default), then the gamma view of the resulting EGLImage will be +the same as the EGLImage source. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_LINEAR, +then the gamma view of the resulting EGLImage will be linear +and no gamma conversions will be done when sampling the image +in client APIs. + +If the value of attribute EGL_GAMMA_MESA is EGL_COLORSPACE_sRGB, +then the gamma view of the resulting EGLImage will be an sRGB +view and the red, green and blue color components will be +converted from sRGB gamma to linear gamma when sampling the image +in client APIs. This conversion should ideally take place before +any filtering, but that is not required. The conversion from an +sRGB gamma component, cs, to a linear gamma component, cl, is as +follows. + +{ cs / 12.92, cs <= 0.04045 + cl = { +{ ((cs + 0.055)/1.055)^2.4, cs > 0.04045 + +Assume cs is the sRGB gamma component in the range [0,1]." + +Add to the list of error conditions for eglCreateImageKHR: + + "* If the value specified in for EGL_GAMMA_MESA + is not EGL_DEFAULT_MESA, and the implementation does not + support creating the specified gamma view, the error + EGL_BAD_VIEW_MESA is generated. + + * If the value specified in for EGL_GAMMA_MESA + is EGL_COLORSPACE_sRGB, and the EGLImage source does not have + red, green and blue color components, the error + EGL_BAD_VIEW_MESA is generated." + +Issues + +1) Should creating multiple EGLImages from the same source +with a different gamma view be allowed? + +RESOLVED: Yes. + +This is so applications can easily switch between using +an sRGB and a linear gamma view for a single EGLImage +source. + +Revision History + +Version 2, February 23, 2013 + Changed used tokens (John
[Mesa-dev] [PATCH 2/3] gallium: Implement DRIimageExtension.duplicateImage
--- src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/common/dri_screen.c | 1 + src/gallium/state_trackers/dri/common/dri_screen.h | 1 + src/gallium/state_trackers/dri/drm/dri2.c | 39 +- src/mesa/state_tracker/st_manager.c| 4 +++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 9f3d2a1..1e63ed3 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -203,6 +203,7 @@ struct st_egl_image { /* this is owned by the caller */ struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index a908e28..92abaf9 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -315,6 +315,7 @@ dri_get_egl_image(struct st_manager *smapi, stimg->texture = NULL; pipe_resource_reference(&stimg->texture, img->texture); + stimg->format = img->format; stimg->level = img->level; stimg->layer = img->layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index 181b22f..d37c393 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -84,6 +84,7 @@ dri_screen(__DRIscreen * sPriv) struct __DRIimageRec { struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; uint32_t dri_format; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index f8d311c..54339fe 100644 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -658,6 +658,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate) pipe_resource_reference(&img->texture, image->texture); img->level = image->level; img->layer = image->layer; + img->format = image->format; /* This should be 0 for sub images, but dup is also used for base images. */ img->dri_components = image->dri_components; img->loader_private = loaderPrivate; @@ -749,6 +750,40 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate) return img; } +static __DRIimage * +dri2_duplicate_image(__DRIscreen *_screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate) +{ + enum pipe_format format; + struct dri_screen *screen = dri_screen(_screen); + __DRIimage *img = NULL; + + if((flags & __DRI_IMAGE_FLAG_SRGB_VIEW) && (flags & __DRI_IMAGE_FLAG_LINEAR_VIEW)) + return NULL; + + if(flags & (__DRI_IMAGE_FLAG_SRGB_VIEW | __DRI_IMAGE_FLAG_LINEAR_VIEW)) { + if(!image->texture) + return NULL; + + if(flags & __DRI_IMAGE_FLAG_SRGB_VIEW) + format = util_format_srgb(image->texture->format); + else + format = util_format_linear(image->texture->format); + + if(!screen->base.screen->is_format_supported(screen->base.screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) + return NULL; + + img = dri2_dup_image(image, loaderPrivate); + + if (img) + img->format = format; + } else if (flags == 0) { + img = dri2_dup_image(image, loaderPrivate); + } + + return img; +} + static void dri2_destroy_image(__DRIimage *img) { @@ -757,7 +792,7 @@ dri2_destroy_image(__DRIimage *img) } static struct __DRIimageExtensionRec dri2ImageExtension = { -{ __DRI_IMAGE, 5 }, +{ __DRI_IMAGE, 7 }, dri2_create_image_from_name, dri2_create_image_from_renderbuffer, dri2_destroy_image, @@ -767,6 +802,8 @@ static struct __DRIimageExtensionRec dri2ImageExtension = { dri2_validate_usage, dri2_from_names, dri2_from_planar, +NULL, +dri2_duplicate_image, }; /* diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index a3a6771..3659499 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -810,6 +810,10 @@ st_manager_get_egl_image_surface(struct st_context *st, void *eglimg) return NULL; u_surface_default_template(&surf_tmpl, stimg.texture); + + if(stimg.format != PIPE_FORMAT_NONE) + surf_tmpl.format = stimg.format; + surf_tmpl.u.tex.level = stimg.level; surf_tmpl.u.tex.first_layer = stimg.layer; surf_tmpl.u.tex.last_layer = stimg.layer; -- 1.8.1.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/3] dri: Add another duplicateImage to DRIimageExtension which allows you to create a sRGB view of a DRI image
duplicateImage will allow you to create a linear or sRGB view into a DRIimage you have access to. This is useful because compositors may want a specific view which doesn't correspond to the one used by applications. --- include/GL/internal/dri_interface.h | 21 - 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 42147e9..f4948a8 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -938,7 +938,7 @@ struct __DRIdri2ExtensionRec { * extensions. */ #define __DRI_IMAGE "DRI_IMAGE" -#define __DRI_IMAGE_VERSION 6 +#define __DRI_IMAGE_VERSION 7 /** * These formats correspond to the similarly named MESA_FORMAT_* @@ -1009,6 +1009,15 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 +/** + * Flags for duplicateImage. + * + * \since 7 + */ + +#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001 +#define __DRI_IMAGE_FLAG_LINEAR_VIEW 0x0002 + /** * queryImage attributes @@ -1105,6 +1114,7 @@ struct __DRIimageExtensionRec { __DRIimage *(*fromPlanar)(__DRIimage *image, int plane, void *loaderPrivate); + /** * Create image from texture. * @@ -1117,6 +1127,15 @@ struct __DRIimageExtensionRec { int level, unsigned *error, void *loaderPrivate); + + /** +* The new __DRIimage will share the raw content with the old one, +* but it might have a different format. +* +* \since 7 +*/ +__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate); }; -- 1.8.1.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] llvmpipe: Fix creation of shared and scanout textures.
I'd still like to have this applied. On Tue, Dec 18, 2012 at 3:16 PM, John Kåre Alsaker wrote: > On Tue, Dec 18, 2012 at 11:20 AM, Jose Fonseca wrote: >> Looks fine. >> >> I'm curious, what does this fix in practice? > It fixes Weston crashing when running with llvmpipe. > >> >> Jose >> >> - Original Message - >>> NOTE: This is a candidate for the stable branches. >>> --- >>> src/gallium/drivers/llvmpipe/lp_texture.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c >>> b/src/gallium/drivers/llvmpipe/lp_texture.c >>> index 2e9c6bf..f17a04a 100644 >>> --- a/src/gallium/drivers/llvmpipe/lp_texture.c >>> +++ b/src/gallium/drivers/llvmpipe/lp_texture.c >>> @@ -295,7 +295,9 @@ llvmpipe_resource_create(struct pipe_screen >>> *_screen, >>> /* assert(lpr->base.bind); */ >>> >>> if (resource_is_texture(&lpr->base)) { >>> - if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { >>> + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | >>> +PIPE_BIND_SCANOUT | >>> +PIPE_BIND_SHARED)) { >>> /* displayable surface */ >>> if (!llvmpipe_displaytarget_layout(screen, lpr)) >>> goto fail; >>> -- >>> 1.8.0.2 >>> >>> ___ >>> mesa-dev mailing list >>> mesa-dev@lists.freedesktop.org >>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev >>> ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] llvmpipe: Fix creation of shared and scanout textures.
On Tue, Dec 18, 2012 at 11:20 AM, Jose Fonseca wrote: > Looks fine. > > I'm curious, what does this fix in practice? It fixes Weston crashing when running with llvmpipe. > > Jose > > - Original Message - >> NOTE: This is a candidate for the stable branches. >> --- >> src/gallium/drivers/llvmpipe/lp_texture.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c >> b/src/gallium/drivers/llvmpipe/lp_texture.c >> index 2e9c6bf..f17a04a 100644 >> --- a/src/gallium/drivers/llvmpipe/lp_texture.c >> +++ b/src/gallium/drivers/llvmpipe/lp_texture.c >> @@ -295,7 +295,9 @@ llvmpipe_resource_create(struct pipe_screen >> *_screen, >> /* assert(lpr->base.bind); */ >> >> if (resource_is_texture(&lpr->base)) { >> - if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { >> + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | >> +PIPE_BIND_SCANOUT | >> +PIPE_BIND_SHARED)) { >> /* displayable surface */ >> if (!llvmpipe_displaytarget_layout(screen, lpr)) >> goto fail; >> -- >> 1.8.0.2 >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev >> ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: Fix creation of shared and scanout textures.
NOTE: This is a candidate for the stable branches. --- src/gallium/drivers/llvmpipe/lp_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 2e9c6bf..f17a04a 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -295,7 +295,9 @@ llvmpipe_resource_create(struct pipe_screen *_screen, /* assert(lpr->base.bind); */ if (resource_is_texture(&lpr->base)) { - if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | +PIPE_BIND_SCANOUT | +PIPE_BIND_SHARED)) { /* displayable surface */ if (!llvmpipe_displaytarget_layout(screen, lpr)) goto fail; -- 1.8.0.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: Fix creation for shared and scanout.
NOTE: This is a candidate for the stable branches. --- src/gallium/drivers/llvmpipe/lp_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index b4ea94c..ccea4e2 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -287,7 +287,9 @@ llvmpipe_resource_create(struct pipe_screen *_screen, /* assert(lpr->base.bind); */ if (resource_is_texture(&lpr->base)) { - if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | +PIPE_BIND_SCANOUT | +PIPE_BIND_SHARED)) { /* displayable surface */ if (!llvmpipe_displaytarget_layout(screen, lpr)) goto fail; -- 1.7.12.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] Cut down false positives when running the Clang Analyzer.
--- src/gallium/auxiliary/util/u_debug.h | 2 +- src/gallium/include/pipe/p_compiler.h | 12 src/mapi/glapi/gen/gl_table.py| 14 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index ec7d4a0..3f4ec25 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -152,7 +152,7 @@ debug_get_num_option(const char *name, long dfault); void _debug_assert_fail(const char *expr, const char *file, unsigned line, -const char *function); +const char *function) ANALYZER_NORETURN; /** diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index 5958333..e6c67b3 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -90,6 +90,18 @@ typedef unsigned char boolean; #endif #endif +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#ifndef ANALYZER_NORETURN +# if __has_feature(attribute_analyzer_noreturn) +#define ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +# else +# define ANALYZER_NORETURN +# endif +#endif + /* Function inlining */ #ifndef inline # ifdef __cplusplus diff --git a/src/mapi/glapi/gen/gl_table.py b/src/mapi/glapi/gen/gl_table.py index 856aedb..018b0da 100644 --- a/src/mapi/glapi/gen/gl_table.py +++ b/src/mapi/glapi/gen/gl_table.py @@ -107,10 +107,22 @@ class PrintRemapTable(gl_XML.gl_print_base): return def printBody(self, api): +print '#ifndef __has_feature' +print '#define __has_feature(x) 0' +print '#endif' +print '' +print '#if __has_feature(attribute_analyzer_noreturn)' +print 'static inline _glapi_proc gl_table_null() __attribute__((analyzer_noreturn));' +print '#endif' +print '' +print 'static inline _glapi_proc gl_table_null() {' +print ' return NULL;' +print '}' +print '' print '#define CALL_by_offset(disp, cast, offset, parameters) \\' print '(*(cast (GET_by_offset(disp, offset parameters' print '#define GET_by_offset(disp, offset) \\' -print '(offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL' +print '(offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : gl_table_null()' print '#define SET_by_offset(disp, offset, fn) \\' print 'do { \\' print 'if ( (offset) < 0 ) { \\' -- 1.7.12.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: Add support for 16-bit per channel RGBA
It just fixes posterization when rendering in linear space. It's also required for having 64 bpp Wayland clients. On Thu, Oct 11, 2012 at 2:18 AM, Brian Paul wrote: > On Mon, Oct 8, 2012 at 4:50 PM, John Kåre Alsaker > wrote: >> --- >> src/gallium/drivers/svga/svga_format.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/src/gallium/drivers/svga/svga_format.c >> b/src/gallium/drivers/svga/svga_format.c >> index 5176106..5a153a8 100644 >> --- a/src/gallium/drivers/svga/svga_format.c >> +++ b/src/gallium/drivers/svga/svga_format.c >> @@ -66,6 +66,9 @@ svga_translate_format(struct svga_screen *ss, >> case PIPE_FORMAT_B4G4R4A4_UNORM: >>return SVGA3D_A4R4G4B4; >> >> + case PIPE_FORMAT_R16G16B16A16_UNORM: >> + return SVGA3D_A16B16G16R16; >> + >> case PIPE_FORMAT_Z16_UNORM: >>return bind & PIPE_BIND_SAMPLER_VIEW ? ss->depth.z16 : SVGA3D_Z_D16; >> case PIPE_FORMAT_S8_UINT_Z24_UNORM: > > Does this fix a particular issue? In any case it looks fine. I can > commit this for you. > > -Brian ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Adding support for sRGB KHR images to EGL
So I wrote a proper proposal. It differs slightly from my implementation (EGL_DEFAULT_MESA is added), so I'll have to revise that. Could someone point me in the correct direction to get enums allocated from Khronos? Name MESA_image_sRGB Name Strings EGL_MESA_image_sRGB Contact John Kåre Alsaker Status Proposal Version Version 1, October 9, 2012 Number EGL Extension #not assigned Dependencies EGL 1.2 or later is required. EGL_KHR_image_base is required. This extension is written against the wording of the EGL 1.2 specification. Overview This extension provides a way for applications to allocate sRGB or linear gamma views for EGLImage sources. This means that sampling from the resulting EGLImage should convert from sRGB's gamma into linear gamma. IP Status Open-source; freely implementable. New Tokens Accepted in the parameter of eglCreateImageKHR: EGL_GAMMA_MESA #not assigned Accepted as values for the EGL_GAMMA_MESA attribute: EGL_DEFAULT_MESA#not assigned EGL_LINEAR_MESA #not assigned EGL_sRGB_MESA #not assigned Additions to the EGL 1.2 Specification: Add to section 2.5.1 "EGLImage Specification" (as defined by the EGL_KHR_image_base specification), in the description of eglCreateImageKHR: "Attributes names accepted in are shown in Table bbb ++-+--+ | Attribute | Description | Default Value| ++-+--+ | EGL_GAMMA_MESA | Specifies the gamma | EGL_DEFAULT_MESA | || view of the | | || EGLImage created. | | ++-+--+ Table bbb. Legal attributes for eglCreateImageKHR parameter ... If the value of attribute EGL_GAMMA_MESA is EGL_DEFAULT_MESA (the default), then the gamma view of the resulting EGLImage will be the same as the EGLImage source. If the value of attribute EGL_GAMMA_MESA is EGL_LINEAR_MESA, then the gamma view of the resulting EGLImage will be linear and no gamma conversions will be done when sampling the image in client APIs. If the value of attribute EGL_GAMMA_MESA is EGL_sRGB_MESA, then the gamma view of the resulting EGLImage will be an sRGB view and the red, green and blue color components will be converted from sRGB gamma to linear gamma when sampling the image in client APIs. This conversion should ideally take place before any filtering, but that is not required. The conversion from an sRGB gamma component, cs, to a linear gamma component, cl, is as follows. { cs / 12.92, cs <= 0.04045 cl = { { ((cs + 0.055)/1.055)^2.4, cs > 0.04045 Assume cs is the sRGB gamma component in the range [0,1]." Add to the list of error conditions for eglCreateImageKHR: "* If the value specified in for EGL_GAMMA_MESA is not EGL_DEFAULT_MESA, and the implementation does not support creating the specified gamma view, the error EGL_BAD_ACCESS is generated. * If the value specified in for EGL_GAMMA_MESA is EGL_sRGB_MESA, and the EGLImage source does not have red, green and blue color components, the error EGL_BAD_ACCESS is generated." Issues 1) Should creating multiple EGLImages from the same source with a different gamma view be allowed? RESOLVED: Yes. This is so applications can easily switch between using an sRGB and a linear gamma view for a single EGLImage source. Revision History Version 1, October 9, 2012 Initial draft (John Kåre Alsaker) ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] svga: Add support for 16-bit per channel RGBA
--- src/gallium/drivers/svga/svga_format.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c index 5176106..5a153a8 100644 --- a/src/gallium/drivers/svga/svga_format.c +++ b/src/gallium/drivers/svga/svga_format.c @@ -66,6 +66,9 @@ svga_translate_format(struct svga_screen *ss, case PIPE_FORMAT_B4G4R4A4_UNORM: return SVGA3D_A4R4G4B4; + case PIPE_FORMAT_R16G16B16A16_UNORM: + return SVGA3D_A16B16G16R16; + case PIPE_FORMAT_Z16_UNORM: return bind & PIPE_BIND_SAMPLER_VIEW ? ss->depth.z16 : SVGA3D_Z_D16; case PIPE_FORMAT_S8_UINT_Z24_UNORM: -- 1.7.12.2 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Adding support for sRGB KHR images to EGL
On Fri, Oct 5, 2012 at 12:41 AM, Eric Anholt wrote: > John Kåre Alsaker writes: > >> I would like add support for sRGB KHR images to EGL. This is primarily >> so Wayland compositors can create sRGB views of client buffers, but >> there's nothing preventing it from being useful in other cases. >> >> To allow this I propose a new EGL attribute which can be passed to >> eglCreateImageKHR, EGL_GAMMA_MESA. It can have two values, >> EGL_LINEAR_MESA (the default) and EGL_SRGB_MESA. These values can be >> shared with my other EGL extension proposal >> (http://lists.freedesktop.org/archives/mesa-dev/2012-September/027888.html). >> When EGL_SRGB_MESA is passed, the image must be created with a sRGB >> view or the function should return an error. >> >> To implement this in DRI for Wayland buffers it requires changes to >> the __DRIimageExtension structure. The fromPlanar function either has >> to be modified, or a new function could be introduced. > > Could you add a specification for this extension like other EGL > extensions that exist out there? I don't want to see an extension added > to the tree without that. That I can do. > > (I think you need to get new enums allocated from khronos, too. idr?) I would need to get them from somewhere. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 3/3] egl: Add MESA_image_sRGB extension.
--- include/EGL/eglmesaext.h| 7 +++ src/egl/drivers/dri2/egl_dri2.c | 32 +++- src/egl/drivers/dri2/platform_android.c | 16 ++-- src/egl/drivers/dri2/platform_drm.c | 11 +++ src/egl/drivers/dri2/platform_wayland.c | 11 +++ src/egl/drivers/dri2/platform_x11.c | 11 +++ src/egl/main/egldisplay.h | 1 + src/egl/main/eglimage.c | 6 ++ src/egl/main/eglimage.h | 3 +++ src/egl/main/eglmisc.c | 1 + 10 files changed, 96 insertions(+), 3 deletions(-) diff --git a/include/EGL/eglmesaext.h b/include/EGL/eglmesaext.h index d476d18..7fc4b65 100644 --- a/include/EGL/eglmesaext.h +++ b/include/EGL/eglmesaext.h @@ -109,6 +109,13 @@ typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDRMDISPLAYMESA) (int fd); #endif #endif +#ifndef EGL_MESA_image_sRGB +#define EGL_MESA_image_sRGB 1 +#define EGL_GAMMA_MESA 0x4534001 /* eglCreateImageKHR attribute */ +#define EGL_LINEAR_MESA 0x4534002 +#define EGL_SRGB_MESA 0x4534003 +#endif + #ifndef EGL_WL_bind_wayland_display #define EGL_WL_bind_wayland_display 1 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 4b58c35..e3263ba 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -492,6 +492,7 @@ dri2_setup_screen(_EGLDisplay *disp) disp->Extensions.MESA_drm_image = EGL_TRUE; disp->Extensions.KHR_image_base = EGL_TRUE; disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE; + disp->Extensions.MESA_image_sRGB = EGL_TRUE; } } @@ -1026,6 +1027,17 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx); GLuint renderbuffer = (GLuint) (uintptr_t) buffer; __DRIimage *dri_image; + EGLint err; + _EGLImageAttribs attrs; + + err = _eglParseImageAttribList(&attrs, disp, attr_list); + if (err != EGL_SUCCESS) + return NULL; + + if (attrs.GammaMESA != EGL_LINEAR_MESA) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + return EGL_NO_IMAGE_KHR; + } if (renderbuffer == 0) { _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); @@ -1054,6 +1066,11 @@ dri2_create_image_mesa_drm_buffer(_EGLDisplay *disp, _EGLContext *ctx, if (err != EGL_SUCCESS) return NULL; + if (attrs.GammaMESA != EGL_LINEAR_MESA) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + return EGL_NO_IMAGE_KHR; + } + if (attrs.Width <= 0 || attrs.Height <= 0 || attrs.DRMBufferStrideMESA <= 0) { _eglError(EGL_BAD_PARAMETER, @@ -1134,7 +1151,20 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx, return NULL; } - dri_image = dri2_dpy->image->fromPlanar(buffer->driver_buffer, plane, NULL); + if (attrs.GammaMESA == EGL_SRGB_MESA) { + if(dri2_dpy->image->base.version < 6) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_wayland_wl_buffer"); + return NULL; + } + + if(f->components != EGL_TEXTURE_RGB && f->components != EGL_TEXTURE_RGBA) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_wayland_wl_buffer"); + return NULL; + } + + dri_image = dri2_dpy->image->duplicateImage(dri2_dpy->dri_screen, buffer->driver_buffer, __DRI_IMAGE_FLAG_SRGB_VIEW, NULL); + } else + dri_image = dri2_dpy->image->fromPlanar(buffer->driver_buffer, plane, NULL); if (dri_image == NULL) { _eglError(EGL_BAD_PARAMETER, "dri2_create_image_wayland_wl_buffer"); diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 15bf054..87d6d40 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -280,12 +280,24 @@ droid_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) static _EGLImage * dri2_create_image_android_native_buffer(_EGLDisplay *disp, -struct ANativeWindowBuffer *buf) +struct ANativeWindowBuffer *buf, +const EGLint *attr_list) { struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); struct dri2_egl_image *dri2_img; int name; EGLint format; + EGLint err; + _EGLImageAttribs attrs; + + err = _eglParseImageAttribList(&attrs, disp, attr_list); + if (err != EGL_SUCCESS) + return NULL; + + if (attrs.GammaMESA != EGL_LINEAR_MESA) { + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); + return NULL; + } if (!buf || buf->common.magic != ANDROID_NATIVE_BUFFER_MAGIC || buf->common.version != sizeof(*buf)) { @@ -359,7 +371,7 @@ droid_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, switch (target) { case EGL_NATIVE_BUFFER_ANDROID: return dri2_create_image_android_native_buffer(disp, -
[Mesa-dev] [RFC 2/3] gallium: Implement DRIimageExtension.duplicateImage
--- src/gallium/include/state_tracker/st_api.h | 1 + src/gallium/state_trackers/dri/common/dri_screen.c | 1 + src/gallium/state_trackers/dri/common/dri_screen.h | 1 + src/gallium/state_trackers/dri/drm/dri2.c | 32 +- src/mesa/state_tracker/st_manager.c| 4 +++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h index 3a11cd4..bcdc342 100644 --- a/src/gallium/include/state_tracker/st_api.h +++ b/src/gallium/include/state_tracker/st_api.h @@ -202,6 +202,7 @@ struct st_egl_image { /* this is owned by the caller */ struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c index b76cb9a..81e61f3 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.c +++ b/src/gallium/state_trackers/dri/common/dri_screen.c @@ -328,6 +328,7 @@ dri_get_egl_image(struct st_manager *smapi, stimg->texture = NULL; pipe_resource_reference(&stimg->texture, img->texture); + stimg->format = img->format; stimg->level = img->level; stimg->layer = img->layer; diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h index ff48b02..e2aab55 100644 --- a/src/gallium/state_trackers/dri/common/dri_screen.h +++ b/src/gallium/state_trackers/dri/common/dri_screen.h @@ -83,6 +83,7 @@ dri_screen(__DRIscreen * sPriv) struct __DRIimageRec { struct pipe_resource *texture; + enum pipe_format format; unsigned level; unsigned layer; uint32_t dri_format; diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c index 78852fb..8f61c37 100755 --- a/src/gallium/state_trackers/dri/drm/dri2.c +++ b/src/gallium/state_trackers/dri/drm/dri2.c @@ -636,6 +636,7 @@ dri2_dup_image(__DRIimage *image, void *loaderPrivate) pipe_resource_reference(&img->texture, image->texture); img->level = image->level; img->layer = image->layer; + img->format = image->format; /* This should be 0 for sub images, but dup is also used for base images. */ img->dri_components = image->dri_components; img->loader_private = loaderPrivate; @@ -727,6 +728,34 @@ dri2_from_planar(__DRIimage *image, int plane, void *loaderPrivate) return img; } +static __DRIimage * +dri2_duplicate_image(__DRIscreen *_screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate) +{ + enum pipe_format format; + struct dri_screen *screen = dri_screen(_screen); + __DRIimage *img = NULL; + + if(flags == __DRI_IMAGE_FLAG_SRGB_VIEW) { + if(!image->texture) + return NULL; + + format = util_format_srgb(image->texture->format); + + if(!screen->base.screen->is_format_supported(screen->base.screen, format, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW)) + return NULL; + + img = dri2_dup_image(image, loaderPrivate); + + if (img) + img->format = format; + } else if (flags == 0) { + img = dri2_dup_image(image, loaderPrivate); + } + + return img; +} + static void dri2_destroy_image(__DRIimage *img) { @@ -735,7 +764,7 @@ dri2_destroy_image(__DRIimage *img) } static struct __DRIimageExtensionRec dri2ImageExtension = { -{ __DRI_IMAGE, 5 }, +{ __DRI_IMAGE, 6 }, dri2_create_image_from_name, dri2_create_image_from_renderbuffer, dri2_destroy_image, @@ -745,6 +774,7 @@ static struct __DRIimageExtensionRec dri2ImageExtension = { dri2_validate_usage, dri2_from_names, dri2_from_planar, +dri2_duplicate_image, }; /* diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index 88b886d..d3de42e 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -807,6 +807,10 @@ st_manager_get_egl_image_surface(struct st_context *st, return NULL; u_surface_default_template(&surf_tmpl, stimg.texture, usage); + + if(stimg.format != PIPE_FORMAT_NONE) + surf_tmpl.format = stimg.format; + surf_tmpl.u.tex.level = stimg.level; surf_tmpl.u.tex.first_layer = stimg.layer; surf_tmpl.u.tex.last_layer = stimg.layer; -- 1.7.12.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [RFC 1/3] dri: Add another duplicateImage to DRIimageExtension which allows you to create a sRGB view of a DRI image
--- include/GL/internal/dri_interface.h | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 1e0f1d0..669c7d9 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -912,7 +912,7 @@ struct __DRIdri2ExtensionRec { * extensions. */ #define __DRI_IMAGE "DRI_IMAGE" -#define __DRI_IMAGE_VERSION 5 +#define __DRI_IMAGE_VERSION 6 /** * These formats correspond to the similarly named MESA_FORMAT_* @@ -983,6 +983,14 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_COMPONENTS_Y_UV0x3004 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 +/** + * Flags for duplicateImage. + * + * \since 6 + */ + +#define __DRI_IMAGE_FLAG_SRGB_VIEW 0x0001 + /** * queryImage attributes @@ -1061,6 +1069,15 @@ struct __DRIimageExtensionRec { */ __DRIimage *(*fromPlanar)(__DRIimage *image, int plane, void *loaderPrivate); + + /** +* The new __DRIimage will share the raw content with the old one, +* but it might have a different format. +* +* \since 6 +*/ +__DRIimage *(*duplicateImage)(__DRIscreen *screen, __DRIimage *image, + unsigned int flags, void *loaderPrivate); }; -- 1.7.12.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Adding support for sRGB KHR images to EGL
I would like add support for sRGB KHR images to EGL. This is primarily so Wayland compositors can create sRGB views of client buffers, but there's nothing preventing it from being useful in other cases. To allow this I propose a new EGL attribute which can be passed to eglCreateImageKHR, EGL_GAMMA_MESA. It can have two values, EGL_LINEAR_MESA (the default) and EGL_SRGB_MESA. These values can be shared with my other EGL extension proposal (http://lists.freedesktop.org/archives/mesa-dev/2012-September/027888.html). When EGL_SRGB_MESA is passed, the image must be created with a sRGB view or the function should return an error. To implement this in DRI for Wayland buffers it requires changes to the __DRIimageExtension structure. The fromPlanar function either has to be modified, or a new function could be introduced. - John Kåre ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Adding support for sRGB framebuffers to EGL
For DRI adding a __DRIdrawable sRGB gamma attribute appears to be the way to go. There's __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE already for __DRIconfig which appears to be unused. That could be used for the capability flag. Implementing it in the gallium EGL backend seems more straightforward, once that actually works. The sorting of EGL_GAMMA_SRGB_BIT also has the desirable function that it prevents simple EGL applications using eglChooseConfig from grabbing the deepest buffer format available (which could easily be a slower 32 bpc floating point format), assuming sRGB support is available and limited to 8 bpc. On Thu, Sep 27, 2012 at 8:57 PM, John Kåre Alsaker wrote: > I failed to consider that premultiplied sRGB color channels can be > stored two ways. The friendly way, to_srgb_gamma(color * alpha) and > what applications actually use, to_srgb_gamma(color) * alpha. That > might affect this proposal. I don't think this has to involve EGL. > > On Thu, Sep 27, 2012 at 3:49 PM, Brian Paul wrote: >> Just some quick comments. >> >> I think the term "GAMMA" should be omitted. I'm no expert but I'm not sure >> that sRGB is strictly a gamma function. The GL_EXT_texture_sRGB spec says >> "The sRGB color space roughly corresponds to 2.2 gamma correction." Also, >> the term GAMMA doesn't appear in any of the existing GLenum values related >> to sRGB. > Only sRGB's gamma function is used and it is explicitly named so to > avoid confusion with the whole sRGB color space. > >> >> Therefore, I think EGL_GAMMA_SRGB_BIT should be just EGL_SRGB_BIT, >> EGL_GAMMA_LINEAR -> EGL_LINEAR, >> EGL_GAMMA_SRGB -> EGL_SRGB. >> >> For the query, you might use "COLOR_ENCODING" like >> GL_ARB_framebuffer_object. > You could use glGetFramebufferAttachmentParameter with > GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING to check if you got a sRGB > framebuffer, but you can't set it. > >> >> You could also take a look at >> http://www.opengl.org/registry/specs/EXT/framebuffer_sRGB.txt to see how >> this was handled for GLX and WGL. > This is done similarly with a capability flag in GLX/WGL, but with the > surface attribute moved into OpenGL (and it affects other > rendertargets). > >> >> -Brian >> >> >> >> On 09/26/2012 04:49 AM, John Kåre Alsaker wrote: >>> >>> EGL_GAMMA_SRGB_BIT should be changed to a boolean EGL config attribute >>> so it can be optionally sorted by eglChooseConfig. It should be sorted >>> after EGL_COLOR_BUFFER_TYPE and true values would be preferred. This >>> sorting should be optional and is done so compositing window managers >>> can sample the framebuffer as an sRGB texture. EGL_GAMMA_SRGB_BIT >>> could also optionally be disabled when the format is not supported as >>> an sRGB texture by the hardware. >>> >>> On Wed, Sep 26, 2012 at 10:19 AM, John Kåre Alsaker >>> wrote: >>>> >>>> The way this would interact with ARB_framebuffer_sRGB is that the >>>> EGL's surface EGL_GAMMA attribute would be ignored. If a EGL config >>>> has the EGL_GAMMA_SRGB_BIT, it is required to support sRGB for the >>>> default OpenGL framebuffer. >>>> >>>> On Tue, Sep 25, 2012 at 5:58 PM, John Kåre Alsaker >>>> wrote: >>>>> >>>>> Hello, >>>>> >>>>> I would like add support for sRGB framebuffers to EGL. Here are my >>>>> proposed changes to EGL: >>>>> >>>>> A new EGL_SURFACE_TYPE bit: >>>>> EGL_GAMMA_SRGB_BIT - This format supports sRGB framebuffers. This also >>>>> means that ARB_framebuffer_sRGB is supported for this format. >>>>> >>>>> New values: >>>>> EGL_GAMMA_LINEAR - The gamma is linear. >>>>> EGL_GAMMA_SRGB - The gamma is as defined by the sRGB standard. >>>>> >>>>> New EGL surface attribute: >>>>> EGL_GAMMA - The gamma of the surface's framebuffer. The default value >>>>> is EGL_GAMMA_LINEAR. >>>>> >>>>> When the surface's EGL_GAMMA attribute's value is EGL_GAMMA_SRGB and >>>>> this is supported by >>>>> the format, reads from this framebuffer will be converted from sRGB >>>>> gamma and writes will >>>>> be converted to sRGB gamma. This may not apply to all functions in the >>>>> client API. >>>>> >>>>> There may be something related to the ARB_framebuffer_sRGB ext
Re: [Mesa-dev] Adding support for sRGB framebuffers to EGL
I failed to consider that premultiplied sRGB color channels can be stored two ways. The friendly way, to_srgb_gamma(color * alpha) and what applications actually use, to_srgb_gamma(color) * alpha. That might affect this proposal. On Thu, Sep 27, 2012 at 3:49 PM, Brian Paul wrote: > Just some quick comments. > > I think the term "GAMMA" should be omitted. I'm no expert but I'm not sure > that sRGB is strictly a gamma function. The GL_EXT_texture_sRGB spec says > "The sRGB color space roughly corresponds to 2.2 gamma correction." Also, > the term GAMMA doesn't appear in any of the existing GLenum values related > to sRGB. Only sRGB's gamma function is used and it is explicitly named so to avoid confusion with the whole sRGB color space. > > Therefore, I think EGL_GAMMA_SRGB_BIT should be just EGL_SRGB_BIT, > EGL_GAMMA_LINEAR -> EGL_LINEAR, > EGL_GAMMA_SRGB -> EGL_SRGB. > > For the query, you might use "COLOR_ENCODING" like > GL_ARB_framebuffer_object. You could use glGetFramebufferAttachmentParameter with GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING to check if you got a sRGB framebuffer, but you can't set it. > > You could also take a look at > http://www.opengl.org/registry/specs/EXT/framebuffer_sRGB.txt to see how > this was handled for GLX and WGL. This is done similarly with a capability flag in GLX/WGL, but with the surface attribute moved into OpenGL (and it affects other rendertargets). > > -Brian > > > > On 09/26/2012 04:49 AM, John Kåre Alsaker wrote: >> >> EGL_GAMMA_SRGB_BIT should be changed to a boolean EGL config attribute >> so it can be optionally sorted by eglChooseConfig. It should be sorted >> after EGL_COLOR_BUFFER_TYPE and true values would be preferred. This >> sorting should be optional and is done so compositing window managers >> can sample the framebuffer as an sRGB texture. EGL_GAMMA_SRGB_BIT >> could also optionally be disabled when the format is not supported as >> an sRGB texture by the hardware. >> >> On Wed, Sep 26, 2012 at 10:19 AM, John Kåre Alsaker >> wrote: >>> >>> The way this would interact with ARB_framebuffer_sRGB is that the >>> EGL's surface EGL_GAMMA attribute would be ignored. If a EGL config >>> has the EGL_GAMMA_SRGB_BIT, it is required to support sRGB for the >>> default OpenGL framebuffer. >>> >>> On Tue, Sep 25, 2012 at 5:58 PM, John Kåre Alsaker >>> wrote: >>>> >>>> Hello, >>>> >>>> I would like add support for sRGB framebuffers to EGL. Here are my >>>> proposed changes to EGL: >>>> >>>> A new EGL_SURFACE_TYPE bit: >>>> EGL_GAMMA_SRGB_BIT - This format supports sRGB framebuffers. This also >>>> means that ARB_framebuffer_sRGB is supported for this format. >>>> >>>> New values: >>>> EGL_GAMMA_LINEAR - The gamma is linear. >>>> EGL_GAMMA_SRGB - The gamma is as defined by the sRGB standard. >>>> >>>> New EGL surface attribute: >>>> EGL_GAMMA - The gamma of the surface's framebuffer. The default value >>>> is EGL_GAMMA_LINEAR. >>>> >>>> When the surface's EGL_GAMMA attribute's value is EGL_GAMMA_SRGB and >>>> this is supported by >>>> the format, reads from this framebuffer will be converted from sRGB >>>> gamma and writes will >>>> be converted to sRGB gamma. This may not apply to all functions in the >>>> client API. >>>> >>>> There may be something related to the ARB_framebuffer_sRGB extension >>>> in EGL already, in >>>> which case someone should link me to it. >>>> >>>> There's two assumptions behind this proposal. One is that you won't >>>> support sRGB only >>>> formats. The other is that linear gamma and sRGB gamma format support >>>> is the same. >>>> This means that window systems can't add a new linear gamma format >>>> without adding an sRGB >>>> format and the other way around. >>>> >>>> I'd like some comments on this proposal and tips on how it could be >>>> implemented in the >>>> mess that is DRI. >>>> >>>> Thanks, >>>> John Kåre >> >> ___ >> mesa-dev mailing list >> mesa-dev@lists.freedesktop.org >> http://lists.freedesktop.org/mailman/listinfo/mesa-dev > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: Remove wierd code which forces non-sRGB formats.
glean/readPixSanity is failing. Depth and stencil buffers are read back wrong, while RGBA is fine. On 9/25/12, Brian Paul wrote: > On 09/24/2012 11:09 PM, John Kåre Alsaker wrote: >> On Mon, Sep 24, 2012 at 5:22 PM, Brian Paul > <mailto:bri...@vmware.com>> wrote: >> >> On 09/23/2012 05:44 AM, John Kåre Alsaker wrote: >> >> --- >>src/gallium/drivers/svga/svga_resource_texture.c | 8 >>1 file changed, 8 deletions(-) >> >> diff --git a/src/gallium/drivers/svga/svga_resource_texture.c >> b/src/gallium/drivers/svga/svga_resource_texture.c >> index 9830e79..97ec7ee 100644 >> --- a/src/gallium/drivers/svga/svga_resource_texture.c >> +++ b/src/gallium/drivers/svga/svga_resource_texture.c >> @@ -540,14 +540,6 @@ svga_texture_from_handle(struct >> pipe_screen *screen, >> pipe_reference_init(&tex->b.b.reference, 1); >> tex->b.b.screen = screen; >> >> - if (format == SVGA3D_X8R8G8B8) >> - tex->b.b.format = PIPE_FORMAT_B8G8R8X8_UNORM; >> - else if (format == SVGA3D_A8R8G8B8) >> - tex->b.b.format = PIPE_FORMAT_B8G8R8A8_UNORM; >> - else { >> - /* ?? */ >> - } >> - >> SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf); >> >> tex->key.cachable = 0; >> >> >> Yeah, I don't know what that's all about either. Have you done a >> piglit run with this change to check for regressions? >> >> Piglit doesn't pass the sanity tests with Mesa master. Are there any >> tests for shared handles in there? > > There's only two tests in sanity.tests (glean/readPixSanity and > glean/basic) and they both pass for me with the VMware svga driver. > > What exactly is your command line and what's the output? > > In any case, the sanity.tests group isn't enough. A full piglit run > would be run with something like this: > > ./piglit_run.py tests.all.tests results > > I'll run the test here but you might want to do more investigation on > your side to see why the sanity tests aren't passing. > > -Brian > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Adding support for sRGB framebuffers to EGL
EGL_GAMMA_SRGB_BIT should be changed to a boolean EGL config attribute so it can be optionally sorted by eglChooseConfig. It should be sorted after EGL_COLOR_BUFFER_TYPE and true values would be preferred. This sorting should be optional and is done so compositing window managers can sample the framebuffer as an sRGB texture. EGL_GAMMA_SRGB_BIT could also optionally be disabled when the format is not supported as an sRGB texture by the hardware. On Wed, Sep 26, 2012 at 10:19 AM, John Kåre Alsaker wrote: > The way this would interact with ARB_framebuffer_sRGB is that the > EGL's surface EGL_GAMMA attribute would be ignored. If a EGL config > has the EGL_GAMMA_SRGB_BIT, it is required to support sRGB for the > default OpenGL framebuffer. > > On Tue, Sep 25, 2012 at 5:58 PM, John Kåre Alsaker > wrote: >> Hello, >> >> I would like add support for sRGB framebuffers to EGL. Here are my >> proposed changes to EGL: >> >> A new EGL_SURFACE_TYPE bit: >> EGL_GAMMA_SRGB_BIT - This format supports sRGB framebuffers. This also >> means that ARB_framebuffer_sRGB is supported for this format. >> >> New values: >> EGL_GAMMA_LINEAR - The gamma is linear. >> EGL_GAMMA_SRGB - The gamma is as defined by the sRGB standard. >> >> New EGL surface attribute: >> EGL_GAMMA - The gamma of the surface's framebuffer. The default value >> is EGL_GAMMA_LINEAR. >> >> When the surface's EGL_GAMMA attribute's value is EGL_GAMMA_SRGB and >> this is supported by >> the format, reads from this framebuffer will be converted from sRGB >> gamma and writes will >> be converted to sRGB gamma. This may not apply to all functions in the >> client API. >> >> There may be something related to the ARB_framebuffer_sRGB extension >> in EGL already, in >> which case someone should link me to it. >> >> There's two assumptions behind this proposal. One is that you won't >> support sRGB only >> formats. The other is that linear gamma and sRGB gamma format support >> is the same. >> This means that window systems can't add a new linear gamma format >> without adding an sRGB >> format and the other way around. >> >> I'd like some comments on this proposal and tips on how it could be >> implemented in the >> mess that is DRI. >> >> Thanks, >> John Kåre ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] Adding support for sRGB framebuffers to EGL
The way this would interact with ARB_framebuffer_sRGB is that the EGL's surface EGL_GAMMA attribute would be ignored. If a EGL config has the EGL_GAMMA_SRGB_BIT, it is required to support sRGB for the default OpenGL framebuffer. On Tue, Sep 25, 2012 at 5:58 PM, John Kåre Alsaker wrote: > Hello, > > I would like add support for sRGB framebuffers to EGL. Here are my > proposed changes to EGL: > > A new EGL_SURFACE_TYPE bit: > EGL_GAMMA_SRGB_BIT - This format supports sRGB framebuffers. This also > means that ARB_framebuffer_sRGB is supported for this format. > > New values: > EGL_GAMMA_LINEAR - The gamma is linear. > EGL_GAMMA_SRGB - The gamma is as defined by the sRGB standard. > > New EGL surface attribute: > EGL_GAMMA - The gamma of the surface's framebuffer. The default value > is EGL_GAMMA_LINEAR. > > When the surface's EGL_GAMMA attribute's value is EGL_GAMMA_SRGB and > this is supported by > the format, reads from this framebuffer will be converted from sRGB > gamma and writes will > be converted to sRGB gamma. This may not apply to all functions in the > client API. > > There may be something related to the ARB_framebuffer_sRGB extension > in EGL already, in > which case someone should link me to it. > > There's two assumptions behind this proposal. One is that you won't > support sRGB only > formats. The other is that linear gamma and sRGB gamma format support > is the same. > This means that window systems can't add a new linear gamma format > without adding an sRGB > format and the other way around. > > I'd like some comments on this proposal and tips on how it could be > implemented in the > mess that is DRI. > > Thanks, > John Kåre ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] Adding support for sRGB framebuffers to EGL
Hello, I would like add support for sRGB framebuffers to EGL. Here are my proposed changes to EGL: A new EGL_SURFACE_TYPE bit: EGL_GAMMA_SRGB_BIT - This format supports sRGB framebuffers. This also means that ARB_framebuffer_sRGB is supported for this format. New values: EGL_GAMMA_LINEAR - The gamma is linear. EGL_GAMMA_SRGB - The gamma is as defined by the sRGB standard. New EGL surface attribute: EGL_GAMMA - The gamma of the surface's framebuffer. The default value is EGL_GAMMA_LINEAR. When the surface's EGL_GAMMA attribute's value is EGL_GAMMA_SRGB and this is supported by the format, reads from this framebuffer will be converted from sRGB gamma and writes will be converted to sRGB gamma. This may not apply to all functions in the client API. There may be something related to the ARB_framebuffer_sRGB extension in EGL already, in which case someone should link me to it. There's two assumptions behind this proposal. One is that you won't support sRGB only formats. The other is that linear gamma and sRGB gamma format support is the same. This means that window systems can't add a new linear gamma format without adding an sRGB format and the other way around. I'd like some comments on this proposal and tips on how it could be implemented in the mess that is DRI. Thanks, John Kåre ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] svga: Remove wierd code which forces non-sRGB formats.
On Mon, Sep 24, 2012 at 5:22 PM, Brian Paul wrote: > On 09/23/2012 05:44 AM, John Kåre Alsaker wrote: > >> --- >> src/gallium/drivers/svga/svga_resource_texture.c | 8 >> 1 file changed, 8 deletions(-) >> >> diff --git a/src/gallium/drivers/svga/svga_resource_texture.c >> b/src/gallium/drivers/svga/svga_resource_texture.c >> index 9830e79..97ec7ee 100644 >> --- a/src/gallium/drivers/svga/svga_resource_texture.c >> +++ b/src/gallium/drivers/svga/svga_resource_texture.c >> @@ -540,14 +540,6 @@ svga_texture_from_handle(struct pipe_screen *screen, >> pipe_reference_init(&tex->b.b.reference, 1); >> tex->b.b.screen = screen; >> >> - if (format == SVGA3D_X8R8G8B8) >> - tex->b.b.format = PIPE_FORMAT_B8G8R8X8_UNORM; >> - else if (format == SVGA3D_A8R8G8B8) >> - tex->b.b.format = PIPE_FORMAT_B8G8R8A8_UNORM; >> - else { >> - /* ?? */ >> - } >> - >> SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf); >> >> tex->key.cachable = 0; >> > > Yeah, I don't know what that's all about either. Have you done a piglit > run with this change to check for regressions? Piglit doesn't pass the sanity tests with Mesa master. Are there any tests for shared handles in there? > > > -Brian > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] svga: Remove wierd code which forces non-sRGB formats.
--- src/gallium/drivers/svga/svga_resource_texture.c | 8 1 file changed, 8 deletions(-) diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 9830e79..97ec7ee 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -540,14 +540,6 @@ svga_texture_from_handle(struct pipe_screen *screen, pipe_reference_init(&tex->b.b.reference, 1); tex->b.b.screen = screen; - if (format == SVGA3D_X8R8G8B8) - tex->b.b.format = PIPE_FORMAT_B8G8R8X8_UNORM; - else if (format == SVGA3D_A8R8G8B8) - tex->b.b.format = PIPE_FORMAT_B8G8R8A8_UNORM; - else { - /* ?? */ - } - SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf); tex->key.cachable = 0; -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH] llvmpipe: Fix creation of shared and scanout textures
--- src/gallium/drivers/llvmpipe/lp_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 841df00..df4417f 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -287,7 +287,9 @@ llvmpipe_resource_create(struct pipe_screen *_screen, /* assert(lpr->base.bind); */ if (resource_is_texture(&lpr->base)) { - if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) { + if (lpr->base.bind & (PIPE_BIND_DISPLAY_TARGET | +PIPE_BIND_SCANOUT | +PIPE_BIND_SHARED)) { /* displayable surface */ if (!llvmpipe_displaytarget_layout(screen, lpr)) goto fail; -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 4/4] gbm: Removed usage of gbm_bo_format from Gallium backend.
--- src/gallium/state_trackers/gbm/gbm_drm.c | 44 +--- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/gallium/state_trackers/gbm/gbm_drm.c b/src/gallium/state_trackers/gbm/gbm_drm.c index 8490480..9f2cfe8 100644 --- a/src/gallium/state_trackers/gbm/gbm_drm.c +++ b/src/gallium/state_trackers/gbm/gbm_drm.c @@ -41,18 +41,37 @@ #endif static INLINE enum pipe_format -gbm_format_to_gallium(enum gbm_bo_format format) +gbm_format_to_gallium(uint32_t format) { switch (format) { - case GBM_BO_FORMAT_XRGB: + case GBM_FORMAT_XRGB: return PIPE_FORMAT_B8G8R8X8_UNORM; - case GBM_BO_FORMAT_ARGB: + case GBM_FORMAT_ARGB: return PIPE_FORMAT_B8G8R8A8_UNORM; + case GBM_FORMAT_ARGB_SRGB: + return PIPE_FORMAT_B8G8R8X8_SRGB; + case GBM_FORMAT_XRGB_SRGB: + return PIPE_FORMAT_B8G8R8A8_SRGB; default: return PIPE_FORMAT_NONE; } +} - return PIPE_FORMAT_NONE; +static INLINE uint32_t +gbm_format_from_gallium(enum pipe_format format) +{ + switch (format) { + case PIPE_FORMAT_B8G8R8X8_UNORM: + return GBM_FORMAT_XRGB; + case PIPE_FORMAT_B8G8R8A8_UNORM: + return GBM_FORMAT_ARGB; + case PIPE_FORMAT_B8G8R8X8_SRGB: + return GBM_FORMAT_ARGB_SRGB; + case PIPE_FORMAT_B8G8R8A8_SRGB: + return GBM_FORMAT_XRGB_SRGB; + default: + return PIPE_FORMAT_NONE; + } } static INLINE uint @@ -74,7 +93,7 @@ gbm_usage_to_gallium(uint usage) static int gbm_gallium_drm_is_format_supported(struct gbm_device *gbm, -enum gbm_bo_format format, +uint32_t format, uint32_t usage) { struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); @@ -88,7 +107,7 @@ gbm_gallium_drm_is_format_supported(struct gbm_device *gbm, gbm_usage_to_gallium(usage))) return 0; - if (usage & GBM_BO_USE_SCANOUT && format != GBM_BO_FORMAT_XRGB) + if (usage & GBM_BO_USE_SCANOUT && format != GBM_FORMAT_XRGB) return 0; return 1; @@ -144,14 +163,9 @@ gbm_gallium_drm_bo_import(struct gbm_device *gbm, bo->base.base.width = resource->width0; bo->base.base.height = resource->height0; - switch (resource->format) { - case PIPE_FORMAT_B8G8R8X8_UNORM: - bo->base.base.format = GBM_BO_FORMAT_XRGB; - break; - case PIPE_FORMAT_B8G8R8A8_UNORM: - bo->base.base.format = GBM_BO_FORMAT_ARGB; - break; - default: + bo->base.base.format = gbm_format_from_gallium(resource->format); + + if (bo->base.base.format == GBM_FORMAT_NONE) { FREE(bo); return NULL; } @@ -171,7 +185,7 @@ gbm_gallium_drm_bo_import(struct gbm_device *gbm, static struct gbm_bo * gbm_gallium_drm_bo_create(struct gbm_device *gbm, uint32_t width, uint32_t height, - enum gbm_bo_format format, uint32_t usage) + uint32_t format, uint32_t usage) { struct gbm_gallium_drm_device *gdrm = gbm_gallium_drm_device(gbm); struct gbm_gallium_drm_bo *bo; -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 3/4] gbm: Removed usage of gbm_bo_format from DRI backend.
--- src/gbm/backends/dri/gbm_dri.c | 4 1 file changed, 4 deletions(-) diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c index d8b1cc7..84c6de3 100644 --- a/src/gbm/backends/dri/gbm_dri.c +++ b/src/gbm/backends/dri/gbm_dri.c @@ -277,10 +277,8 @@ gbm_dri_is_format_supported(struct gbm_device *gbm, uint32_t usage) { switch (format) { - case GBM_BO_FORMAT_XRGB: case GBM_FORMAT_XRGB: break; - case GBM_BO_FORMAT_ARGB: case GBM_FORMAT_ARGB: if (usage & GBM_BO_USE_SCANOUT) return 0; @@ -494,11 +492,9 @@ gbm_dri_bo_create(struct gbm_device *gbm, dri_format =__DRI_IMAGE_FORMAT_RGB565; break; case GBM_FORMAT_XRGB: - case GBM_BO_FORMAT_XRGB: dri_format = __DRI_IMAGE_FORMAT_XRGB; break; case GBM_FORMAT_ARGB: - case GBM_BO_FORMAT_ARGB: dri_format = __DRI_IMAGE_FORMAT_ARGB; break; case GBM_FORMAT_ABGR: -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/4] gbm: Remove gbm_bo_format and add GBM_FORMAT_NONE.
--- src/gbm/main/gbm.h | 10 ++ 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h index 32211a7..1bc4740 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -68,19 +68,13 @@ union gbm_bo_handle { uint64_t u64; }; -/** Format of the allocated buffer */ -enum gbm_bo_format { - /** RGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_XRGB, - /** ARGB with 8 bits per channel in a 32 bit value */ - GBM_BO_FORMAT_ARGB -}; - #define __gbm_fourcc_code(a,b,c,d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | \ ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24)) #define GBM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */ +#define GBM_FORMAT_NONE 0 + /* color index */ #define GBM_FORMAT_C8 __gbm_fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 1/4] gbm: Add sRGB formats.
--- src/gbm/main/gbm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h index 9d2a030..32211a7 100644 --- a/src/gbm/main/gbm.h +++ b/src/gbm/main/gbm.h @@ -127,6 +127,9 @@ enum gbm_bo_format { #define GBM_FORMAT_RGBA__gbm_fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ #define GBM_FORMAT_BGRA__gbm_fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ +#define GBM_FORMAT_XRGB_SRGB __gbm_fourcc_code('X', 'r', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian with sRGB gamma */ +#define GBM_FORMAT_ARGB_SRGB __gbm_fourcc_code('A', 'r', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian with sRGB gamma for color components */ + #define GBM_FORMAT_XRGB2101010 __gbm_fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ #define GBM_FORMAT_XBGR2101010 __gbm_fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ #define GBM_FORMAT_RGBX1010102 __gbm_fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ -- 1.7.12 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev