blob: 2fc2f4861daa033f1fc88820127fd853b0c89cc5 [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.
23 */
24
25#ifndef OBJ_H
26#define OBJ_H
27
28#include "intel.h"
29
Chia-I Wubbf2c932014-08-07 12:20:08 +080030struct intel_dev;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080031struct intel_mem;
32
33struct intel_base_dbg {
34 int alloc_id;
35 XGL_DBG_OBJECT_TYPE type;
36
37 void *create_info;
38 XGL_SIZE create_info_size;
39
40 void *tag;
41 XGL_SIZE tag_size;
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060042
43 /*
44 * Need pointer to base object to be able to log debug
45 * messages with intel_dev_log
46 */
47 struct intel_dev *dev;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080048};
49
50struct intel_base {
51 const struct icd_dispatch_table *dispatch;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080052
Chia-I Wu82f50aa2014-08-05 10:43:03 +080053 struct intel_base_dbg *dbg;
54
Chia-I Wu26f0bd02014-08-07 10:38:40 +080055 XGL_RESULT (*get_info)(struct intel_base *base, int type,
56 XGL_SIZE *size, XGL_VOID *data);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080057};
58
59struct intel_obj {
60 struct intel_base base;
61
62 void (*destroy)(struct intel_obj *obj);
63
Chia-I Wu26f0bd02014-08-07 10:38:40 +080064 /* for memory binding */
Chia-I Wu82f50aa2014-08-05 10:43:03 +080065 struct intel_mem *mem;
66 XGL_SIZE offset;
67};
68
Chia-I Wu82f50aa2014-08-05 10:43:03 +080069static inline struct intel_base *intel_base(XGL_BASE_OBJECT base)
70{
71 return (struct intel_base *) base;
72}
73
74static inline struct intel_obj *intel_obj(XGL_OBJECT obj)
75{
76 return (struct intel_obj *) obj;
77}
78
Chia-I Wu82f50aa2014-08-05 10:43:03 +080079bool intel_base_is_valid(const struct intel_base *base);
80
Chia-I Wu26f0bd02014-08-07 10:38:40 +080081XGL_RESULT intel_base_get_info(struct intel_base *base, int type,
82 XGL_SIZE *size, XGL_VOID *data);
83
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060084struct intel_base_dbg *intel_base_dbg_create(struct intel_dev *dev,
85 XGL_DBG_OBJECT_TYPE type,
Chia-I Wu82f50aa2014-08-05 10:43:03 +080086 const void *create_info,
Chia-I Wubbf2c932014-08-07 12:20:08 +080087 XGL_SIZE dbg_size);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080088void intel_base_dbg_destroy(struct intel_base_dbg *dbg);
89
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060090struct intel_base *intel_base_create(struct intel_dev *dev,
91 XGL_SIZE obj_size, bool debug,
Chia-I Wubbf2c932014-08-07 12:20:08 +080092 XGL_DBG_OBJECT_TYPE type,
93 const void *create_info,
94 XGL_SIZE dbg_size);
95void intel_base_destroy(struct intel_base *base);
96
Chia-I Wu53fc6aa2014-08-06 14:22:51 +080097XGL_RESULT XGLAPI intelDestroyObject(
98 XGL_OBJECT object);
99
100XGL_RESULT XGLAPI intelGetObjectInfo(
101 XGL_BASE_OBJECT object,
102 XGL_OBJECT_INFO_TYPE infoType,
103 XGL_SIZE* pDataSize,
104 XGL_VOID* pData);
105
106XGL_RESULT XGLAPI intelBindObjectMemory(
107 XGL_OBJECT object,
108 XGL_GPU_MEMORY mem,
109 XGL_GPU_SIZE offset);
110
Chia-I Wu7ec9f342014-08-19 10:47:53 +0800111XGL_RESULT XGLAPI intelDbgSetObjectTag(
112 XGL_BASE_OBJECT object,
113 XGL_SIZE tagSize,
114 const XGL_VOID* pTag);
115
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800116#endif /* OBJ_H */