[vulkan] Add an undefined to shader-ro barrier

I guess it's kind of UB, but it's handy for images that will be
conditionally written by the GPU but need to be in shader-read-only for
draw calls and the validation layers can't tell that the layers won't be
used.
This commit is contained in:
Bill Currie 2023-08-02 17:51:04 +09:00
parent 00040c8900
commit 39bb433498
2 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,7 @@ typedef struct qfv_bufferbarrier_s {
enum {
qfv_LT_Undefined_to_TransferDst,
qfv_LT_Undefined_to_General,
qfv_LT_Undefined_to_ShaderReadOnly,
qfv_LT_TransferDst_to_TransferSrc,
qfv_LT_TransferDst_to_General,
qfv_LT_TransferDst_to_ShaderReadOnly,

View File

@ -57,6 +57,19 @@ const qfv_imagebarrier_t imageBarriers[] = {
{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }
},
},
[qfv_LT_Undefined_to_ShaderReadOnly] = {
.srcStages = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
.dstStages = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.barrier = {
VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, 0,
0,
VK_ACCESS_SHADER_READ_BIT,
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, 0,
{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 }
},
},
[qfv_LT_TransferDst_to_TransferSrc] = {
.srcStages = VK_PIPELINE_STAGE_TRANSFER_BIT,
.dstStages = VK_PIPELINE_STAGE_TRANSFER_BIT,