blob: bab8f02a4be6dd7ba57548a4db1813d1943055a7 [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;
42};
43
44struct intel_base {
45 const struct icd_dispatch_table *dispatch;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080046
Chia-I Wu82f50aa2014-08-05 10:43:03 +080047 struct intel_base_dbg *dbg;
48
Chia-I Wu26f0bd02014-08-07 10:38:40 +080049 XGL_RESULT (*get_info)(struct intel_base *base, int type,
50 XGL_SIZE *size, XGL_VOID *data);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080051};
52
53struct intel_obj {
54 struct intel_base base;
55
56 void (*destroy)(struct intel_obj *obj);
57
Chia-I Wu26f0bd02014-08-07 10:38:40 +080058 /* for memory binding */
Chia-I Wu82f50aa2014-08-05 10:43:03 +080059 struct intel_mem *mem;
60 XGL_SIZE offset;
61};
62
63struct intel_state {
64 struct intel_obj obj;
65};
66
67static inline struct intel_base *intel_base(XGL_BASE_OBJECT base)
68{
69 return (struct intel_base *) base;
70}
71
72static inline struct intel_obj *intel_obj(XGL_OBJECT obj)
73{
74 return (struct intel_obj *) obj;
75}
76
77static inline struct intel_state *intel_state(XGL_STATE_OBJECT state)
78{
79 return (struct intel_state *) state;
80}
81
82bool intel_base_is_valid(const struct intel_base *base);
83
Chia-I Wu26f0bd02014-08-07 10:38:40 +080084XGL_RESULT intel_base_get_info(struct intel_base *base, int type,
85 XGL_SIZE *size, XGL_VOID *data);
86
Chia-I Wu82f50aa2014-08-05 10:43:03 +080087struct intel_base_dbg *intel_base_dbg_create(XGL_DBG_OBJECT_TYPE type,
88 const void *create_info,
Chia-I Wubbf2c932014-08-07 12:20:08 +080089 XGL_SIZE dbg_size);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080090void intel_base_dbg_destroy(struct intel_base_dbg *dbg);
91
Chia-I Wubbf2c932014-08-07 12:20:08 +080092struct intel_base *intel_base_create(XGL_SIZE obj_size, bool debug,
93 XGL_DBG_OBJECT_TYPE type,
94 const void *create_info,
95 XGL_SIZE dbg_size);
96void intel_base_destroy(struct intel_base *base);
97
Chia-I Wu53fc6aa2014-08-06 14:22:51 +080098XGL_RESULT XGLAPI intelDestroyObject(
99 XGL_OBJECT object);
100
101XGL_RESULT XGLAPI intelGetObjectInfo(
102 XGL_BASE_OBJECT object,
103 XGL_OBJECT_INFO_TYPE infoType,
104 XGL_SIZE* pDataSize,
105 XGL_VOID* pData);
106
107XGL_RESULT XGLAPI intelBindObjectMemory(
108 XGL_OBJECT object,
109 XGL_GPU_MEMORY mem,
110 XGL_GPU_SIZE offset);
111
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800112#endif /* OBJ_H */