ilo: avoid resource owning in core

It is up to the users whether to reference count the BOs or not.
This commit is contained in:
Chia-I Wu
2015-05-21 16:30:03 +08:00
parent ab7229b9b6
commit 1885ac4908
7 changed files with 27 additions and 142 deletions
+1 -13
View File
@@ -37,6 +37,7 @@
struct ilo_buffer {
unsigned bo_size;
/* managed by users */
struct intel_bo *bo;
};
@@ -77,17 +78,4 @@ ilo_buffer_init(struct ilo_buffer *buf, const struct ilo_dev *dev,
}
}
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 */
+1 -8
View File
@@ -32,8 +32,7 @@
#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)
@@ -180,9 +179,3 @@ 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);
}
-3
View File
@@ -63,9 +63,6 @@ struct ilo_dev {
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)
{
-74
View File
@@ -1,74 +0,0 @@
/*
* 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 */
+4 -23
View File
@@ -125,8 +125,6 @@ struct ilo_image {
bool scanout;
struct intel_bo *bo;
struct {
enum ilo_image_aux_type type;
@@ -140,8 +138,12 @@ struct ilo_image {
unsigned bo_stride;
unsigned bo_height;
/* managed by users */
struct intel_bo *bo;
} aux;
/* managed by users */
struct intel_bo *bo;
};
struct pipe_resource;
@@ -158,27 +160,6 @@ ilo_image_init_for_imported(struct ilo_image *img,
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)
{
+10 -10
View File
@@ -178,8 +178,8 @@ tex_create_bo(struct ilo_texture *tex)
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;
}
@@ -223,7 +223,7 @@ tex_create_hiz(struct ilo_texture *tex)
if (!bo)
return false;
ilo_image_set_aux_bo(&tex->image, bo);
tex->image.aux.bo = bo;
if (tex->imported) {
unsigned lv;
@@ -256,7 +256,7 @@ tex_create_mcs(struct ilo_texture *tex)
if (!bo)
return false;
ilo_image_set_aux_bo(&tex->image, bo);
tex->image.aux.bo = bo;
return true;
}
@@ -267,7 +267,8 @@ tex_destroy(struct ilo_texture *tex)
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);
@@ -328,8 +329,7 @@ tex_import_handle(struct ilo_texture *tex,
return false;
}
ilo_image_set_bo(&tex->image, bo);
intel_bo_unref(bo);
tex->image.bo = bo;
tex->imported = true;
@@ -427,8 +427,8 @@ buf_create_bo(struct ilo_buffer_resource *buf)
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;
}
@@ -436,7 +436,7 @@ buf_create_bo(struct ilo_buffer_resource *buf)
static void
buf_destroy(struct ilo_buffer_resource *buf)
{
ilo_buffer_cleanup(&buf->buffer);
intel_bo_unref(buf->buffer.bo);
FREE(buf);
}
+11 -11
View File
@@ -31,7 +31,6 @@
#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"
@@ -43,8 +42,7 @@
struct pipe_fence_handle {
struct pipe_reference reference;
struct ilo_fence fence;
struct intel_bo *seqno_bo;
};
static float
@@ -642,7 +640,7 @@ ilo_screen_fence_reference(struct pipe_screen *screen,
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);
}
}
@@ -655,10 +653,14 @@ ilo_screen_fence_finish(struct pipe_screen *screen,
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;
}
@@ -677,7 +679,6 @@ ilo_screen_fence_signalled(struct pipe_screen *screen,
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);
@@ -686,8 +687,7 @@ ilo_screen_fence_create(struct pipe_screen *screen, struct intel_bo *bo)
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;
}
@@ -697,7 +697,7 @@ ilo_screen_destroy(struct pipe_screen *screen)
{
struct ilo_screen *is = ilo_screen(screen);
ilo_dev_cleanup(&is->dev);
intel_winsys_destroy(is->dev.winsys);
FREE(is);
}