[vulkan] Add partial support for cube maps to OIT

Partial because frame buffer creation isn't handled yet (using six
layers), but using layer a layer capable view and shaders doesn't cause
problems (other than maybe slightly slower code).
This commit is contained in:
Bill Currie 2023-01-24 10:09:00 +09:00
parent 6d7a9e2bc2
commit 0ccee3032e
4 changed files with 7 additions and 5 deletions

View file

@ -17,4 +17,4 @@ layout (set = OIT_SET, binding = 1) buffer Fragments {
FragData fragments[];
};
layout (set = OIT_SET, binding = 2, r32i) coherent uniform iimage2D heads;
layout (set = OIT_SET, binding = 2, r32i) coherent uniform iimage2DArray heads;

View file

@ -6,7 +6,7 @@ BlendFrags (vec4 color)
#define MAX_FRAGMENTS 64
FragData frags[MAX_FRAGMENTS];
int numFrags = 0;
ivec2 coord = ivec2(gl_FragCoord.xy);
ivec3 coord = ivec3(gl_FragCoord.xy, gl_ViewIndex);
int index = imageLoad (heads, coord).r;
//FIXME use a heap and prioritize closer fragments

View file

@ -4,7 +4,7 @@ void
StoreFrag (vec4 color, float depth)
{
int index = atomicAdd (numFragments, 1);
ivec2 coord = ivec2(gl_FragCoord.xy);
ivec3 coord = ivec3(gl_FragCoord.xy, gl_ViewIndex);
if (index < maxFragments) {
int prevIndex = imageAtomicExchange (heads, coord, index);
fragments[index].color = color;

View file

@ -192,7 +192,7 @@ Vulkan_Translucent_CreateBuffers (vulkan_ctx_t *ctx, VkExtent2D extent)
.type = qfv_res_image_view,
.image_view = {
.image = i,
.type = VK_IMAGE_VIEW_TYPE_2D,
.type = VK_IMAGE_VIEW_TYPE_2D_ARRAY,
.format = VK_FORMAT_R32_SINT,
.aspect = VK_IMAGE_ASPECT_COLOR_BIT,
},
@ -268,6 +268,7 @@ translucent_clear (qfv_renderframe_t *rFrame)
qfv_imagebarrier_t ib = imageBarriers[qfv_LT_Undefined_to_TransferDst];
ib.barrier.image = tframe->heads;
ib.barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
dfunc->vkCmdPipelineBarrier (cmd, ib.srcStages, ib.dstStages,
0, 0, 0, 0, 0,
1, &ib.barrier);
@ -275,13 +276,14 @@ translucent_clear (qfv_renderframe_t *rFrame)
{ .int32 = {-1, -1, -1, -1} },
};
VkImageSubresourceRange ranges[] = {
{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 },
{ VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, VK_REMAINING_ARRAY_LAYERS },
};
dfunc->vkCmdClearColorImage (cmd, tframe->heads,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
clear_color, 1, ranges);
ib = imageBarriers[qfv_LT_TransferDst_to_General];
ib.barrier.image = tframe->heads;
ib.barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
dfunc->vkCmdPipelineBarrier (cmd, ib.srcStages, ib.dstStages,
0, 0, 0, 0, 0,
1, &ib.barrier);