diff options
author | Chia-I Wu <[email protected]> | 2014-09-19 13:42:08 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2014-09-19 16:02:11 +0800 |
commit | 270667472fa3e406b4748488718fdb3a7ef24e28 (patch) | |
tree | a226545260ccfc434370a57d3f8c4530396a6de7 /src/gallium/drivers/ilo/ilo_cp.c | |
parent | 26ee6f23a9aec6b1f392baa0e3f1f2c62c038a57 (diff) |
ilo: simplify ilo_cp_set_owner()
The simplification allows us to get rid of ilo_cp_set_ring() and
ilo_cp_implicit_flush(). The 3D query code is refactored for the
simplification.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_cp.c')
-rw-r--r-- | src/gallium/drivers/ilo/ilo_cp.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/src/gallium/drivers/ilo/ilo_cp.c b/src/gallium/drivers/ilo/ilo_cp.c index dddd5a31c81..fd4f49e54a2 100644 --- a/src/gallium/drivers/ilo/ilo_cp.c +++ b/src/gallium/drivers/ilo/ilo_cp.c @@ -31,12 +31,62 @@ #include "ilo_shader.h" #include "ilo_cp.h" +static const struct ilo_cp_owner ilo_cp_default_owner; + +static void +ilo_cp_release_owner(struct ilo_cp *cp) +{ + if (cp->owner != &ilo_cp_default_owner) { + const struct ilo_cp_owner *owner = cp->owner; + + cp->owner = &ilo_cp_default_owner; + + assert(ilo_cp_space(cp) >= owner->reserve); + owner->release(cp, owner->data); + } +} + +/** + * Set the parser owner. If this is a new owner or a new ring, the old owner + * is released and the new owner's own() is called. + * + * The parser may be implicitly flushed if there is a ring change or there is + * not enough space for the new owner. + */ +void +ilo_cp_set_owner(struct ilo_cp *cp, enum intel_ring_type ring, + const struct ilo_cp_owner *owner) +{ + if (!owner) + owner = &ilo_cp_default_owner; + + if (cp->ring != ring) { + ilo_cp_flush(cp, "ring change"); + cp->ring = ring; + } + + if (cp->owner != owner) { + ilo_cp_release_owner(cp); + + /* multiply by 2 because there are own() and release() */ + if (ilo_cp_space(cp) < owner->reserve * 2) { + ilo_cp_flush(cp, "new owner"); + assert(ilo_cp_space(cp) >= owner->reserve * 2); + } + + cp->owner = owner; + + assert(ilo_cp_space(cp) >= owner->reserve); + cp->owner->own(cp, cp->owner->data); + } +} + static struct intel_bo * ilo_cp_end_batch(struct ilo_cp *cp, unsigned *used) { struct intel_bo *bo; - ilo_cp_set_owner(cp, NULL, 0); + ilo_cp_release_owner(cp); if (!ilo_builder_batch_used(&cp->builder)) { ilo_builder_batch_discard(&cp->builder); @@ -130,6 +180,7 @@ ilo_cp_create(const struct ilo_dev_info *dev, } cp->ring = INTEL_RING_RENDER; + cp->owner = &ilo_cp_default_owner; ilo_builder_init(&cp->builder, dev, winsys); |