blob: 48cf6ef7fdbf5c2af2de6f27d6dae0e6551f63b7 [file] [log] [blame]
Chia-I Wu82f50aa2014-08-05 10:43:03 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu82f50aa2014-08-05 10:43:03 +080026 */
27
28#ifndef OBJ_H
29#define OBJ_H
30
31#include "intel.h"
32
Chia-I Wubbf2c932014-08-07 12:20:08 +080033struct intel_dev;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080034struct intel_mem;
35
36struct intel_base_dbg {
Chia-I Wu900364b2015-01-03 13:55:22 +080037 uint32_t alloc_id;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080038 XGL_DBG_OBJECT_TYPE type;
39
40 void *create_info;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060041 size_t create_info_size;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080042
43 void *tag;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060044 size_t tag_size;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080045};
46
47struct intel_base {
Chia-I Wu924c1fc2015-01-19 11:14:00 +080048 struct intel_handle handle;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080049
Chia-I Wu82f50aa2014-08-05 10:43:03 +080050 struct intel_base_dbg *dbg;
51
Chia-I Wu26f0bd02014-08-07 10:38:40 +080052 XGL_RESULT (*get_info)(struct intel_base *base, int type,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060053 size_t *size, void *data);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080054};
55
56struct intel_obj {
57 struct intel_base base;
58
59 void (*destroy)(struct intel_obj *obj);
60
Chia-I Wu26f0bd02014-08-07 10:38:40 +080061 /* for memory binding */
Chia-I Wu82f50aa2014-08-05 10:43:03 +080062 struct intel_mem *mem;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060063 size_t offset;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080064};
65
Chia-I Wu82f50aa2014-08-05 10:43:03 +080066static inline struct intel_base *intel_base(XGL_BASE_OBJECT base)
67{
68 return (struct intel_base *) base;
69}
70
71static inline struct intel_obj *intel_obj(XGL_OBJECT obj)
72{
73 return (struct intel_obj *) obj;
74}
75
Chia-I Wu9e61c0d2014-09-15 15:12:06 +080076static inline void intel_obj_bind_mem(struct intel_obj *obj,
77 struct intel_mem *mem,
78 XGL_GPU_SIZE offset)
79{
80 obj->mem = mem;
81 obj->offset = offset;
82}
83
Chia-I Wu26f0bd02014-08-07 10:38:40 +080084XGL_RESULT intel_base_get_info(struct intel_base *base, int type,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060085 size_t *size, void *data);
Chia-I Wu26f0bd02014-08-07 10:38:40 +080086
Chia-I Wu545c2e12015-02-22 13:19:54 +080087struct intel_base_dbg *intel_base_dbg_create(const struct intel_handle *handle,
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060088 XGL_DBG_OBJECT_TYPE type,
Chia-I Wu82f50aa2014-08-05 10:43:03 +080089 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060090 size_t dbg_size);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080091void intel_base_dbg_destroy(struct intel_base_dbg *dbg);
92
Chia-I Wu545c2e12015-02-22 13:19:54 +080093struct intel_base *intel_base_create(const struct intel_handle *handle,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060094 size_t obj_size, bool debug,
Chia-I Wubbf2c932014-08-07 12:20:08 +080095 XGL_DBG_OBJECT_TYPE type,
96 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060097 size_t dbg_size);
Chia-I Wubbf2c932014-08-07 12:20:08 +080098void intel_base_destroy(struct intel_base *base);
99
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800100#endif /* OBJ_H */