| 1 |
|
| 2 |
. |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef KK_IMAGE_LAYOUT_H |
| 9 |
#define KK_IMAGE_LAYOUT_H 1 |
| 10 |
|
| 11 |
#include "kosmickrisp/bridge/mtl_types.h" |
| 12 |
|
| 13 |
#include "util/format/u_formats.h" |
| 14 |
|
| 15 |
#include "vulkan/vulkan.h" |
| 16 |
|
| 17 |
#define KK_MAX_MIP_LEVELS 16 |
| 18 |
|
| 19 |
struct kk_device; |
| 20 |
struct VkImageCreateInfo; |
| 21 |
enum pipe_swizzle; |
| 22 |
|
| 23 |
struct kk_image_layout { |
| 24 |
|
| 25 |
uint32_t width_px, height_px, depth_px, layers; |
| 26 |
|
| 27 |
enum mtl_texture_type type; |
| 28 |
|
| 29 |
|
| 30 |
uint8_t sample_count_sa; |
| 31 |
|
| 32 |
|
| 33 |
uint8_t levels; |
| 34 |
|
| 35 |
uint8_t optimized_layout; |
| 36 |
|
| 37 |
enum mtl_texture_usage usage; |
| 38 |
|
| 39 |
|
| 40 |
struct { |
| 41 |
enum pipe_format pipe; |
| 42 |
uint32_t mtl; |
| 43 |
} format; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
struct { |
| 49 |
uint8_t red; |
| 50 |
uint8_t green; |
| 51 |
uint8_t blue; |
| 52 |
uint8_t alpha; |
| 53 |
} swizzle; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
uint32_t linear_stride_B; |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
uint64_t layer_stride_B; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
uint64_t level_offsets_B[KK_MAX_MIP_LEVELS]; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
uint32_t stride_el[KK_MAX_MIP_LEVELS]; |
| 81 |
|
| 82 |
|
| 83 |
uint64_t size_B; |
| 84 |
|
| 85 |
|
| 86 |
uint64_t align_B; |
| 87 |
}; |
| 88 |
|
| 89 |
struct kk_view_layout { |
| 90 |
|
| 91 |
VkImageViewType view_type; |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
uint8_t sample_count_sa; |
| 97 |
|
| 98 |
|
| 99 |
struct { |
| 100 |
enum pipe_format pipe; |
| 101 |
uint32_t mtl; |
| 102 |
} format; |
| 103 |
|
| 104 |
|
| 105 |
uint16_t base_array_layer; |
| 106 |
|
| 107 |
|
| 108 |
uint16_t array_len; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
struct { |
| 114 |
union { |
| 115 |
struct { |
| 116 |
uint8_t red; |
| 117 |
uint8_t green; |
| 118 |
uint8_t blue; |
| 119 |
uint8_t alpha; |
| 120 |
}; |
| 121 |
uint8_t channels[4]; |
| 122 |
}; |
| 123 |
} swizzle; |
| 124 |
|
| 125 |
|
| 126 |
uint8_t base_level; |
| 127 |
|
| 128 |
|
| 129 |
uint8_t num_levels; |
| 130 |
|
| 131 |
uint16_t min_lod_clamp; |
| 132 |
}; |
| 133 |
|
| 134 |
void kk_image_layout_init(const struct kk_device *dev, |
| 135 |
const struct VkImageCreateInfo *create_info, |
| 136 |
enum pipe_format format, const uint8_t width_scale, |
| 137 |
const uint8_t height_scale, |
| 138 |
struct kk_image_layout *layout); |
| 139 |
|
| 140 |
#endif |