summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Wilson <[email protected]>2017-01-10 21:23:24 +0000
committerKenneth Graunke <[email protected]>2017-02-15 17:00:42 -0800
commited442ee39b4e2a2e25ea4ccd880e4bded9d29a51 (patch)
tree93c531ee40829bf5040816e740f9c7f898d42743 /src
parenta1891da7c865c80d95c450abfc0d2bc49db5f678 (diff)
i965: Do not use purged bo after calling glObjectUnpurgeable
If the buffer has been freed by the kernel under memory pressure, it is invalid to try and access the backing storage for that buffer in the future - the backing storage is not recreated automatically. As such we need to mark the GL object as being freed for unretained buffers and so recreate the object on next use. Futhermore from the GL_APPLE_object_purgeable: "In contrast, by calling ObjectUnpurgeableAPPLE with an <option> of UNDEFINED_APPLE, the application is indicating that it intends to recreate the contents of the storage from scratch. Further, the application is is stating that it would like the GL to do only the minimal amount of work set PURGEABLE_APPLE to FALSE. If ObjectUnpurgeableAPPLE is called with the <option> set to UNDEFINED_APPLE, then ObjectUnpurgeableAPPLE will return the value UNDEFINED_APPLE." we must always report GL_UNDEFINED_APPLE when called with glObjectUnpurgeable(GL_UNDEFINED_APPLE). Testcase: piglit/object_purgeable-api-* Signed-off-by: Chris Wilson <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_object_purgeable.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_object_purgeable.c b/src/mesa/drivers/dri/i965/brw_object_purgeable.c
index 20f66f229c3..d3dba8c0af0 100644
--- a/src/mesa/drivers/dri/i965/brw_object_purgeable.c
+++ b/src/mesa/drivers/dri/i965/brw_object_purgeable.c
@@ -100,8 +100,8 @@ intel_render_object_purgeable(struct gl_context * ctx,
return intel_buffer_purgeable(intel->mt->bo);
}
-static GLenum
-intel_buffer_unpurgeable(drm_intel_bo *buffer)
+static int
+intel_bo_unpurgeable(drm_intel_bo *buffer)
{
int retained;
@@ -109,7 +109,7 @@ intel_buffer_unpurgeable(drm_intel_bo *buffer)
if (buffer != NULL)
retained = drm_intel_bo_madvise(buffer, I915_MADV_WILLNEED);
- return retained ? GL_RETAINED_APPLE : GL_UNDEFINED_APPLE;
+ return retained;
}
static GLenum
@@ -117,10 +117,20 @@ intel_buffer_object_unpurgeable(struct gl_context * ctx,
struct gl_buffer_object *obj,
GLenum option)
{
+ struct intel_buffer_object *intel = intel_buffer_object(obj);
+
(void) ctx;
- (void) option;
- return intel_buffer_unpurgeable(intel_buffer_object(obj)->buffer);
+ if (!intel->buffer)
+ return GL_UNDEFINED_APPLE;
+
+ if (option == GL_UNDEFINED_APPLE || !intel_bo_unpurgeable(intel->buffer)) {
+ drm_intel_bo_unreference(intel->buffer);
+ intel->buffer = NULL;
+ return GL_UNDEFINED_APPLE;
+ }
+
+ return GL_RETAINED_APPLE;
}
static GLenum
@@ -131,13 +141,17 @@ intel_texture_object_unpurgeable(struct gl_context * ctx,
struct intel_texture_object *intel;
(void) ctx;
- (void) option;
intel = intel_texture_object(obj);
if (intel->mt == NULL || intel->mt->bo == NULL)
return GL_UNDEFINED_APPLE;
- return intel_buffer_unpurgeable(intel->mt->bo);
+ if (option == GL_UNDEFINED_APPLE || !intel_bo_unpurgeable(intel->mt->bo)) {
+ intel_miptree_release(&intel->mt);
+ return GL_UNDEFINED_APPLE;
+ }
+
+ return GL_RETAINED_APPLE;
}
static GLenum
@@ -148,13 +162,17 @@ intel_render_object_unpurgeable(struct gl_context * ctx,
struct intel_renderbuffer *intel;
(void) ctx;
- (void) option;
intel = intel_renderbuffer(obj);
if (intel->mt == NULL)
return GL_UNDEFINED_APPLE;
- return intel_buffer_unpurgeable(intel->mt->bo);
+ if (option == GL_UNDEFINED_APPLE || !intel_bo_unpurgeable(intel->mt->bo)) {
+ intel_miptree_release(&intel->mt);
+ return GL_UNDEFINED_APPLE;
+ }
+
+ return GL_RETAINED_APPLE;
}
void