blob: 28f0c41b540b7692fcd5406f1f117939af402d34 [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;
41 XGL_SIZE create_info_size;
42
43 void *tag;
44 XGL_SIZE tag_size;
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060045
46 /*
47 * Need pointer to base object to be able to log debug
48 * messages with intel_dev_log
49 */
50 struct intel_dev *dev;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080051};
52
53struct intel_base {
Jon Ashburn70f97242014-12-03 11:13:40 -070054 const XGL_LAYER_DISPATCH_TABLE *dispatch;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080055
Chia-I Wu82f50aa2014-08-05 10:43:03 +080056 struct intel_base_dbg *dbg;
57
Chia-I Wu26f0bd02014-08-07 10:38:40 +080058 XGL_RESULT (*get_info)(struct intel_base *base, int type,
59 XGL_SIZE *size, XGL_VOID *data);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080060};
61
62struct intel_obj {
63 struct intel_base base;
64
65 void (*destroy)(struct intel_obj *obj);
66
Chia-I Wu26f0bd02014-08-07 10:38:40 +080067 /* for memory binding */
Chia-I Wu82f50aa2014-08-05 10:43:03 +080068 struct intel_mem *mem;
69 XGL_SIZE offset;
70};
71
Chia-I Wu82f50aa2014-08-05 10:43:03 +080072static inline struct intel_base *intel_base(XGL_BASE_OBJECT base)
73{
74 return (struct intel_base *) base;
75}
76
77static inline struct intel_obj *intel_obj(XGL_OBJECT obj)
78{
79 return (struct intel_obj *) obj;
80}
81
Chia-I Wu9e61c0d2014-09-15 15:12:06 +080082static inline void intel_obj_bind_mem(struct intel_obj *obj,
83 struct intel_mem *mem,
84 XGL_GPU_SIZE offset)
85{
86 obj->mem = mem;
87 obj->offset = offset;
88}
89
Chia-I Wu82f50aa2014-08-05 10:43:03 +080090bool intel_base_is_valid(const struct intel_base *base);
91
Chia-I Wu26f0bd02014-08-07 10:38:40 +080092XGL_RESULT intel_base_get_info(struct intel_base *base, int type,
93 XGL_SIZE *size, XGL_VOID *data);
94
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060095struct intel_base_dbg *intel_base_dbg_create(struct intel_dev *dev,
96 XGL_DBG_OBJECT_TYPE type,
Chia-I Wu82f50aa2014-08-05 10:43:03 +080097 const void *create_info,
Chia-I Wubbf2c932014-08-07 12:20:08 +080098 XGL_SIZE dbg_size);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080099void intel_base_dbg_destroy(struct intel_base_dbg *dbg);
100
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -0600101struct intel_base *intel_base_create(struct intel_dev *dev,
102 XGL_SIZE obj_size, bool debug,
Chia-I Wubbf2c932014-08-07 12:20:08 +0800103 XGL_DBG_OBJECT_TYPE type,
104 const void *create_info,
105 XGL_SIZE dbg_size);
106void intel_base_destroy(struct intel_base *base);
107
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800108#endif /* OBJ_H */