st/dri: implement createImageFromRenderbuffer(2)
Tested with dEQP-EGL.functional.image.*renderbuffer* tests. Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
4ec2ac11bd
commit
e14fe41e0b
|
@ -1561,7 +1561,7 @@ dri2_get_capabilities(__DRIscreen *_screen)
|
||||||
|
|
||||||
/* The extension is modified during runtime if DRI_PRIME is detected */
|
/* The extension is modified during runtime if DRI_PRIME is detected */
|
||||||
static __DRIimageExtension dri2ImageExtension = {
|
static __DRIimageExtension dri2ImageExtension = {
|
||||||
.base = { __DRI_IMAGE, 15 },
|
.base = { __DRI_IMAGE, 17 },
|
||||||
|
|
||||||
.createImageFromName = dri2_create_image_from_name,
|
.createImageFromName = dri2_create_image_from_name,
|
||||||
.createImageFromRenderbuffer = dri2_create_image_from_renderbuffer,
|
.createImageFromRenderbuffer = dri2_create_image_from_renderbuffer,
|
||||||
|
@ -1579,6 +1579,12 @@ static __DRIimageExtension dri2ImageExtension = {
|
||||||
.getCapabilities = dri2_get_capabilities,
|
.getCapabilities = dri2_get_capabilities,
|
||||||
.mapImage = dri2_map_image,
|
.mapImage = dri2_map_image,
|
||||||
.unmapImage = dri2_unmap_image,
|
.unmapImage = dri2_unmap_image,
|
||||||
|
.createImageWithModifiers = NULL,
|
||||||
|
.createImageFromDmaBufs2 = NULL,
|
||||||
|
.queryDmaBufFormats = NULL,
|
||||||
|
.queryDmaBufModifiers = NULL,
|
||||||
|
.queryDmaBufFormatModifierAttribs = NULL,
|
||||||
|
.createImageFromRenderbuffer2 = dri2_create_image_from_renderbuffer2,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const __DRIrobustnessExtension dri2Robustness = {
|
static const __DRIrobustnessExtension dri2Robustness = {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "pipe/p_screen.h"
|
#include "pipe/p_screen.h"
|
||||||
#include "state_tracker/st_texture.h"
|
#include "state_tracker/st_texture.h"
|
||||||
#include "state_tracker/st_context.h"
|
#include "state_tracker/st_context.h"
|
||||||
|
#include "state_tracker/st_cb_fbo.h"
|
||||||
#include "main/texobj.h"
|
#include "main/texobj.h"
|
||||||
|
|
||||||
#include "dri_helpers.h"
|
#include "dri_helpers.h"
|
||||||
|
@ -245,17 +246,69 @@ dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__DRIimage *
|
||||||
|
dri2_create_image_from_renderbuffer2(__DRIcontext *context,
|
||||||
|
int renderbuffer, void *loaderPrivate,
|
||||||
|
unsigned *error)
|
||||||
|
{
|
||||||
|
struct gl_context *ctx = ((struct st_context *)dri_context(context)->st)->ctx;
|
||||||
|
struct gl_renderbuffer *rb;
|
||||||
|
struct pipe_resource *tex;
|
||||||
|
__DRIimage *img;
|
||||||
|
|
||||||
|
/* Section 3.9 (EGLImage Specification and Management) of the EGL 1.5
|
||||||
|
* specification says:
|
||||||
|
*
|
||||||
|
* "If target is EGL_GL_RENDERBUFFER and buffer is not the name of a
|
||||||
|
* renderbuffer object, or if buffer is the name of a multisampled
|
||||||
|
* renderbuffer object, the error EGL_BAD_PARAMETER is generated."
|
||||||
|
*
|
||||||
|
* "If target is EGL_GL_TEXTURE_2D , EGL_GL_TEXTURE_CUBE_MAP_*,
|
||||||
|
* EGL_GL_RENDERBUFFER or EGL_GL_TEXTURE_3D and buffer refers to the
|
||||||
|
* default GL texture object (0) for the corresponding GL target, the
|
||||||
|
* error EGL_BAD_PARAMETER is generated."
|
||||||
|
* (rely on _mesa_lookup_renderbuffer returning NULL in this case)
|
||||||
|
*/
|
||||||
|
rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
|
||||||
|
if (!rb || rb->NumSamples > 0) {
|
||||||
|
*error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
tex = st_get_renderbuffer_resource(rb);
|
||||||
|
if (!tex) {
|
||||||
|
*error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
img = CALLOC_STRUCT(__DRIimageRec);
|
||||||
|
if (!img) {
|
||||||
|
*error = __DRI_IMAGE_ERROR_BAD_ALLOC;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
img->dri_format = driGLFormatToImageFormat(rb->Format);
|
||||||
|
img->loader_private = loaderPrivate;
|
||||||
|
|
||||||
|
if (img->dri_format == __DRI_IMAGE_FORMAT_NONE) {
|
||||||
|
*error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
|
||||||
|
free(img);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pipe_resource_reference(&img->texture, tex);
|
||||||
|
|
||||||
|
*error = __DRI_IMAGE_ERROR_SUCCESS;
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
||||||
__DRIimage *
|
__DRIimage *
|
||||||
dri2_create_image_from_renderbuffer(__DRIcontext *context,
|
dri2_create_image_from_renderbuffer(__DRIcontext *context,
|
||||||
int renderbuffer, void *loaderPrivate)
|
int renderbuffer, void *loaderPrivate)
|
||||||
{
|
{
|
||||||
struct dri_context *ctx = dri_context(context);
|
unsigned error;
|
||||||
|
return dri2_create_image_from_renderbuffer2(context, renderbuffer,
|
||||||
if (!ctx->st->get_resource_for_egl_image)
|
loaderPrivate, &error);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -35,6 +35,11 @@ __DRIimage *
|
||||||
dri2_create_image_from_renderbuffer(__DRIcontext *context,
|
dri2_create_image_from_renderbuffer(__DRIcontext *context,
|
||||||
int renderbuffer, void *loaderPrivate);
|
int renderbuffer, void *loaderPrivate);
|
||||||
|
|
||||||
|
__DRIimage *
|
||||||
|
dri2_create_image_from_renderbuffer2(__DRIcontext *context,
|
||||||
|
int renderbuffer, void *loaderPrivate,
|
||||||
|
unsigned *error);
|
||||||
|
|
||||||
void
|
void
|
||||||
dri2_destroy_image(__DRIimage *img);
|
dri2_destroy_image(__DRIimage *img);
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,11 @@ st_renderbuffer(struct gl_renderbuffer *rb)
|
||||||
return (struct st_renderbuffer *) rb;
|
return (struct st_renderbuffer *) rb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct pipe_resource *
|
||||||
|
st_get_renderbuffer_resource(struct gl_renderbuffer *rb)
|
||||||
|
{
|
||||||
|
return st_renderbuffer(rb)->texture;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
|
* Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
|
||||||
|
|
Loading…
Reference in New Issue