diff options
author | Topi Pohjolainen <[email protected]> | 2013-06-18 13:47:43 +0300 |
---|---|---|
committer | Topi Pohjolainen <[email protected]> | 2013-08-02 08:56:03 +0300 |
commit | 3a52cd351af6ad834fa6205ec03a82559d1cea92 (patch) | |
tree | 6537adb4d0aa12d14576e52ec22c94208cbdc517 /src/mesa | |
parent | 0de013b61930505bbeaf094d079b566df18a0cf7 (diff) |
intel: restrict dma-buf-import images to external sampling only
Memory originating outside mesa stack is meant to be for reading
only. In addition, the restrictions imposed by the image external
extension should apply. For example, users shouldn't be allowed
to generare mip-trees based on these images.
v2 (Chad): document using full extension names, fix the comment
style itself and emit description of error
Signed-off-by: Topi Pohjolainen <[email protected]>
Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_fbo.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_regions.h | 9 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_tex_image.c | 11 |
4 files changed, 27 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_fbo.c b/src/mesa/drivers/dri/i965/intel_fbo.c index 059b3eac492..45409046c5c 100644 --- a/src/mesa/drivers/dri/i965/intel_fbo.c +++ b/src/mesa/drivers/dri/i965/intel_fbo.c @@ -268,6 +268,13 @@ intel_image_target_renderbuffer_storage(struct gl_context *ctx, return; } + /* Buffers originating from outside are for read-only. */ + if (image->dma_buf_imported) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetRenderbufferStorage(dma buffers are read-only)"); + return; + } + /* __DRIimage is opaque to the core so it has to be checked here */ switch (image->format) { case MESA_FORMAT_RGBA8888_REV: diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h index ebb54886ac2..f08a113c936 100644 --- a/src/mesa/drivers/dri/i965/intel_regions.h +++ b/src/mesa/drivers/dri/i965/intel_regions.h @@ -150,7 +150,14 @@ struct __DRIimageRec { GLuint tile_y; bool has_depthstencil; - /* Provided by EGL_EXT_image_dma_buf_import */ + /** + * Provided by EGL_EXT_image_dma_buf_import. + * + * The flag is set in order to restrict the use of the image later on. + * + * See intel_image_target_texture_2d() + */ + bool dma_buf_imported; enum __DRIYUVColorSpace yuv_color_space; enum __DRISampleRange sample_range; enum __DRIChromaSiting horizontal_siting; diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 12a96c03f73..4ee86026574 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -719,6 +719,7 @@ intel_create_image_from_dma_bufs(__DRIscreen *screen, return NULL; } + image->dma_buf_imported = true; image->yuv_color_space = yuv_color_space; image->sample_range = sample_range; image->horizontal_siting = horizontal_siting; diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c index 4b551b7c5d0..178541d89bd 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_image.c +++ b/src/mesa/drivers/dri/i965/intel_tex_image.c @@ -368,6 +368,17 @@ intel_image_target_texture_2d(struct gl_context *ctx, GLenum target, if (image == NULL) return; + /** + * Images originating via EGL_EXT_image_dma_buf_import can be used only + * with GL_OES_EGL_image_external only. + */ + if (image->dma_buf_imported && target != GL_TEXTURE_EXTERNAL_OES) { + _mesa_error(ctx, GL_INVALID_OPERATION, + "glEGLImageTargetTexture2DOES(dma buffers can be used with " + "GL_OES_EGL_image_external only"); + return; + } + /* Disallow depth/stencil textures: we don't have a way to pass the * separate stencil miptree of a GL_DEPTH_STENCIL texture through. */ |