Skip to content

Commit 3a0eab5

Browse files
committed
Revert "(vulkan) vulkan_common optimizations"
This reverts commit 8147fbe.
1 parent 8147fbe commit 3a0eab5

2 files changed

Lines changed: 60 additions & 51 deletions

File tree

gfx/common/vulkan_common.c

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,9 +1344,7 @@ static void vulkan_acquire_clear_fences(gfx_ctx_vulkan_data_t *vk)
13441344
{
13451345
struct vulkan_context *ctx = &vk->context;
13461346
VkSemaphore sem = vk->context.swapchain_wait_semaphores[i];
1347-
#ifdef DEBUG
1348-
retro_assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
1349-
#endif
1347+
assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
13501348
ctx->swapchain_recycled_semaphores[ctx->num_recycled_acquire_semaphores++] = sem;
13511349
}
13521350
vk->context.swapchain_wait_semaphores[i] = VK_NULL_HANDLE;
@@ -1408,9 +1406,7 @@ static void vulkan_acquire_wait_fences(gfx_ctx_vulkan_data_t *vk)
14081406
{
14091407
struct vulkan_context *ctx = &vk->context;
14101408
VkSemaphore sem = vk->context.swapchain_wait_semaphores[index];
1411-
#ifdef DEBUG
1412-
retro_assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
1413-
#endif
1409+
assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
14141410
ctx->swapchain_recycled_semaphores[ctx->num_recycled_acquire_semaphores++] = sem;
14151411
}
14161412
vk->context.swapchain_wait_semaphores[index] = VK_NULL_HANDLE;
@@ -1473,10 +1469,8 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context,
14731469

14741470
chain->current = chain->current->next;
14751471
chain->offset = 0;
1476-
#ifdef DEBUG
14771472
/* This cannot possibly fail. */
14781473
retro_assert(vulkan_buffer_chain_suballoc(chain, len, range));
1479-
#endif
14801474
}
14811475
return true;
14821476
}
@@ -1603,16 +1597,15 @@ VkDescriptorSet vulkan_descriptor_manager_alloc(
16031597
}
16041598

16051599
manager->current->next = vulkan_alloc_descriptor_pool(device, manager);
1606-
#ifdef DEBUG
16071600
retro_assert(manager->current->next);
1608-
#endif
16091601

16101602
manager->current = manager->current->next;
16111603
manager->count = 0;
16121604
}
16131605
return manager->current->sets[manager->count++];
16141606
}
16151607

1608+
16161609
bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk,
16171610
enum vulkan_wsi_type type,
16181611
void *display, void *surface,
@@ -1879,9 +1872,7 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
18791872
}
18801873
}
18811874

1882-
#ifdef DEBUG
18831875
retro_assert(!(vk->context.flags & VK_CTX_FLAG_HAS_ACQUIRED_SWAPCHAIN));
1884-
#endif
18851876

18861877
if (vk->flags & VK_DATA_FLAG_EMULATING_MAILBOX)
18871878
{
@@ -1912,16 +1903,16 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
19121903
vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX);
19131904
vk->context.flags |= VK_CTX_FLAG_HAS_ACQUIRED_SWAPCHAIN;
19141905

1915-
/* Recycle the previous acquire semaphore rather than stalling the device.
1916-
* vkDeviceWaitIdle here was a significant hot-path bottleneck. */
1917-
if (vk->context.swapchain_acquire_semaphore != VK_NULL_HANDLE)
1906+
if (vk->context.swapchain_acquire_semaphore)
19181907
{
1919-
struct vulkan_context *ctx = &vk->context;
1920-
#ifdef DEBUG
1921-
retro_assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
1908+
#ifdef HAVE_THREADS
1909+
slock_lock(vk->context.queue_lock);
1910+
#endif
1911+
vkDeviceWaitIdle(vk->context.device);
1912+
vkDestroySemaphore(vk->context.device, vk->context.swapchain_acquire_semaphore, NULL);
1913+
#ifdef HAVE_THREADS
1914+
slock_unlock(vk->context.queue_lock);
19221915
#endif
1923-
ctx->swapchain_recycled_semaphores[ctx->num_recycled_acquire_semaphores++] =
1924-
vk->context.swapchain_acquire_semaphore;
19251916
}
19261917
vk->context.swapchain_acquire_semaphore = semaphore;
19271918
}
@@ -1932,9 +1923,7 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk)
19321923
{
19331924
struct vulkan_context *ctx = &vk->context;
19341925
VkSemaphore sem = semaphore;
1935-
#ifdef DEBUG
1936-
retro_assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
1937-
#endif
1926+
assert(ctx->num_recycled_acquire_semaphores < VULKAN_MAX_SWAPCHAIN_IMAGES);
19381927
ctx->swapchain_recycled_semaphores[ctx->num_recycled_acquire_semaphores++] = sem;
19391928
}
19401929
}

gfx/common/vulkan_common.h

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -146,40 +146,60 @@
146146
vkUpdateDescriptorSets(_device, 1, &write, 0, NULL); \
147147
}
148148

