summaryrefslogtreecommitdiff
path: root/linux-core/drm_gem.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2008-05-06 14:43:49 -0700
committerKeith Packard <keithp@keithp.com>2008-05-06 14:43:49 -0700
commit631e86c5c4ad9b2cdd40749ea3b351204a362c80 (patch)
treed7c7aff2bafaca4a86ea09f64ff7c7c539dbfd0f /linux-core/drm_gem.c
parent8551bfc6dba03dcd9d182b2099a0906153ecfa01 (diff)
Start coding up memory domains
Diffstat (limited to 'linux-core/drm_gem.c')
-rw-r--r--linux-core/drm_gem.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/linux-core/drm_gem.c b/linux-core/drm_gem.c
index 80d5a350..929c008f 100644
--- a/linux-core/drm_gem.c
+++ b/linux-core/drm_gem.c
@@ -539,3 +539,41 @@ drm_gem_object_handle_free (struct kref *kref)
}
EXPORT_SYMBOL(drm_gem_object_handle_free);
+
+/*
+ * Set the next domain for the specified object. This
+ * may not actually perform the necessary flushing/invaliding though,
+ * as that may want to be batched with other set_domain operations
+ */
+int drm_gem_object_set_domain (struct drm_gem_object *obj,
+ uint32_t read_domains,
+ uint32_t write_domain)
+{
+ struct drm_device *dev = obj->dev;
+ uint32_t invalidate_domains = 0;
+ uint32_t flush_domains = 0;
+
+ /*
+ * Flush the current write domain if
+ * the new read domains don't match. Invalidate
+ * any read domains which differ from the old
+ * write domain
+ */
+ if (obj->write_domain && obj->write_domain != read_domains)
+ {
+ flush_domains |= obj->write_domain;
+ invalidate_domains |= read_domains & ~obj->write_domain;
+ }
+ /*
+ * Invalidate any read caches which may have
+ * stale data. That is, any new read domains.
+ */
+ invalidate_domains |= read_domains & ~obj->read_domains;
+ obj->write_domain = write_domain;
+ obj->read_domain = read_domains;
+ if ((flush_domains | invalidate_domains) & DRM_GEM_DOMAIN_CPU)
+ drm_gem_object_clflush (obj);
+ dev->invalidate_domains |= invalidate_domains & ~DRM_GEM_DOMAIN_CPU;
+ dev->flush_domains |= flush_domains & ~DRM_GEM_DOMAIN_CPU;
+}
+EXPORT_SYMBOL(drm_gem_object_set_domain);