Skip to content

Commit dffaf58

Browse files
fix: vulkan validation layers
1 parent 33adbf4 commit dffaf58

7 files changed

Lines changed: 41 additions & 3 deletions

File tree

‎docs/changelog.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ away, please see git history for details.
99
(draw) add draw callbacks
1010
(starter) added reverse z depth buffer support (v1.3.0)
1111
(graphics) fix draw_indexed multiple index buffers (v1.5.1)
12+
(graphics) fix new validation layer errors (v1.5.2)
1213
- v0.6.2 (2025-10-08) (draw) performance improvements
1314
(draw) fix draw 3d plane issues
1415
(draw) add text transforms

‎docs/version.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ the API is complete. It just means we won't break what currently exists.
6060
* Draw Backend v1.1.0 (pl_draw_backend_ext.h)
6161
* DXT v1.0.0 (pl_dxt_ext.h)
6262
* GPU Allocators v1.0.0 (pl_gpu_allocators_ext.h)
63-
* Graphics v1.5.1 (pl_graphics_ext.h)
63+
* Graphics v1.5.2 (pl_graphics_ext.h)
6464
* Image v1.0.0 (pl_image_ext.h)
6565
* Job v2.2.0 (pl_job_ext.h)
6666
* Atomics v1.0.0 (pl_platform_ext.h)

‎extensions/pl_graphics_cpu.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ pl_set_texture_usage(plBlitEncoder* ptEncoder, plTextureHandle tHandle, plTextur
437437
{
438438
}
439439

440+
void
441+
pl_set_texture_usage(plBlitEncoder* ptEncoder, plTextureHandle tHandle, plTextureUsage tNewUsage, plTextureUsage tOldUsage)
442+
{
443+
}
444+
440445
void
441446
pl_bind_texture_to_memory(plDevice* ptDevice, plTextureHandle tHandle, const plDeviceMemoryAllocation* ptAllocation)
442447
{

‎extensions/pl_graphics_ext.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,7 @@ pl_load_graphics_ext(plApiRegistryI* ptApiRegistry, bool bReload)
11951195
.begin_blit_pass = pl_begin_blit_pass,
11961196
.end_blit_pass = pl_end_blit_pass,
11971197
.set_texture_usage = pl_set_texture_usage,
1198+
.set_texture_usage_ex = pl_set_texture_usage_ex,
11981199
.draw_stream = pl_draw_stream,
11991200
.draw = pl_draw,
12001201
.draw_indexed = pl_draw_indexed,

‎extensions/pl_graphics_ext.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Index of this file:
114114
// [SECTION] apis
115115
//-----------------------------------------------------------------------------
116116

117-
#define plGraphicsI_version {1, 5, 1}
117+
#define plGraphicsI_version {1, 5, 2}
118118

119119
//-----------------------------------------------------------------------------
120120
// [SECTION] includes
@@ -410,6 +410,7 @@ typedef struct _plGraphicsI
410410
plBlitEncoder* (*begin_blit_pass) (plCommandBuffer*); // do not store
411411
void (*end_blit_pass) (plBlitEncoder*);
412412
void (*set_texture_usage) (plBlitEncoder*, plTextureHandle, plTextureUsage tNewUsage, plTextureUsage tOldUsage);
413+
void (*set_texture_usage_ex) (plBlitEncoder*, plTextureHandle, plTextureUsage tNewUsage, plTextureUsage tOldUsage, plPipelineStageFlags tNewStages, plPipelineStageFlags tOldStages);
413414
void (*copy_buffer_to_texture) (plBlitEncoder*, plBufferHandle, plTextureHandle, uint32_t regionCount, const plBufferImageCopy*);
414415
void (*copy_texture_to_buffer) (plBlitEncoder*, plTextureHandle, plBufferHandle, uint32_t regionCount, const plBufferImageCopy*);
415416
void (*copy_texture) (plBlitEncoder*, plTextureHandle src, plTextureHandle dst, uint32_t regionCount, const plImageCopy*);

‎extensions/pl_graphics_metal.m‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,11 @@
22942294
{
22952295
}
22962296

2297+
void
2298+
pl_set_texture_usage(plBlitEncoder* ptEncoder, plTextureHandle tHandle, plTextureUsage tNewUsage, plTextureUsage tOldUsage)
2299+
{
2300+
}
2301+
22972302
static plBlitEncoder*
22982303
pl_begin_blit_pass(plCommandBuffer* ptCmdBuffer)
22992304
{

‎extensions/pl_graphics_vulkan.c‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,30 @@ pl_set_texture_usage(plBlitEncoder* ptEncoder, plTextureHandle tHandle, plTextur
13561356
pl__transition_image_layout(ptCmdBuffer->tCmdBuffer, ptVulkanTexture->tImage, pl__vulkan_layout(tOldUsage), pl__vulkan_layout(tNewUsage), tRange, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
13571357
}
13581358

1359+
void
1360+
pl_set_texture_usage_ex(plBlitEncoder* ptEncoder, plTextureHandle tHandle, plTextureUsage tNewUsage, plTextureUsage tOldUsage, plPipelineStageFlags tNewStages, plPipelineStageFlags tOldStages)
1361+
{
1362+
plCommandBuffer* ptCmdBuffer = ptEncoder->ptCommandBuffer;
1363+
plDevice* ptDevice = ptCmdBuffer->ptDevice;
1364+
1365+
plTexture* ptTexture = pl__get_texture(ptDevice, tHandle);
1366+
plVulkanTexture* ptVulkanTexture = &ptDevice->sbtTexturesHot[tHandle.uIndex];
1367+
1368+
VkImageAspectFlags tImageAspectFlags = ptTexture->tDesc.tUsage & PL_TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
1369+
1370+
if (pl__format_has_stencil(pl__vulkan_format(ptTexture->tDesc.tFormat)))
1371+
tImageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
1372+
1373+
VkImageSubresourceRange tRange = {
1374+
.baseMipLevel = 0,
1375+
.levelCount = ptTexture->tDesc.uMips,
1376+
.baseArrayLayer = 0,
1377+
.layerCount = ptTexture->tDesc.uLayers,
1378+
.aspectMask = tImageAspectFlags
1379+
};
1380+
pl__transition_image_layout(ptCmdBuffer->tCmdBuffer, ptVulkanTexture->tImage, pl__vulkan_layout(tOldUsage), pl__vulkan_layout(tNewUsage), tRange, pl_vulkan_pipeline_stage_flags(tOldStages), pl_vulkan_pipeline_stage_flags(tNewStages));
1381+
}
1382+
13591383
void
13601384
pl_bind_texture_to_memory(plDevice* ptDevice, plTextureHandle tHandle, const plDeviceMemoryAllocation* ptAllocation)
13611385
{
@@ -4937,7 +4961,8 @@ pl__transition_image_layout(VkCommandBuffer tCommandBuffer, VkImage tImage, VkIm
49374961
// Image will be read in a shader (sampler, input attachment)
49384962
// Make sure any writes to the image have been finished
49394963
if (tBarrier.srcAccessMask == 0)
4940-
tBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
4964+
tBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
4965+
// tBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
49414966
tBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
49424967
break;
49434968
default:

0 commit comments

Comments
 (0)