149-
/*
150-
* Vertex layout: two triangles forming a quad (CCW winding).
151-
* v0 (TL) -- v2/v4 (TR)
152-
* | / |
153-
* v1/v5 (BL) -- v3 (BR)
154-
*/
155149
#define VULKAN_WRITE_QUAD_VBO(pv, _x, _y, _width, _height, _tex_x, _tex_y, _tex_width, _tex_height, vulkan_color) \
156150
{ \
157151
float r = (vulkan_color)->r; \
158152
float g = (vulkan_color)->g; \
159153
float b = (vulkan_color)->b; \
160154
float a = (vulkan_color)->a; \
161-
float _x1 = (float)(_x); \
162-
float _y1 = (float)(_y); \
163-
float _x2 = _x1 + (float)(_width); \
164-
float _y2 = _y1 + (float)(_height); \
165-
float _tx1 = (float)(_tex_x); \
166-
float _ty1 = (float)(_tex_y); \
167-
float _tx2 = _tx1 + (float)(_tex_width); \
168-
float _ty2 = _ty1 + (float)(_tex_height); \
169-
/* Triangle 1: TL, BL, TR */ \
170-
pv[0].x = _x1; pv[0].y = _y1; pv[0].tex_x = _tx1; pv[0].tex_y = _ty1; \
171-
pv[0].color.r = r; pv[0].color.g = g; pv[0].color.b = b; pv[0].color.a = a; \
172-
pv[1].x = _x1; pv[1].y = _y2; pv[1].tex_x = _tx1; pv[1].tex_y = _ty2; \
173-
pv[1].color.r = r; pv[1].color.g = g; pv[1].color.b = b; pv[1].color.a = a; \
174-
pv[2].x = _x2; pv[2].y = _y1; pv[2].tex_x = _tx2; pv[2].tex_y = _ty1; \
175-
pv[2].color.r = r; pv[2].color.g = g; pv[2].color.b = b; pv[2].color.a = a; \
176-
/* Triangle 2: TR, BL, BR */ \
177-
pv[3].x = _x2; pv[3].y = _y2; pv[3].tex_x = _tx2; pv[3].tex_y = _ty2; \
178-
pv[3].color.r = r; pv[3].color.g = g; pv[3].color.b = b; pv[3].color.a = a; \
179-
pv[4].x = _x2; pv[4].y = _y1; pv[4].tex_x = _tx2; pv[4].tex_y = _ty1; \
180-
pv[4].color.r = r; pv[4].color.g = g; pv[4].color.b = b; pv[4].color.a = a; \
181-
pv[5].x = _x1; pv[5].y = _y2; pv[5].tex_x = _tx1; pv[5].tex_y = _ty2; \
182-
pv[5].color.r = r; pv[5].color.g = g; pv[5].color.b = b; pv[5].color.a = a; \
155+
pv[0].x = (_x) + 0.0f * (_width); \
156+
pv[0].y = (_y) + 0.0f * (_height); \
157+
pv[0].tex_x = (_tex_x) + 0.0f * (_tex_width); \
158+
pv[0].tex_y = (_tex_y) + 0.0f * (_tex_height); \
159+
pv[0].color.r = r; \
160+
pv[0].color.g = g; \
161+
pv[0].color.b = b; \
162+
pv[0].color.a = a; \
163+
pv[1].x = (_x) + 0.0f * (_width); \
164+
pv[1].y = (_y) + 1.0f * (_height); \
165+
pv[1].tex_x = (_tex_x) + 0.0f * (_tex_width); \
166+
pv[1].tex_y = (_tex_y) + 1.0f * (_tex_height); \
167+
pv[1].color.r = r; \
168+
pv[1].color.g = g; \
169+
pv[1].color.b = b; \
170+
pv[1].color.a = a; \
171+
pv[2].x = (_x) + 1.0f * (_width); \
172+
pv[2].y = (_y) + 0.0f * (_height); \
173+
pv[2].tex_x = (_tex_x) + 1.0f * (_tex_width); \
174+
pv[2].tex_y = (_tex_y) + 0.0f * (_tex_height); \
175+
pv[2].color.r = r; \
176+
pv[2].color.g = g; \
177+
pv[2].color.b = b; \
178+
pv[2].color.a = a; \
179+
pv[3].x = (_x) + 1.0f * (_width); \
180+
pv[3].y = (_y) + 1.0f * (_height); \
181+
pv[3].tex_x = (_tex_x) + 1.0f * (_tex_width); \
182+
pv[3].tex_y = (_tex_y) + 1.0f * (_tex_height); \
183+
pv[3].color.r = r; \
184+
pv[3].color.g = g; \
185+
pv[3].color.b = b; \
186+
pv[3].color.a = a; \
187+
pv[4].x = (_x) + 1.0f * (_width); \
188+
pv[4].y = (_y) + 0.0f * (_height); \
189+
pv[4].tex_x = (_tex_x) + 1.0f * (_tex_width); \
190+
pv[4].tex_y = (_tex_y) + 0.0f * (_tex_height); \
191+
pv[4].color.r = r; \
192+
pv[4].color.g = g; \
193+
pv[4].color.b = b; \
194+
pv[4].color.a = a; \
195+
pv[5].x = (_x) + 0.0f * (_width); \
196+
pv[5].y = (_y) + 1.0f * (_height); \
197+
pv[5].tex_x = (_tex_x) + 0.0f * (_tex_width); \
198+
pv[5].tex_y = (_tex_y) + 1.0f * (_tex_height); \
199+
pv[5].color.r = r; \
200+
pv[5].color.g = g; \
201+
pv[5].color.b = b; \
202+
pv[5].color.a = a; \
183203
}
184204

185205
/* We don't have to sync against previous TRANSFER,

0 commit comments

Comments
 (0)