i965/vec4: Make with_writemask() non-static.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_tex_image.c
index 15015dd6d064b259d239cceaf277b60abc3ba5a5..f270862b65dfe20d35aaeca6afdb7dc9f6ae601d 100644 (file)
@@ -113,7 +113,6 @@ try_pbo_upload(struct gl_context *ctx,
               GLenum format, GLenum type, const void *pixels)
 {
    struct intel_texture_image *intelImage = intel_texture_image(image);
-   struct intel_context *intel = intel_context(ctx);
    struct brw_context *brw = brw_context(ctx);
    struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
    GLuint src_offset;
@@ -124,8 +123,7 @@ try_pbo_upload(struct gl_context *ctx,
 
    DBG("trying pbo upload\n");
 
-   if (intel->ctx._ImageTransferState ||
-       unpack->SkipPixels || unpack->SkipRows) {
+   if (ctx->_ImageTransferState || unpack->SkipPixels || unpack->SkipRows) {
       DBG("%s: image transfer\n", __FUNCTION__);
       return false;
    }
@@ -175,6 +173,7 @@ try_pbo_upload(struct gl_context *ctx,
                            0, 0, false,
                            image->Width, image->Height, GL_COPY)) {
       DBG("%s: blit failed\n", __FUNCTION__);
+      intel_miptree_release(&pbo_mt);
       return false;
    }
 
@@ -241,14 +240,13 @@ intel_set_texture_image_region(struct gl_context *ctx,
                                GLuint tile_x,
                                GLuint tile_y)
 {
-   struct intel_context *intel = intel_context(ctx);
    struct brw_context *brw = brw_context(ctx);
    struct intel_texture_image *intel_image = intel_texture_image(image);
    struct gl_texture_object *texobj = image->TexObject;
    struct intel_texture_object *intel_texobj = intel_texture_object(texobj);
    uint32_t draw_x, draw_y;
 
-   _mesa_init_teximage_fields(&intel->ctx, image,
+   _mesa_init_teximage_fields(&brw->ctx, image,
                              width, height, 1,
                              0, internalFormat, format);
 
@@ -296,8 +294,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 {
    struct gl_framebuffer *fb = dPriv->driverPrivate;
    struct brw_context *brw = pDRICtx->driverPrivate;
-   struct intel_context *intel = &brw->intel;
-   struct gl_context *ctx = &intel->ctx;
+   struct gl_context *ctx = &brw->ctx;
    struct intel_texture_object *intelObj;
    struct intel_renderbuffer *rb;
    struct gl_texture_object *texObj;
@@ -311,7 +308,8 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
    if (!intelObj)
       return;
 
-   if (dPriv->lastStamp != dPriv->dri2.stamp)
+   if (dPriv->lastStamp != dPriv->dri2.stamp ||
+       !pDRICtx->driScreenPriv->dri2.useInvalidate)
       intel_update_renderbuffers(pDRICtx, dPriv);
 
    rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
@@ -335,7 +333,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
       texFormat = MESA_FORMAT_RGB565;
    }
 
-   _mesa_lock_texture(&intel->ctx, texObj);
+   _mesa_lock_texture(&brw->ctx, texObj);
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
    intel_miptree_make_shareable(brw, rb->mt);
    intel_set_texture_image_region(ctx, texImage, rb->mt->region, target,
@@ -343,7 +341,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
                                   rb->mt->region->width,
                                   rb->mt->region->height,
                                   0, 0);
-   _mesa_unlock_texture(&intel->ctx, texObj);
+   _mesa_unlock_texture(&brw->ctx, texObj);
 }
 
 void
@@ -371,6 +369,24 @@ 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;
+   }
+
+   if (target == GL_TEXTURE_EXTERNAL_OES && !image->dma_buf_imported) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+            "glEGLImageTargetTexture2DOES(external target is enabled only "
+               "for images created with EGL_EXT_image_dma_buf_import");
+      return;
+   }
+
    /* Disallow depth/stencil textures: we don't have a way to pass the
     * separate stencil miptree of a GL_DEPTH_STENCIL texture through.
     */