| 1 |
|
| 2 |
. |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#include "kk_image.h" |
| 9 |
|
| 10 |
#include "kk_device.h" |
| 11 |
#include "kk_device_memory.h" |
| 12 |
#include "kk_entrypoints.h" |
| 13 |
#include "kk_format.h" |
| 14 |
#include "kk_physical_device.h" |
| 15 |
|
| 16 |
#include "kosmickrisp/bridge/mtl_bridge.h" |
| 17 |
|
| 18 |
#include "vk_enum_defines.h" |
| 19 |
#include "vk_enum_to_str.h" |
| 20 |
#include "vk_format.h" |
| 21 |
#include "wsi_common_private.h" |
| 22 |
|
| 23 |
static VkFormatFeatureFlags2 |
| 24 |
kk_get_image_plane_format_features(struct kk_physical_device *pdev, |
| 25 |
VkFormat vk_format, VkImageTiling tiling, |
| 26 |
uint64_t drm_format_mod) |
| 27 |
{ |
| 28 |
VkFormatFeatureFlags2 features = 0; |
| 29 |
|
| 30 |
|
| 31 |
if (tiling == VK_IMAGE_TILING_LINEAR && vk_format_is_compressed(vk_format)) |
| 32 |
return 0; |
| 33 |
|
| 34 |
enum pipe_format p_format = vk_format_to_pipe_format(vk_format); |
| 35 |
if (p_format == PIPE_FORMAT_NONE) |
| 36 |
return 0; |
| 37 |
|
| 38 |
|
| 39 |
if (!util_is_power_of_two_nonzero(util_format_get_blocksize(p_format))) |
| 40 |
return 0; |
| 41 |
|
| 42 |
const struct kk_va_format *va_format = kk_get_va_format(p_format); |
| 43 |
if (va_format == NULL) |
| 44 |
return 0; |
| 45 |
|
| 46 |
|
| 47 |
features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; |
| 48 |
features |= VK_FORMAT_FEATURE_2_BLIT_SRC_BIT; |
| 49 |
|
| 50 |
if (va_format->filter) { |
| 51 |
features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT; |
| 52 |
features |= |
| 53 |
VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
if (vk_format_has_depth(vk_format)) { |
| 61 |
features |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
if (va_format->color && tiling != VK_IMAGE_TILING_LINEAR && |
| 66 |
vk_format != VK_FORMAT_A8_UNORM) { |
| 67 |
features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT; |
| 68 |
features |= VK_FORMAT_FEATURE_2_BLIT_DST_BIT; |
| 69 |
|
| 70 |
|
| 71 |
if (!vk_format_is_snorm(vk_format)) |
| 72 |
features |= VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT; |
| 73 |
} |
| 74 |
|
| 75 |
if (vk_format_is_depth_or_stencil(vk_format)) { |
| 76 |
if (tiling == VK_IMAGE_TILING_LINEAR) |
| 77 |
return 0; |
| 78 |
|
| 79 |
features |= VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 80 |
} |
| 81 |
|
| 82 |
if (va_format->write) { |
| 83 |
features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT; |
| 84 |
features |= VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT; |
| 85 |
features |= VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT; |
| 86 |
} |
| 87 |
|
| 88 |
if (va_format->atomic) |
| 89 |
features |= VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT; |
| 90 |
|
| 91 |
if (features != 0) { |
| 92 |
features |= VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT; |
| 93 |
features |= VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT; |
| 94 |
} |
| 95 |
|
| 96 |
return features; |
| 97 |
} |
| 98 |
|
| 99 |
VkFormatFeatureFlags2 |
| 100 |
kk_get_image_format_features(struct kk_physical_device *pdev, |
| 101 |
VkFormat vk_format, VkImageTiling tiling, |
| 102 |
uint64_t drm_format_mod) |
| 103 |
{ |
| 104 |
const struct vk_format_ycbcr_info *ycbcr_info = |
| 105 |
vk_format_get_ycbcr_info(vk_format); |
| 106 |
if (ycbcr_info == NULL) { |
| 107 |
return kk_get_image_plane_format_features(pdev, vk_format, tiling, |
| 108 |
drm_format_mod); |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
VkFormatFeatureFlags2 features = ~0ull; |
| 115 |
bool cosited_chroma = false; |
| 116 |
for (uint8_t plane = 0; plane < ycbcr_info->n_planes; plane++) { |
| 117 |
const struct vk_format_ycbcr_plane *plane_info = |
| 118 |
&ycbcr_info->planes[plane]; |
| 119 |
features &= kk_get_image_plane_format_features(pdev, plane_info->format, |
| 120 |
tiling, drm_format_mod); |
| 121 |
if (plane_info->denominator_scales[0] > 1 || |
| 122 |
plane_info->denominator_scales[1] > 1) |
| 123 |
cosited_chroma = true; |
| 124 |
} |
| 125 |
if (features == 0) |
| 126 |
return 0; |
| 127 |
|
| 128 |
|
| 129 |
assert(features & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT); |
| 130 |
assert(features & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT); |
| 131 |
|
| 132 |
|
| 133 |
features &= |
| 134 |
~(VK_FORMAT_FEATURE_2_BLIT_SRC_BIT | VK_FORMAT_FEATURE_2_BLIT_DST_BIT | |
| 135 |
VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | |
| 136 |
VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT | |
| 137 |
VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT); |
| 138 |
|
| 139 |
|
| 140 |
features |= |
| 141 |
VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT; |
| 142 |
|
| 143 |
if (ycbcr_info->n_planes > 1) { |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
features |= |
| 155 |
VK_FORMAT_FEATURE_DISJOINT_BIT | |
| 156 |
VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT | |
| 157 |
VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT; |
| 158 |
} |
| 159 |
|
| 160 |
if (cosited_chroma) |
| 161 |
features |= VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT; |
| 162 |
|
| 163 |
return features; |
| 164 |
} |
| 165 |
|
| 166 |
static VkFormatFeatureFlags2 |
| 167 |
vk_image_usage_to_format_features(VkImageUsageFlagBits usage_flag) |
| 168 |
{ |
| 169 |
assert(util_bitcount(usage_flag) == 1); |
| 170 |
switch (usage_flag) { |
| 171 |
case VK_IMAGE_USAGE_TRANSFER_SRC_BIT: |
| 172 |
return VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT | |
| 173 |
VK_FORMAT_FEATURE_BLIT_SRC_BIT; |
| 174 |
case VK_IMAGE_USAGE_TRANSFER_DST_BIT: |
| 175 |
return VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT | |
| 176 |
VK_FORMAT_FEATURE_BLIT_DST_BIT; |
| 177 |
case VK_IMAGE_USAGE_SAMPLED_BIT: |
| 178 |
return VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT; |
| 179 |
case VK_IMAGE_USAGE_STORAGE_BIT: |
| 180 |
return VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT; |
| 181 |
case VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT: |
| 182 |
return VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT; |
| 183 |
case VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT: |
| 184 |
return VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 185 |
case VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT: |
| 186 |
return VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | |
| 187 |
VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 188 |
case VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR: |
| 189 |
return VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR; |
| 190 |
default: |
| 191 |
return 0; |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
uint32_t |
| 196 |
kk_image_max_dimension(VkImageType image_type) |
| 197 |
{ |
| 198 |
|
| 199 |
|
| 200 |
switch (image_type) { |
| 201 |
case VK_IMAGE_TYPE_1D: |
| 202 |
case VK_IMAGE_TYPE_2D: |
| 203 |
return 16384; |
| 204 |
case VK_IMAGE_TYPE_3D: |
| 205 |
return 2048; |
| 206 |
default: |
| 207 |
UNREACHABLE("Invalid image type"); |
| 208 |
} |
| 209 |
} |
| 210 |
|
| 211 |
VKAPI_ATTR VkResult VKAPI_CALL |
| 212 |
kk_GetPhysicalDeviceImageFormatProperties2( |
| 213 |
VkPhysicalDevice physicalDevice, |
| 214 |
const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 215 |
VkImageFormatProperties2 *pImageFormatProperties) |
| 216 |
{ |
| 217 |
VK_FROM_HANDLE(kk_physical_device, pdev, physicalDevice); |
| 218 |
|
| 219 |
const VkPhysicalDeviceExternalImageFormatInfo *external_info = |
| 220 |
vk_find_struct_const(pImageFormatInfo->pNext, |
| 221 |
PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO); |
| 222 |
|
| 223 |
|
| 224 |
memset(&pImageFormatProperties->imageFormatProperties, 0, |
| 225 |
sizeof(pImageFormatProperties->imageFormatProperties)); |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
if (vk_format_is_depth_or_stencil(pImageFormatInfo->format) && |
| 230 |
pImageFormatInfo->type == VK_IMAGE_TYPE_3D) |
| 231 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 232 |
|
| 233 |
|
| 234 |
if (util_format_is_etc(vk_format_to_pipe_format(pImageFormatInfo->format)) && |
| 235 |
pImageFormatInfo->type == VK_IMAGE_TYPE_3D) |
| 236 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
if (pImageFormatInfo->flags & |
| 243 |
VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT) |
| 244 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 245 |
|
| 246 |
const struct vk_format_ycbcr_info *ycbcr_info = |
| 247 |
vk_format_get_ycbcr_info(pImageFormatInfo->format); |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
VkFormatFeatureFlags2 features; |
| 254 |
if (ycbcr_info == NULL) { |
| 255 |
features = kk_get_image_plane_format_features( |
| 256 |
pdev, pImageFormatInfo->format, pImageFormatInfo->tiling, 0u); |
| 257 |
} else { |
| 258 |
features = ~0ull; |
| 259 |
assert(ycbcr_info->n_planes > 0); |
| 260 |
for (uint8_t plane = 0; plane < ycbcr_info->n_planes; plane++) { |
| 261 |
const VkFormat plane_format = ycbcr_info->planes[plane].format; |
| 262 |
features &= kk_get_image_plane_format_features( |
| 263 |
pdev, plane_format, pImageFormatInfo->tiling, 0u); |
| 264 |
} |
| 265 |
} |
| 266 |
|
| 267 |
if (features == 0) |
| 268 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 269 |
|
| 270 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_LINEAR && |
| 271 |
pImageFormatInfo->type == VK_IMAGE_TYPE_3D) |
| 272 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_LINEAR && |
| 280 |
(pImageFormatInfo->usage & |
| 281 |
(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 282 |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))) |
| 283 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 284 |
|
| 285 |
if (ycbcr_info && pImageFormatInfo->type != VK_IMAGE_TYPE_2D) |
| 286 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 287 |
|
| 288 |
|
| 289 |
if ((pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT)) |
| 290 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
if ((pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) && |
| 305 |
(pImageFormatInfo->type == VK_IMAGE_TYPE_1D || |
| 306 |
pImageFormatInfo->tiling == VK_IMAGE_TILING_LINEAR)) |
| 307 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
if ((pImageFormatInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && |
| 319 |
(pImageFormatInfo->flags & (VK_IMAGE_CREATE_SPARSE_ALIASED_BIT | |
| 320 |
VK_IMAGE_CREATE_SPARSE_BINDING_BIT | |
| 321 |
VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT))) |
| 322 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 323 |
|
| 324 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT && |
| 325 |
pImageFormatInfo->type != VK_IMAGE_TYPE_2D) |
| 326 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 327 |
|
| 328 |
const uint32_t max_dim = kk_image_max_dimension(pImageFormatInfo->type); |
| 329 |
assert(util_is_power_of_two_nonzero(max_dim)); |
| 330 |
uint32_t maxMipLevels = util_logbase2(max_dim) + 1; |
| 331 |
VkExtent3D maxExtent; |
| 332 |
uint32_t maxArraySize; |
| 333 |
switch (pImageFormatInfo->type) { |
| 334 |
case VK_IMAGE_TYPE_1D: |
| 335 |
maxExtent = (VkExtent3D){max_dim, 1, 1}; |
| 336 |
maxArraySize = 2048u; |
| 337 |
break; |
| 338 |
case VK_IMAGE_TYPE_2D: |
| 339 |
maxExtent = (VkExtent3D){max_dim, max_dim, 1}; |
| 340 |
maxArraySize = 2048u; |
| 341 |
break; |
| 342 |
case VK_IMAGE_TYPE_3D: |
| 343 |
maxExtent = (VkExtent3D){max_dim, max_dim, max_dim}; |
| 344 |
maxArraySize = 1u; |
| 345 |
break; |
| 346 |
default: |
| 347 |
UNREACHABLE("Invalid image type"); |
| 348 |
} |
| 349 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_LINEAR) |
| 350 |
maxArraySize = 1; |
| 351 |
|
| 352 |
if (ycbcr_info != NULL || pImageFormatInfo->tiling == VK_IMAGE_TILING_LINEAR) |
| 353 |
maxMipLevels = 1; |
| 354 |
|
| 355 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 356 |
maxArraySize = 1; |
| 357 |
maxMipLevels = 1; |
| 358 |
} |
| 359 |
|
| 360 |
VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT; |
| 361 |
if (pImageFormatInfo->tiling == VK_IMAGE_TILING_OPTIMAL && |
| 362 |
pImageFormatInfo->type == VK_IMAGE_TYPE_2D && ycbcr_info == NULL && |
| 363 |
(features & (VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT | |
| 364 |
VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT)) && |
| 365 |
!(pImageFormatInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT)) { |
| 366 |
sampleCounts = |
| 367 |
VK_SAMPLE_COUNT_1_BIT | VK_SAMPLE_COUNT_2_BIT | |
| 368 |
|
| 369 |
VK_SAMPLE_COUNT_4_BIT |
| 370 |
|
| 371 |
; |
| 372 |
} |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
const VkImageUsageFlags image_usage = pImageFormatInfo->usage; |
| 386 |
VkImageUsageFlags view_usage = image_usage; |
| 387 |
if (pImageFormatInfo->flags & VK_IMAGE_CREATE_EXTENDED_USAGE_BIT) |
| 388 |
view_usage = 0; |
| 389 |
|
| 390 |
u_foreach_bit(b, view_usage) { |
| 391 |
VkFormatFeatureFlags2 usage_features = |
| 392 |
vk_image_usage_to_format_features(1 << b); |
| 393 |
if (usage_features && !(features & usage_features)) |
| 394 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 395 |
} |
| 396 |
|
| 397 |
const VkExternalMemoryProperties *ext_mem_props = NULL; |
| 398 |
if (external_info != NULL && external_info->handleType != 0) { |
| 399 |
|
| 400 |
|
| 401 |
switch (external_info->handleType) { |
| 402 |
case VK_EXTERNAL_MEMORY_HANDLE_TYPE_MTLHEAP_BIT_EXT: |
| 403 |
ext_mem_props = &kk_mtlheap_mem_props; |
| 404 |
break; |
| 405 |
default: |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
return vk_errorf(pdev, VK_ERROR_FORMAT_NOT_SUPPORTED, |
| 414 |
"unsupported VkExternalMemoryHandleTypeFlagBits: %s ", |
| 415 |
vk_ExternalMemoryHandleTypeFlagBits_to_str( |
| 416 |
external_info->handleType)); |
| 417 |
} |
| 418 |
} |
| 419 |
|
| 420 |
const unsigned plane_count = |
| 421 |
vk_format_get_plane_count(pImageFormatInfo->format); |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
if (plane_count == 1 && |
| 442 |
!(pImageFormatInfo->flags & VK_IMAGE_CREATE_ALIAS_BIT) && |
| 443 |
(pImageFormatInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT)) |
| 444 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 445 |
|
| 446 |
if (ycbcr_info && |
| 447 |
((pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) || |
| 448 |
(pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT))) |
| 449 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 450 |
|
| 451 |
if ((pImageFormatInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && |
| 452 |
(pImageFormatInfo->usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT)) |
| 453 |
return VK_ERROR_FORMAT_NOT_SUPPORTED; |
| 454 |
|
| 455 |
pImageFormatProperties->imageFormatProperties = (VkImageFormatProperties){ |
| 456 |
.maxExtent = maxExtent, |
| 457 |
.maxMipLevels = maxMipLevels, |
| 458 |
.maxArrayLayers = maxArraySize, |
| 459 |
.sampleCounts = sampleCounts, |
| 460 |
.maxResourceSize = UINT32_MAX, |
| 461 |
}; |
| 462 |
|
| 463 |
vk_foreach_struct(s, pImageFormatProperties->pNext) { |
| 464 |
switch (s->sType) { |
| 465 |
case VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES: { |
| 466 |
VkExternalImageFormatProperties *p = (void *)s; |
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
if (ext_mem_props != NULL) |
| 477 |
p->externalMemoryProperties = *ext_mem_props; |
| 478 |
break; |
| 479 |
} |
| 480 |
case VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES: { |
| 481 |
VkSamplerYcbcrConversionImageFormatProperties *ycbcr_props = (void *)s; |
| 482 |
ycbcr_props->combinedImageSamplerDescriptorCount = plane_count; |
| 483 |
break; |
| 484 |
} |
| 485 |
case VK_STRUCTURE_TYPE_HOST_IMAGE_COPY_DEVICE_PERFORMANCE_QUERY_EXT: { |
| 486 |
VkHostImageCopyDevicePerformanceQueryEXT *host_props = (void *)s; |
| 487 |
host_props->optimalDeviceAccess = true; |
| 488 |
host_props->identicalMemoryLayout = true; |
| 489 |
break; |
| 490 |
} |
| 491 |
default: |
| 492 |
vk_debug_ignored_stype(s->sType); |
| 493 |
break; |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
return VK_SUCCESS; |
| 498 |
} |
| 499 |
|
| 500 |
VKAPI_ATTR void VKAPI_CALL |
| 501 |
kk_GetPhysicalDeviceSparseImageFormatProperties2( |
| 502 |
VkPhysicalDevice physicalDevice, |
| 503 |
const VkPhysicalDeviceSparseImageFormatInfo2 *pFormatInfo, |
| 504 |
uint32_t *pPropertyCount, VkSparseImageFormatProperties2 *pProperties) |
| 505 |
{ |
| 506 |
*pPropertyCount = 0; |
| 507 |
return; |
| 508 |
} |
| 509 |
|
| 510 |
static VkResult |
| 511 |
kk_image_init(struct kk_device *dev, struct kk_image *image, |
| 512 |
const VkImageCreateInfo *pCreateInfo) |
| 513 |
{ |
| 514 |
vk_image_init(&dev->vk, &image->vk, pCreateInfo); |
| 515 |
|
| 516 |
if ((image->vk.usage & (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | |
| 517 |
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)) && |
| 518 |
image->vk.samples > 1) { |
| 519 |
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; |
| 520 |
image->vk.stencil_usage |= VK_IMAGE_USAGE_SAMPLED_BIT; |
| 521 |
} |
| 522 |
|
| 523 |
if (image->vk.usage & VK_IMAGE_USAGE_TRANSFER_SRC_BIT) |
| 524 |
image->vk.usage |= VK_IMAGE_USAGE_SAMPLED_BIT; |
| 525 |
if (image->vk.usage & VK_IMAGE_USAGE_TRANSFER_DST_BIT) { |
| 526 |
if (util_format_is_depth_or_stencil( |
| 527 |
vk_format_to_pipe_format(image->vk.format))) { |
| 528 |
image->vk.usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 529 |
image->vk.stencil_usage |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; |
| 530 |
} else { |
| 531 |
image->vk.usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; |
| 532 |
} |
| 533 |
} |
| 534 |
|
| 535 |
image->plane_count = vk_format_get_plane_count(pCreateInfo->format); |
| 536 |
image->disjoint = image->plane_count > 1 && |
| 537 |
(pCreateInfo->flags & VK_IMAGE_CREATE_DISJOINT_BIT); |
| 538 |
|
| 539 |
const struct vk_format_ycbcr_info *ycbcr_info = |
| 540 |
vk_format_get_ycbcr_info(pCreateInfo->format); |
| 541 |
for (uint8_t plane = 0; plane < image->plane_count; plane++) { |
| 542 |
VkFormat format = |
| 543 |
ycbcr_info ? ycbcr_info->planes[plane].format : pCreateInfo->format; |
| 544 |
const uint8_t width_scale = |
| 545 |
ycbcr_info ? ycbcr_info->planes[plane].denominator_scales[0] : 1; |
| 546 |
const uint8_t height_scale = |
| 547 |
ycbcr_info ? ycbcr_info->planes[plane].denominator_scales[1] : 1; |
| 548 |
kk_image_layout_init(dev, pCreateInfo, vk_format_to_pipe_format(format), |
| 549 |
width_scale, height_scale, |
| 550 |
&image->planes[plane].layout); |
| 551 |
} |
| 552 |
|
| 553 |
if (image->vk.format == VK_FORMAT_D32_SFLOAT_S8_UINT) { |
| 554 |
kk_image_layout_init(dev, pCreateInfo, PIPE_FORMAT_R32_UINT, 1, 1, |
| 555 |
&image->stencil_copy_temp.layout); |
| 556 |
} |
| 557 |
|
| 558 |
return VK_SUCCESS; |
| 559 |
} |
| 560 |
|
| 561 |
static void |
| 562 |
kk_image_plane_size_align_B(struct kk_device *dev, const struct kk_image *image, |
| 563 |
const struct kk_image_plane *plane, |
| 564 |
uint64_t *size_B_out, uint64_t *align_B_out) |
| 565 |
{ |
| 566 |
*size_B_out = plane->layout.size_B; |
| 567 |
*align_B_out = plane->layout.align_B; |
| 568 |
} |
| 569 |
|
| 570 |
static void |
| 571 |
kk_image_plane_finish(struct kk_device *dev, struct kk_image_plane *plane, |
| 572 |
VkImageCreateFlags create_flags, |
| 573 |
const VkAllocationCallbacks *pAllocator) |
| 574 |
{ |
| 575 |
if (plane->mtl_handle != NULL) |
| 576 |
mtl_release(plane->mtl_handle); |
| 577 |
if (plane->mtl_handle_array != NULL) |
| 578 |
mtl_release(plane->mtl_handle_array); |
| 579 |
} |
| 580 |
|
| 581 |
static void |
| 582 |
kk_image_finish(struct kk_device *dev, struct kk_image *image, |
| 583 |
const VkAllocationCallbacks *pAllocator) |
| 584 |
{ |
| 585 |
for (uint8_t plane = 0; plane < image->plane_count; plane++) { |
| 586 |
kk_image_plane_finish(dev, &image->planes[plane], image->vk.create_flags, |
| 587 |
pAllocator); |
| 588 |
} |
| 589 |
|
| 590 |
if (image->stencil_copy_temp.layout.size_B > 0) { |
| 591 |
kk_image_plane_finish(dev, &image->stencil_copy_temp, |
| 592 |
image->vk.create_flags, pAllocator); |
| 593 |
} |
| 594 |
|
| 595 |
vk_image_finish(&image->vk); |
| 596 |
} |
| 597 |
|
| 598 |
VKAPI_ATTR VkResult VKAPI_CALL |
| 599 |
kk_CreateImage(VkDevice _device, const VkImageCreateInfo *pCreateInfo, |
| 600 |
const VkAllocationCallbacks *pAllocator, VkImage *pImage) |
| 601 |
{ |
| 602 |
VK_FROM_HANDLE(kk_device, dev, _device); |
| 603 |
struct kk_physical_device *pdev = kk_device_physical(dev); |
| 604 |
struct kk_image *image; |
| 605 |
VkResult result; |
| 606 |
|
| 607 |
if (wsi_common_is_swapchain_image(pCreateInfo)) |
| 608 |
return wsi_common_create_swapchain_image(&pdev->wsi_device, pCreateInfo, |
| 609 |
pImage); |
| 610 |
|
| 611 |
image = vk_zalloc2(&dev->vk.alloc, pAllocator, sizeof(*image), 8, |
| 612 |
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT); |
| 613 |
if (!image) |
| 614 |
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY); |
| 615 |
|
| 616 |
result = kk_image_init(dev, image, pCreateInfo); |
| 617 |
if (result != VK_SUCCESS) { |
| 618 |
vk_free2(&dev->vk.alloc, pAllocator, image); |
| 619 |
return result; |
| 620 |
} |
| 621 |
|
| 622 |
*pImage = kk_image_to_handle(image); |
| 623 |
|
| 624 |
return VK_SUCCESS; |
| 625 |
} |
| 626 |
|
| 627 |
VKAPI_ATTR void VKAPI_CALL |
| 628 |
kk_DestroyImage(VkDevice device, VkImage _image, |
| 629 |
const VkAllocationCallbacks *pAllocator) |
| 630 |
{ |
| 631 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 632 |
VK_FROM_HANDLE(kk_image, image, _image); |
| 633 |
|
| 634 |
if (!image) |
| 635 |
return; |
| 636 |
|
| 637 |
kk_image_finish(dev, image, pAllocator); |
| 638 |
vk_free2(&dev->vk.alloc, pAllocator, image); |
| 639 |
} |
| 640 |
|
| 641 |
static void |
| 642 |
kk_image_plane_add_req(struct kk_device *dev, const struct kk_image *image, |
| 643 |
const struct kk_image_plane *plane, uint64_t *size_B, |
| 644 |
uint32_t *align_B) |
| 645 |
{ |
| 646 |
assert(util_is_power_of_two_or_zero64(*align_B)); |
| 647 |
uint64_t plane_size_B, plane_align_B; |
| 648 |
kk_image_plane_size_align_B(dev, image, plane, &plane_size_B, |
| 649 |
&plane_align_B); |
| 650 |
|
| 651 |
*align_B = MAX2(*align_B, plane_align_B); |
| 652 |
*size_B = align64(*size_B, plane_align_B); |
| 653 |
*size_B += plane_size_B; |
| 654 |
} |
| 655 |
|
| 656 |
static void |
| 657 |
kk_get_image_memory_requirements(struct kk_device *dev, struct kk_image *image, |
| 658 |
VkImageAspectFlags aspects, |
| 659 |
VkMemoryRequirements2 *pMemoryRequirements) |
| 660 |
{ |
| 661 |
struct kk_physical_device *pdev = kk_device_physical(dev); |
| 662 |
uint32_t memory_types = (1 << pdev->mem_type_count) - 1; |
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
if (image->vk.usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT) { |
| 668 |
for (uint32_t i = 0; i < pdev->mem_type_count; i++) { |
| 669 |
if (!(pdev->mem_types[i].propertyFlags & |
| 670 |
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) |
| 671 |
memory_types &= ~BITFIELD_BIT(i); |
| 672 |
} |
| 673 |
} |
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
uint64_t size_B = 0; |
| 678 |
uint32_t align_B = 0; |
| 679 |
if (image->disjoint) { |
| 680 |
uint8_t plane = kk_image_memory_aspects_to_plane(image, aspects); |
| 681 |
kk_image_plane_add_req(dev, image, &image->planes[plane], &size_B, |
| 682 |
&align_B); |
| 683 |
} else { |
| 684 |
for (unsigned plane = 0; plane < image->plane_count; plane++) { |
| 685 |
kk_image_plane_add_req(dev, image, &image->planes[plane], &size_B, |
| 686 |
&align_B); |
| 687 |
} |
| 688 |
} |
| 689 |
|
| 690 |
if (image->stencil_copy_temp.layout.size_B > 0) { |
| 691 |
kk_image_plane_add_req(dev, image, &image->stencil_copy_temp, &size_B, |
| 692 |
&align_B); |
| 693 |
} |
| 694 |
|
| 695 |
pMemoryRequirements->memoryRequirements.memoryTypeBits = memory_types; |
| 696 |
pMemoryRequirements->memoryRequirements.alignment = align_B; |
| 697 |
pMemoryRequirements->memoryRequirements.size = size_B; |
| 698 |
|
| 699 |
vk_foreach_struct_const(ext, pMemoryRequirements->pNext) { |
| 700 |
switch (ext->sType) { |
| 701 |
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS: { |
| 702 |
VkMemoryDedicatedRequirements *dedicated = (void *)ext; |
| 703 |
dedicated->prefersDedicatedAllocation = |
| 704 |
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT; |
| 705 |
dedicated->requiresDedicatedAllocation = |
| 706 |
image->vk.tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT; |
| 707 |
break; |
| 708 |
} |
| 709 |
default: |
| 710 |
vk_debug_ignored_stype(ext->sType); |
| 711 |
break; |
| 712 |
} |
| 713 |
} |
| 714 |
} |
| 715 |
|
| 716 |
VKAPI_ATTR void VKAPI_CALL |
| 717 |
kk_GetImageMemoryRequirements2(VkDevice device, |
| 718 |
const VkImageMemoryRequirementsInfo2 *pInfo, |
| 719 |
VkMemoryRequirements2 *pMemoryRequirements) |
| 720 |
{ |
| 721 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 722 |
VK_FROM_HANDLE(kk_image, image, pInfo->image); |
| 723 |
|
| 724 |
const VkImagePlaneMemoryRequirementsInfo *plane_info = |
| 725 |
vk_find_struct_const(pInfo->pNext, IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO); |
| 726 |
const VkImageAspectFlags aspects = |
| 727 |
image->disjoint ? plane_info->planeAspect : image->vk.aspects; |
| 728 |
|
| 729 |
kk_get_image_memory_requirements(dev, image, aspects, pMemoryRequirements); |
| 730 |
} |
| 731 |
|
| 732 |
VKAPI_ATTR void VKAPI_CALL |
| 733 |
kk_GetDeviceImageMemoryRequirements(VkDevice device, |
| 734 |
const VkDeviceImageMemoryRequirements *pInfo, |
| 735 |
VkMemoryRequirements2 *pMemoryRequirements) |
| 736 |
{ |
| 737 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 738 |
ASSERTED VkResult result; |
| 739 |
struct kk_image image = {0}; |
| 740 |
|
| 741 |
result = kk_image_init(dev, &image, pInfo->pCreateInfo); |
| 742 |
assert(result == VK_SUCCESS); |
| 743 |
|
| 744 |
const VkImageAspectFlags aspects = |
| 745 |
image.disjoint ? pInfo->planeAspect : image.vk.aspects; |
| 746 |
|
| 747 |
kk_get_image_memory_requirements(dev, &image, aspects, pMemoryRequirements); |
| 748 |
|
| 749 |
kk_image_finish(dev, &image, NULL); |
| 750 |
} |
| 751 |
|
| 752 |
VKAPI_ATTR void VKAPI_CALL |
| 753 |
kk_GetImageSparseMemoryRequirements2( |
| 754 |
VkDevice device, const VkImageSparseMemoryRequirementsInfo2 *pInfo, |
| 755 |
uint32_t *pSparseMemoryRequirementCount, |
| 756 |
VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) |
| 757 |
{ |
| 758 |
*pSparseMemoryRequirementCount = 0u; |
| 759 |
} |
| 760 |
|
| 761 |
VKAPI_ATTR void VKAPI_CALL |
| 762 |
kk_GetDeviceImageSparseMemoryRequirements( |
| 763 |
VkDevice device, const VkDeviceImageMemoryRequirements *pInfo, |
| 764 |
uint32_t *pSparseMemoryRequirementCount, |
| 765 |
VkSparseImageMemoryRequirements2 *pSparseMemoryRequirements) |
| 766 |
{ |
| 767 |
*pSparseMemoryRequirementCount = 0u; |
| 768 |
} |
| 769 |
|
| 770 |
static void |
| 771 |
kk_get_image_subresource_layout(struct kk_device *dev, struct kk_image *image, |
| 772 |
const VkImageSubresource2KHR *pSubresource, |
| 773 |
VkSubresourceLayout2KHR *pLayout) |
| 774 |
{ |
| 775 |
const VkImageSubresource *isr = &pSubresource->imageSubresource; |
| 776 |
|
| 777 |
const uint8_t p = kk_image_memory_aspects_to_plane(image, isr->aspectMask); |
| 778 |
const struct kk_image_plane *plane = &image->planes[p]; |
| 779 |
|
| 780 |
uint64_t offset_B = 0; |
| 781 |
if (!image->disjoint) { |
| 782 |
uint32_t align_B = 0; |
| 783 |
for (unsigned i = 0; i < p; i++) { |
| 784 |
kk_image_plane_add_req(dev, image, &image->planes[i], &offset_B, |
| 785 |
&align_B); |
| 786 |
} |
| 787 |
} |
| 788 |
|
| 789 |
pLayout->subresourceLayout = (VkSubresourceLayout){ |
| 790 |
.offset = offset_B, |
| 791 |
.size = plane->layout.size_B, |
| 792 |
.rowPitch = plane->layout.linear_stride_B, |
| 793 |
.arrayPitch = plane->layout.layer_stride_B, |
| 794 |
.depthPitch = 1u, |
| 795 |
}; |
| 796 |
} |
| 797 |
|
| 798 |
VKAPI_ATTR void VKAPI_CALL |
| 799 |
kk_GetImageSubresourceLayout2KHR(VkDevice device, VkImage _image, |
| 800 |
const VkImageSubresource2KHR *pSubresource, |
| 801 |
VkSubresourceLayout2KHR *pLayout) |
| 802 |
{ |
| 803 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 804 |
VK_FROM_HANDLE(kk_image, image, _image); |
| 805 |
|
| 806 |
kk_get_image_subresource_layout(dev, image, pSubresource, pLayout); |
| 807 |
} |
| 808 |
|
| 809 |
VKAPI_ATTR void VKAPI_CALL |
| 810 |
kk_GetDeviceImageSubresourceLayoutKHR( |
| 811 |
VkDevice device, const VkDeviceImageSubresourceInfoKHR *pInfo, |
| 812 |
VkSubresourceLayout2KHR *pLayout) |
| 813 |
{ |
| 814 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 815 |
ASSERTED VkResult result; |
| 816 |
struct kk_image image = {0}; |
| 817 |
|
| 818 |
result = kk_image_init(dev, &image, pInfo->pCreateInfo); |
| 819 |
assert(result == VK_SUCCESS); |
| 820 |
|
| 821 |
kk_get_image_subresource_layout(dev, &image, pInfo->pSubresource, pLayout); |
| 822 |
|
| 823 |
kk_image_finish(dev, &image, NULL); |
| 824 |
} |
| 825 |
|
| 826 |
static VkResult |
| 827 |
kk_image_plane_bind(struct kk_device *dev, struct kk_image *image, |
| 828 |
struct kk_image_plane *plane, struct kk_device_memory *mem, |
| 829 |
uint64_t *offset_B) |
| 830 |
{ |
| 831 |
uint64_t plane_size_B, plane_align_B; |
| 832 |
kk_image_plane_size_align_B(dev, image, plane, &plane_size_B, |
| 833 |
&plane_align_B); |
| 834 |
*offset_B = align64(*offset_B, plane_align_B); |
| 835 |
|
| 836 |
|
| 837 |
if (plane->layout.optimized_layout) |
| 838 |
plane->mtl_handle = mtl_new_texture_with_descriptor( |
| 839 |
mem->bo->mtl_handle, &plane->layout, *offset_B); |
| 840 |
else |
| 841 |
plane->mtl_handle = mtl_new_texture_with_descriptor_linear( |
| 842 |
mem->bo->map, &plane->layout, *offset_B); |
| 843 |
plane->addr = mem->bo->gpu + *offset_B; |
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
if (plane->layout.type == MTL_TEXTURE_TYPE_3D && |
| 848 |
(image->vk.create_flags & |
| 849 |
(VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT | |
| 850 |
VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT))) { |
| 851 |
struct kk_image_layout array_layout = plane->layout; |
| 852 |
array_layout.type = MTL_TEXTURE_TYPE_2D_ARRAY; |
| 853 |
array_layout.layers = array_layout.layers * array_layout.depth_px; |
| 854 |
array_layout.depth_px = 1u; |
| 855 |
plane->mtl_handle_array = mtl_new_texture_with_descriptor( |
| 856 |
mem->bo->mtl_handle, &array_layout, *offset_B); |
| 857 |
} |
| 858 |
|
| 859 |
*offset_B += plane_size_B; |
| 860 |
|
| 861 |
return VK_SUCCESS; |
| 862 |
} |
| 863 |
|
| 864 |
static VkResult |
| 865 |
kk_bind_image_memory(struct kk_device *dev, const VkBindImageMemoryInfo *info) |
| 866 |
{ |
| 867 |
VK_FROM_HANDLE(kk_device_memory, mem, info->memory); |
| 868 |
VK_FROM_HANDLE(kk_image, image, info->image); |
| 869 |
VkResult result; |
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
#ifdef KK_USE_WSI_PLATFORM |
| 874 |
const VkBindImageMemorySwapchainInfoKHR *swapchain_info = |
| 875 |
vk_find_struct_const(info->pNext, BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR); |
| 876 |
|
| 877 |
if (swapchain_info && swapchain_info->swapchain != VK_NULL_HANDLE) { |
| 878 |
VK_FROM_HANDLE(wsi_swapchain, swapchain, swapchain_info->swapchain); |
| 879 |
VkImage _wsi_image = |
| 880 |
swapchain->get_wsi_image(swapchain, swapchain_info->imageIndex)->image; |
| 881 |
VK_FROM_HANDLE(kk_image, wsi_img, _wsi_image); |
| 882 |
|
| 883 |
assert(image->plane_count == 1); |
| 884 |
assert(wsi_img->plane_count == 1); |
| 885 |
|
| 886 |
struct kk_image_plane *plane = &image->planes[0]; |
| 887 |
struct kk_image_plane *swapchain_plane = &wsi_img->planes[0]; |
| 888 |
|
| 889 |
|
| 890 |
plane->layout = swapchain_plane->layout; |
| 891 |
plane->mtl_handle = mtl_retain(swapchain_plane->mtl_handle); |
| 892 |
plane->mtl_handle_array = |
| 893 |
swapchain_plane->mtl_handle_array |
| 894 |
? mtl_retain(swapchain_plane->mtl_handle_array) |
| 895 |
: NULL; |
| 896 |
plane->addr = swapchain_plane->addr; |
| 897 |
|
| 898 |
return VK_SUCCESS; |
| 899 |
} |
| 900 |
#endif |
| 901 |
|
| 902 |
uint64_t offset_B = info->memoryOffset; |
| 903 |
if (image->disjoint) { |
| 904 |
const VkBindImagePlaneMemoryInfo *plane_info = |
| 905 |
vk_find_struct_const(info->pNext, BIND_IMAGE_PLANE_MEMORY_INFO); |
| 906 |
const uint8_t plane = |
| 907 |
kk_image_memory_aspects_to_plane(image, plane_info->planeAspect); |
| 908 |
result = |
| 909 |
kk_image_plane_bind(dev, image, &image->planes[plane], mem, &offset_B); |
| 910 |
if (result != VK_SUCCESS) |
| 911 |
return result; |
| 912 |
} else { |
| 913 |
for (unsigned plane = 0; plane < image->plane_count; plane++) { |
| 914 |
result = kk_image_plane_bind(dev, image, &image->planes[plane], mem, |
| 915 |
&offset_B); |
| 916 |
if (result != VK_SUCCESS) |
| 917 |
return result; |
| 918 |
} |
| 919 |
} |
| 920 |
|
| 921 |
if (image->stencil_copy_temp.layout.size_B > 0) { |
| 922 |
result = kk_image_plane_bind(dev, image, &image->stencil_copy_temp, mem, |
| 923 |
&offset_B); |
| 924 |
if (result != VK_SUCCESS) |
| 925 |
return result; |
| 926 |
} |
| 927 |
|
| 928 |
return VK_SUCCESS; |
| 929 |
} |
| 930 |
|
| 931 |
VKAPI_ATTR VkResult VKAPI_CALL |
| 932 |
kk_BindImageMemory2(VkDevice device, uint32_t bindInfoCount, |
| 933 |
const VkBindImageMemoryInfo *pBindInfos) |
| 934 |
{ |
| 935 |
VK_FROM_HANDLE(kk_device, dev, device); |
| 936 |
VkResult first_error_or_success = VK_SUCCESS; |
| 937 |
|
| 938 |
for (uint32_t i = 0; i < bindInfoCount; ++i) { |
| 939 |
VkResult result = kk_bind_image_memory(dev, &pBindInfos[i]); |
| 940 |
|
| 941 |
const VkBindMemoryStatusKHR *status = |
| 942 |
vk_find_struct_const(pBindInfos[i].pNext, BIND_MEMORY_STATUS_KHR); |
| 943 |
if (status != NULL && status->pResult != NULL) |
| 944 |
*status->pResult = VK_SUCCESS; |
| 945 |
|
| 946 |
if (first_error_or_success == VK_SUCCESS) |
| 947 |
first_error_or_success = result; |
| 948 |
} |
| 949 |
|
| 950 |
return first_error_or_success; |
| 951 |
} |
| 952 |
|
| 953 |
VKAPI_ATTR VkResult VKAPI_CALL |
| 954 |
kk_GetImageOpaqueCaptureDescriptorDataEXT( |
| 955 |
VkDevice _device, const VkImageCaptureDescriptorDataInfoEXT *pInfo, |
| 956 |
void *pData) |
| 957 |
{ |
| 958 |
return VK_SUCCESS; |
| 959 |
} |