diff options
author | Emil Velikov <[email protected]> | 2017-06-29 00:35:56 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-07-12 15:44:26 +0100 |
commit | 962110fa57a5876b523491b701ebe68aa6eb731b (patch) | |
tree | 476d951ce69a8f5ff0e0adf9ce105d8fd5f6915f /src/egl/drivers | |
parent | a2ae8e6076cfdb4b3100d5d7c444c2f8ed68f5f5 (diff) |
egl: enhance KHR_gl_image extensions checks
Drop the (duplicate) top-level check in dri2_create_image_khr() and add
the respective checks in dri2_create_image_khr_{texture,renderbuffer}
v2: use unreachable instead of assert in dri2_create_image_khr_texture
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl/drivers')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index a641d774523..f8cadfaf8c8 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1682,6 +1682,11 @@ dri2_create_image_khr_renderbuffer(_EGLDisplay *disp, _EGLContext *ctx, return EGL_NO_IMAGE_KHR; } + if (!disp->Extensions.KHR_gl_renderbuffer_image) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + return EGL_NO_IMAGE_KHR; + } + dri_image = dri2_dpy->image->createImageFromRenderbuffer(dri2_ctx->dri_context, renderbuffer, NULL); @@ -1820,30 +1825,38 @@ dri2_create_image_khr_texture(_EGLDisplay *disp, _EGLContext *ctx, switch (target) { case EGL_GL_TEXTURE_2D_KHR: + if (!disp->Extensions.KHR_gl_texture_2D_image) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + return EGL_NO_IMAGE_KHR; + } depth = 0; gl_target = GL_TEXTURE_2D; break; case EGL_GL_TEXTURE_3D_KHR: - if (disp->Extensions.KHR_gl_texture_3D_image) { - depth = attrs.GLTextureZOffset; - gl_target = GL_TEXTURE_3D; - break; - } - else { + if (!disp->Extensions.KHR_gl_texture_3D_image) { _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); return EGL_NO_IMAGE_KHR; } + + depth = attrs.GLTextureZOffset; + gl_target = GL_TEXTURE_3D; + break; case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR: + if (!disp->Extensions.KHR_gl_texture_cubemap_image) { + _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + return EGL_NO_IMAGE_KHR; + } + depth = target - EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR; gl_target = GL_TEXTURE_CUBE_MAP; break; default: - _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); + unreachable("Unexpected target in dri2_create_image_khr_texture()"); return EGL_NO_IMAGE_KHR; } @@ -2447,15 +2460,8 @@ dri2_create_image_khr(_EGLDriver *drv, _EGLDisplay *disp, case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR: case EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR: case EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR: - return dri2_create_image_khr_texture(disp, ctx, target, buffer, attr_list); case EGL_GL_TEXTURE_3D_KHR: - if (disp->Extensions.KHR_gl_texture_3D_image) { - return dri2_create_image_khr_texture(disp, ctx, target, buffer, attr_list); - } - else { - _eglError(EGL_BAD_PARAMETER, "dri2_create_image_khr"); - return EGL_NO_IMAGE_KHR; - } + return dri2_create_image_khr_texture(disp, ctx, target, buffer, attr_list); case EGL_GL_RENDERBUFFER_KHR: return dri2_create_image_khr_renderbuffer(disp, ctx, buffer, attr_list); #ifdef HAVE_LIBDRM |