| 1 |
/* |
| 2 |
* Copyright 2024 Valve Corporation |
| 3 |
* Copyright 2024 Alyssa Rosenzweig |
| 4 |
* Copyright 2022-2023 Collabora Ltd. and Red Hat Inc. |
| 5 |
* SPDX-License-Identifier: MIT |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "hk_private.h" |
| 11 |
|
| 12 |
#include "hk_device.h" |
| 13 |
#include "vk_descriptor_update_template.h" |
| 14 |
#include "vk_object.h" |
| 15 |
|
| 16 |
#include "util/list.h" |
| 17 |
#include "util/vma.h" |
| 18 |
|
| 19 |
struct hk_descriptor_set_layout; |
| 20 |
|
| 21 |
struct hk_sampled_image_descriptor { |
| 22 |
struct agx_texture_packed tex; |
| 23 |
struct agx_sampler_packed sampler; |
| 24 |
uint16_t sampler_index; |
| 25 |
|
| 26 |
/* Negative if there is no border colour, else the clamp=0 sampler index used |
| 27 |
* for custom border colour emulation. |
| 28 |
*/ |
| 29 |
int16_t clamp_0_sampler_index_or_negative; |
| 30 |
|
| 31 |
/* We want LOD bias and min LOD together as fp16 in this order and 32-bit |
| 32 |
* aligned. This lets us keep everything vectorized on the shader side, since |
| 33 |
* this matches the AGX2 lod_bias + min_lod descriptor. |
| 34 |
*/ |
| 35 |
uint16_t lod_bias_fp16; |
| 36 |
uint16_t min_lod_fp16; |
| 37 |
|
| 38 |
/* This is only used for txf, it can be separate from the other stuff */ |
| 39 |
uint16_t min_lod_uint16; |
| 40 |
uint16_t pad; |
| 41 |
/* TODO: This should probably be a heap! */ |
| 42 |
uint32_t border[4]; |
| 43 |
uint8_t pad2[4]; |
| 44 |
}; |
| 45 |
static_assert(sizeof(struct hk_sampled_image_descriptor) == 64, |
| 46 |
"hk_sampled_image_descriptor has no holes"); |
| 47 |
|
| 48 |
struct hk_storage_image_descriptor { |
| 49 |
struct agx_texture_packed tex; |
| 50 |
struct agx_pbe_packed pbe; |
| 51 |
}; |
| 52 |
static_assert(sizeof(struct hk_storage_image_descriptor) == 48, |
| 53 |
"hk_storage_image_descriptor has no holes"); |
| 54 |
|
| 55 |
/* This has to match nir_address_format_64bit_bounded_global */ |
| 56 |
struct hk_buffer_address { |
| 57 |
uint64_t base_addr; |
| 58 |
uint32_t size; |
| 59 |
uint32_t zero; /* Must be zero! */ |
| 60 |
}; |
| 61 |
|
| 62 |
struct hk_descriptor_pool { |
| 63 |
struct vk_object_base base; |
| 64 |
|
| 65 |
struct list_head sets; |
| 66 |
|
| 67 |
struct agx_bo *bo; |
| 68 |
uint8_t *mapped_ptr; |
| 69 |
struct util_vma_heap heap; |
| 70 |
}; |
| 71 |
|
| 72 |
VK_DEFINE_NONDISP_HANDLE_CASTS(hk_descriptor_pool, base, VkDescriptorPool, |
| 73 |
VK_OBJECT_TYPE_DESCRIPTOR_POOL) |
| 74 |
|
| 75 |
struct hk_descriptor_set { |
| 76 |
struct vk_object_base base; |
| 77 |
|
| 78 |
/* Link in hk_descriptor_pool::sets */ |
| 79 |
struct list_head link; |
| 80 |
|
| 81 |
struct hk_descriptor_set_layout *layout; |
| 82 |
void *mapped_ptr; |
| 83 |
uint64_t addr; |
| 84 |
uint32_t size; |
| 85 |
|
| 86 |
struct hk_buffer_address dynamic_buffers[]; |
| 87 |
}; |
| 88 |
|
| 89 |
VK_DEFINE_NONDISP_HANDLE_CASTS(hk_descriptor_set, base, VkDescriptorSet, |
| 90 |
VK_OBJECT_TYPE_DESCRIPTOR_SET) |
| 91 |
|
| 92 |
static inline uint64_t |
| 93 |
hk_descriptor_set_addr(const struct hk_descriptor_set *set) |
| 94 |
{ |
| 95 |
return set->addr; |
| 96 |
} |
| 97 |
|
| 98 |
struct hk_push_descriptor_set { |
| 99 |
uint8_t data[HK_PUSH_DESCRIPTOR_SET_SIZE]; |
| 100 |
}; |
| 101 |
|
| 102 |
void hk_push_descriptor_set_update(struct hk_push_descriptor_set *push_set, |
| 103 |
struct hk_descriptor_set_layout *layout, |
| 104 |
uint32_t write_count, |
| 105 |
const VkWriteDescriptorSet *writes); |
| 106 |
|
| 107 |
void hk_push_descriptor_set_update_template( |
| 108 |
struct hk_push_descriptor_set *push_set, |
| 109 |
struct hk_descriptor_set_layout *layout, |
| 110 |
const struct vk_descriptor_update_template *template, const void *data); |