It is up to the users whether to reference count the BOs or not.
struct ilo_buffer {
unsigned bo_size;
+ /* managed by users */
struct intel_bo *bo;
};
}
}
-static inline void
-ilo_buffer_cleanup(struct ilo_buffer *buf)
-{
- intel_bo_unref(buf->bo);
-}
-
-static inline void
-ilo_buffer_set_bo(struct ilo_buffer *buf, struct intel_bo *bo)
-{
- intel_bo_unref(buf->bo);
- buf->bo = intel_bo_ref(bo);
-}
-
#endif /* ILO_BUFFER_H */
#include "ilo_dev.h"
/**
- * Initialize the \p dev from \p winsys. \p winsys is considered owned by \p
- * dev and will be destroyed in \p ilo_dev_cleanup().
+ * Initialize the \p dev from \p winsys.
*/
bool
ilo_dev_init(struct ilo_dev *dev, struct intel_winsys *winsys)
return true;
}
-
-void
-ilo_dev_cleanup(struct ilo_dev *dev)
-{
- intel_winsys_destroy(dev->winsys);
-}
bool
ilo_dev_init(struct ilo_dev *dev, struct intel_winsys *winsys);
-void
-ilo_dev_cleanup(struct ilo_dev *dev);
-
static inline int
ilo_dev_gen(const struct ilo_dev *dev)
{
+++ /dev/null
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2012-2013 LunarG, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Chia-I Wu <olv@lunarg.com>
- */
-
-#ifndef ILO_FENCE_H
-#define ILO_FENCE_H
-
-#include "intel_winsys.h"
-
-#include "ilo_core.h"
-#include "ilo_debug.h"
-#include "ilo_dev.h"
-
-struct ilo_fence {
- struct intel_bo *seq_bo;
-};
-
-static inline void
-ilo_fence_init(struct ilo_fence *fence, const struct ilo_dev *dev)
-{
- assert(ilo_is_zeroed(fence, sizeof(*fence)));
-}
-
-static inline void
-ilo_fence_cleanup(struct ilo_fence *fence)
-{
- intel_bo_unref(fence->seq_bo);
-}
-
-/**
- * Set the sequence bo for waiting. The fence is considered signaled when
- * there is no sequence bo.
- */
-static inline void
-ilo_fence_set_seq_bo(struct ilo_fence *fence, struct intel_bo *seq_bo)
-{
- intel_bo_unref(fence->seq_bo);
- fence->seq_bo = intel_bo_ref(seq_bo);
-}
-
-/**
- * Wait for the fence to be signaled or until \p timeout nanoseconds has
- * passed. It will wait indefinitely when \p timeout is negative.
- */
-static inline bool
-ilo_fence_wait(struct ilo_fence *fence, int64_t timeout)
-{
- return (!fence->seq_bo || intel_bo_wait(fence->seq_bo, timeout) == 0);
-}
-
-#endif /* ILO_FENCE_H */
bool scanout;
- struct intel_bo *bo;
-
struct {
enum ilo_image_aux_type type;
unsigned bo_stride;
unsigned bo_height;
+ /* managed by users */
struct intel_bo *bo;
} aux;
+
+ /* managed by users */
+ struct intel_bo *bo;
};
struct pipe_resource;
enum gen_surface_tiling tiling,
unsigned bo_stride);
-static inline void
-ilo_image_cleanup(struct ilo_image *img)
-{
- intel_bo_unref(img->bo);
- intel_bo_unref(img->aux.bo);
-}
-
-static inline void
-ilo_image_set_bo(struct ilo_image *img, struct intel_bo *bo)
-{
- intel_bo_unref(img->bo);
- img->bo = intel_bo_ref(bo);
-}
-
-static inline void
-ilo_image_set_aux_bo(struct ilo_image *img, struct intel_bo *bo)
-{
- intel_bo_unref(img->aux.bo);
- img->aux.bo = intel_bo_ref(bo);
-}
-
static inline bool
ilo_image_can_enable_aux(const struct ilo_image *img, unsigned level)
{
if (!bo)
return false;
- ilo_image_set_bo(&tex->image, bo);
- intel_bo_unref(bo);
+ intel_bo_unref(tex->image.bo);
+ tex->image.bo = bo;
return true;
}
if (!bo)
return false;
- ilo_image_set_aux_bo(&tex->image, bo);
+ tex->image.aux.bo = bo;
if (tex->imported) {
unsigned lv;
if (!bo)
return false;
- ilo_image_set_aux_bo(&tex->image, bo);
+ tex->image.aux.bo = bo;
return true;
}
if (tex->separate_s8)
tex_destroy(tex->separate_s8);
- ilo_image_cleanup(&tex->image);
+ intel_bo_unref(tex->image.bo);
+ intel_bo_unref(tex->image.aux.bo);
tex_free_slices(tex);
FREE(tex);
return false;
}
- ilo_image_set_bo(&tex->image, bo);
- intel_bo_unref(bo);
+ tex->image.bo = bo;
tex->imported = true;
if (!bo)
return false;
- ilo_buffer_set_bo(&buf->buffer, bo);
- intel_bo_unref(bo);
+ intel_bo_unref(buf->buffer.bo);
+ buf->buffer.bo = bo;
return true;
}
static void
buf_destroy(struct ilo_buffer_resource *buf)
{
- ilo_buffer_cleanup(&buf->buffer);
+ intel_bo_unref(buf->buffer.bo);
FREE(buf);
}
#include "vl/vl_decoder.h"
#include "vl/vl_video_buffer.h"
#include "genhw/genhw.h" /* for GEN6_REG_TIMESTAMP */
-#include "core/ilo_fence.h"
#include "core/ilo_format.h"
#include "core/intel_winsys.h"
struct pipe_fence_handle {
struct pipe_reference reference;
-
- struct ilo_fence fence;
+ struct intel_bo *seqno_bo;
};
static float
STATIC_ASSERT(&((struct pipe_fence_handle *) NULL)->reference == NULL);
if (pipe_reference(&old->reference, &fence->reference)) {
- ilo_fence_cleanup(&old->fence);
+ intel_bo_unref(old->seqno_bo);
FREE(old);
}
}
const int64_t wait_timeout = (timeout > INT64_MAX) ? -1 : timeout;
bool signaled;
- signaled = ilo_fence_wait(&fence->fence, wait_timeout);
+ signaled = (!fence->seqno_bo ||
+ intel_bo_wait(fence->seqno_bo, wait_timeout) == 0);
+
/* XXX not thread safe */
- if (signaled)
- ilo_fence_set_seq_bo(&fence->fence, NULL);
+ if (signaled && fence->seqno_bo) {
+ intel_bo_unref(fence->seqno_bo);
+ fence->seqno_bo = NULL;
+ }
return signaled;
}
struct pipe_fence_handle *
ilo_screen_fence_create(struct pipe_screen *screen, struct intel_bo *bo)
{
- struct ilo_screen *is = ilo_screen(screen);
struct pipe_fence_handle *fence;
fence = CALLOC_STRUCT(pipe_fence_handle);
pipe_reference_init(&fence->reference, 1);
- ilo_fence_init(&fence->fence, &is->dev);
- ilo_fence_set_seq_bo(&fence->fence, bo);
+ fence->seqno_bo = intel_bo_ref(bo);
return fence;
}
{
struct ilo_screen *is = ilo_screen(screen);
- ilo_dev_cleanup(&is->dev);
+ intel_winsys_destroy(is->dev.winsys);
FREE(is);
}