blob: 94d161acecea92f1d56c88e7eff1cccb444ee058 [file] [log] [blame]
Chia-I Wu82f50aa2014-08-05 10:43:03 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu82f50aa2014-08-05 10:43:03 +08003 *
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 {
Tony Barbourde4124d2015-07-03 10:33:54 -060037 VkDbgObjectType type;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080038
39 void *create_info;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060040 size_t create_info_size;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080041
42 void *tag;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060043 size_t tag_size;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080044};
45
46struct intel_base {
Chia-I Wu924c1fc2015-01-19 11:14:00 +080047 struct intel_handle handle;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080048
Chia-I Wu82f50aa2014-08-05 10:43:03 +080049 struct intel_base_dbg *dbg;
50
Tony Barbour426b9052015-06-24 16:06:58 -060051 VkResult (*get_memory_requirements)(struct intel_base *base,
52 VkMemoryRequirements *data);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080053};
54
55struct intel_obj {
56 struct intel_base base;
57
58 void (*destroy)(struct intel_obj *obj);
59
Chia-I Wu26f0bd02014-08-07 10:38:40 +080060 /* for memory binding */
Chia-I Wu82f50aa2014-08-05 10:43:03 +080061 struct intel_mem *mem;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060062 size_t offset;
Chia-I Wu82f50aa2014-08-05 10:43:03 +080063};
64
Tony Barbourde4124d2015-07-03 10:33:54 -060065static inline struct intel_base *intel_base(uint64_t base)
Chia-I Wu82f50aa2014-08-05 10:43:03 +080066{
67 return (struct intel_base *) base;
68}
69
Tony Barbourde4124d2015-07-03 10:33:54 -060070static inline struct intel_obj *intel_obj(uint64_t obj)
Chia-I Wu82f50aa2014-08-05 10:43:03 +080071{
72 return (struct intel_obj *) obj;
73}
74
Chia-I Wu9e61c0d2014-09-15 15:12:06 +080075static inline void intel_obj_bind_mem(struct intel_obj *obj,
76 struct intel_mem *mem,
Tony Barbour8205d902015-04-16 15:59:00 -060077 VkDeviceSize offset)
Chia-I Wu9e61c0d2014-09-15 15:12:06 +080078{
79 obj->mem = mem;
80 obj->offset = offset;
81}
82
Tony Barbour426b9052015-06-24 16:06:58 -060083VkResult intel_base_get_memory_requirements(struct intel_base *base, VkMemoryRequirements *data);
Chia-I Wu26f0bd02014-08-07 10:38:40 +080084
Chia-I Wu545c2e12015-02-22 13:19:54 +080085struct intel_base_dbg *intel_base_dbg_create(const struct intel_handle *handle,
Tony Barbourde4124d2015-07-03 10:33:54 -060086 VkDbgObjectType type,
Chia-I Wu82f50aa2014-08-05 10:43:03 +080087 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060088 size_t dbg_size);
Chia-I Wuf13ed3c2015-02-22 14:09:00 +080089void intel_base_dbg_destroy(const struct intel_handle *handle,
90 struct intel_base_dbg *dbg);
Chia-I Wu82f50aa2014-08-05 10:43:03 +080091
Chia-I Wu545c2e12015-02-22 13:19:54 +080092struct intel_base *intel_base_create(const struct intel_handle *handle,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060093 size_t obj_size, bool debug,
Tony Barbourde4124d2015-07-03 10:33:54 -060094 VkDbgObjectType type,
Chia-I Wubbf2c932014-08-07 12:20:08 +080095 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060096 size_t dbg_size);
Chia-I Wubbf2c932014-08-07 12:20:08 +080097void intel_base_destroy(struct intel_base *base);
98
Chia-I Wu82f50aa2014-08-05 10:43:03 +080099#endif /* OBJ_H */