Skip to content

Commit

Permalink
vk: make validation not complain about first 2 RT frames
Browse files Browse the repository at this point in the history
Not sure what's happening with the rest, but first couple works.
  • Loading branch information
w23 committed May 1, 2024
1 parent fcd9c77 commit 660513f
Showing 3 changed files with 16 additions and 6 deletions.
13 changes: 9 additions & 4 deletions ref/vk/ray_resources.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "ray_resources.h"
#include "vk_core.h"
#include "vk_image.h"

#include "shaders/ray_interop.h" // FIXME temp for type validation
#include "vk_common.h"

#include <stdlib.h>

@@ -23,9 +22,13 @@ void R_VkResourcesPrepareDescriptorsValues(VkCommandBuffer cmdbuf, vk_resources_
const qboolean write = i >= args.write_begin;

if (res->type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) {
ASSERT(image_barriers_count < COUNTOF(image_barriers));

if (write) {
// No reads are happening
ASSERT(res->read.pipelines == 0);
//ASSERT(res->read.pipelines == 0);

src_stage_mask |= res->read.pipelines;

res->write = (ray_resource_state_t) {
.access_mask = VK_ACCESS_SHADER_WRITE_BIT,
@@ -36,7 +39,7 @@ void R_VkResourcesPrepareDescriptorsValues(VkCommandBuffer cmdbuf, vk_resources_
image_barriers[image_barriers_count++] = (VkImageMemoryBarrier) {
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
.image = src_value->image_object->image,
.srcAccessMask = 0,
.srcAccessMask = res->read.access_mask,
.dstAccessMask = res->write.access_mask,
.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
.newLayout = res->write.image_layout,
@@ -49,6 +52,8 @@ void R_VkResourcesPrepareDescriptorsValues(VkCommandBuffer cmdbuf, vk_resources_
},
};

// Mark that read would need a transition
res->read = (ray_resource_state_t){0};
} else {
// Write happened
ASSERT(res->write.pipelines != 0);
6 changes: 5 additions & 1 deletion ref/vk/vk_render.c
Original file line number Diff line number Diff line change
@@ -676,7 +676,11 @@ void VK_Render_FIXME_Barrier( VkCommandBuffer cmdbuf ) {
} };
vkCmdPipelineBarrier(cmdbuf,
VK_PIPELINE_STAGE_TRANSFER_BIT,
VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | (vk_core.rtx ? VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR | VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR : 0),
VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | (vk_core.rtx
? VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
| VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR
| VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
: 0),
0, 0, NULL, ARRAYSIZE(bmb), bmb, 0, NULL);
}
}
3 changes: 2 additions & 1 deletion ref/vk/vk_rtx.c
Original file line number Diff line number Diff line change
@@ -378,7 +378,8 @@ static void performTracing( vk_combuf_t *combuf, const perform_tracing_args_t* a
if (!res->name[0] || !res->image.image || res->source_index_plus_1 > 0)
continue;

res->resource.read = res->resource.write = (ray_resource_state_t){0};
//res->resource.read = res->resource.write = (ray_resource_state_t){0};
res->resource.write = (ray_resource_state_t){0};
}

DEBUG_BEGIN(cmdbuf, "yay tracing");

0 comments on commit 660513f

Please sign in to comment.