Skip to content

Commit 3f66d8c

Browse files
committed
Fix Validation error in blit path that fails for Mali devices
1 parent 4d04bcc commit 3f66d8c

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/vulkan/wsi/wsi_common.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,25 @@ int __android_log_print(
388388
...
389389
);
390390

391-
#define LOG_A(...) __android_log_print(6, "Wrapper", __VA_ARGS__)
391+
int should_log(void);
392+
393+
void wlog(const char* fmt, ...);
394+
395+
#define LOG_A(...) __android_log_print(6, "VkWrapper", __VA_ARGS__)
396+
397+
#define W_WFORMAT(fmt, ...) fmt " \t (%s:%d)", ## __VA_ARGS__, __FUNCTION__, __LINE__
398+
399+
#define W___WLOG__(LEVEL, fmt, ...) \
400+
if (should_log() >= LEVEL) { \
401+
wlog(W_WFORMAT(fmt, ## __VA_ARGS__)); \
402+
LOG_A(W_WFORMAT(fmt, ## __VA_ARGS__)); \
403+
}
404+
405+
#define WSI_LOGT(fmt, ...) W___WLOG__(4, "" fmt, ## __VA_ARGS__)
406+
#define WSI_LOGA(fmt, ...) W___WLOG__(5, "! " fmt, ## __VA_ARGS__)
407+
#define WSI_LOGD(fmt, ...) W___WLOG__(3, fmt, ## __VA_ARGS__)
408+
#define WSI_LOG(fmt, ...) W___WLOG__(2, fmt, ## __VA_ARGS__)
409+
#define WSI_LOGE(fmt, ...) W___WLOG__(1, "[ERROR] " fmt, ## __VA_ARGS__)
392410

393411
#ifdef __cplusplus
394412
}

src/vulkan/wsi/wsi_common_ahardware_buffer.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ wsi_create_ahardware_buffer_image_mem(const struct wsi_swapchain *chain,
7575
const struct wsi_image_info *info,
7676
struct wsi_image *image)
7777
{
78-
LOG_A("In wsi_create_ahardware_buffer_image_mem");
78+
WSI_LOGT("not blitting");
7979
const struct wsi_device *wsi = chain->wsi;
8080
VkImage old_image = image->image;
8181
VkResult result;
@@ -129,7 +129,7 @@ wsi_create_ahardware_buffer_image_mem(const struct wsi_swapchain *chain,
129129
};
130130
result = wsi->AllocateMemory(chain->device, &memory_info,
131131
&chain->alloc, &image->memory);
132-
LOG_A("wsi->AllocateMemory: %d", result);
132+
WSI_LOGT("wsi->AllocateMemory: %d", result);
133133
if (result != VK_SUCCESS)
134134
return vk_errorf(NULL, result, "Failed to allocate memory");
135135
image->num_planes = 1;
@@ -142,6 +142,7 @@ wsi_create_ahardware_buffer_blit_context(const struct wsi_swapchain *chain,
142142
const struct wsi_image_info *info,
143143
struct wsi_image *image)
144144
{
145+
WSI_LOGT("blitting");
145146
assert(chain->blit.type == WSI_SWAPCHAIN_IMAGE_BLIT);
146147
const struct wsi_device *wsi = chain->wsi;
147148
VkResult result;
@@ -172,7 +173,7 @@ wsi_create_ahardware_buffer_blit_context(const struct wsi_swapchain *chain,
172173
.pNext = &external_format,
173174
.handleTypes = handle_types,
174175
};
175-
const VkImageCreateInfo image_info = {
176+
VkImageCreateInfo image_info = {
176177
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
177178
.pNext = &external_memory_info,
178179
.flags = 0u,
@@ -191,6 +192,20 @@ wsi_create_ahardware_buffer_blit_context(const struct wsi_swapchain *chain,
191192
info->create.pQueueFamilyIndices,
192193
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
193194
};
195+
196+
// VVL if external_format.externalFormat
197+
// Validation Error: [ VUID-VkImageCreateInfo-pNext-01974 ] | MessageID = 0xee97da05
198+
// vkCreateImage(): pCreateInfo->pNext<VkExternalFormatANDROID>.externalFormat (40) is non-zero, format is VK_FORMAT_R8G8B8A8_UNORM.
199+
// Validation Error: [ VUID-VkImageCreateInfo-pNext-02397 ] | MessageID = 0xcac730da
200+
// vkCreateImage(): pCreateInfo->pNext<VkExternalFormatANDROID>.externalFormat (40) is non-zero, but usage is VK_IMAGE_USAGE_TRANSFER_DST_BIT.
201+
// Validation Error: [ VUID-VkImageCreateInfo-pNext-02398 ] | MessageID = 0xc94b7919
202+
// vkCreateImage(): pCreateInfo->pNext<VkExternalFormatANDROID>.externalFormat (40) is non-zero, but layout is VK_IMAGE_TILING_LINEAR.
203+
if (external_format.externalFormat != 0) {
204+
image_info.format = VK_FORMAT_UNDEFINED;
205+
image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
206+
image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
207+
}
208+
194209
result = wsi->CreateImage(chain->device, &image_info,
195210
&chain->alloc, &image->blit.image);
196211
if (result != VK_SUCCESS)

0 commit comments

Comments
 (0)