rtx: fix pre-denoise barriers, remove feedback from rgen

This commit is contained in:
Ivan 'provod' Avdeev 2021-11-07 09:21:15 -08:00 committed by Ivan Avdeev
parent e6db0fde45
commit c89dfee7b8
2 changed files with 4 additions and 29 deletions

View File

@ -35,8 +35,6 @@ layout (set = 0, binding = 8, align = 1) readonly buffer UBOLightClusters {
LightCluster clusters[MAX_LIGHT_CLUSTERS]; LightCluster clusters[MAX_LIGHT_CLUSTERS];
} light_grid; } light_grid;
layout(set = 0, binding = 9, rgba8) uniform readonly image2D previous_frame;
layout (push_constant) uniform PC_ { layout (push_constant) uniform PC_ {
PushConstants push_constants; PushConstants push_constants;
}; };
@ -440,14 +438,6 @@ void main() {
throughput *= brdfWeight; throughput *= brdfWeight;
} // for all bounces } // for all bounces
if (false)
{
vec3 prev_frame = imageLoad(previous_frame, ivec2(gl_LaunchIDEXT.xy)).rgb;
prev_frame *= prev_frame;
prev_frame *= color_factor;
C = mix(C, prev_frame, push_constants.prev_frame_blend_factor);
}
C /= color_factor; C /= color_factor;
C = aces_tonemap(C); C = aces_tonemap(C);

View File

@ -71,8 +71,6 @@ enum {
RayDescBinding_Lights = 7, RayDescBinding_Lights = 7,
RayDescBinding_LightClusters = 8, RayDescBinding_LightClusters = 8,
RayDescBinding_PrevFrame = 9,
RayDescBinding_COUNT RayDescBinding_COUNT
}; };
@ -559,7 +557,7 @@ static void prepareTlas( VkCommandBuffer cmdbuf ) {
createTlas(cmdbuf); createTlas(cmdbuf);
} }
static void updateDescriptors( VkCommandBuffer cmdbuf, const vk_ray_frame_render_args_t *args, const vk_image_t *frame_src, const vk_image_t *frame_dst ) { static void updateDescriptors( VkCommandBuffer cmdbuf, const vk_ray_frame_render_args_t *args, const vk_image_t *frame_dst ) {
// 3. Update descriptor sets (bind dest image, tlas, projection matrix) // 3. Update descriptor sets (bind dest image, tlas, projection matrix)
VkDescriptorImageInfo dii_all_textures[MAX_TEXTURES]; VkDescriptorImageInfo dii_all_textures[MAX_TEXTURES];
@ -569,12 +567,6 @@ static void updateDescriptors( VkCommandBuffer cmdbuf, const vk_ray_frame_render
.imageLayout = VK_IMAGE_LAYOUT_GENERAL, .imageLayout = VK_IMAGE_LAYOUT_GENERAL,
}; };
g_rtx.desc_values[RayDescBinding_PrevFrame].image = (VkDescriptorImageInfo){
.sampler = VK_NULL_HANDLE,
.imageView = frame_src->view,
.imageLayout = VK_IMAGE_LAYOUT_GENERAL,
};
g_rtx.desc_values[RayDescBinding_TLAS].accel = (VkWriteDescriptorSetAccelerationStructureKHR){ g_rtx.desc_values[RayDescBinding_TLAS].accel = (VkWriteDescriptorSetAccelerationStructureKHR){
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR, .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
.accelerationStructureCount = 1, .accelerationStructureCount = 1,
@ -835,7 +827,7 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
} }
} else { } else {
prepareTlas(cmdbuf); prepareTlas(cmdbuf);
updateDescriptors(cmdbuf, args, frame_src, frame_dst); updateDescriptors(cmdbuf, args, frame_dst);
rayTrace(cmdbuf, frame_dst->image, args->fov_angle_y); rayTrace(cmdbuf, frame_dst->image, args->fov_angle_y);
// Barrier for frame_dst image // Barrier for frame_dst image
@ -847,7 +839,7 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT, .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
.newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
.subresourceRange = .subresourceRange =
(VkImageSubresourceRange){ (VkImageSubresourceRange){
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
@ -884,7 +876,7 @@ void VK_RayFrameEnd(const vk_ray_frame_render_args_t* args)
const xvk_denoiser_args_t denoiser_args = { const xvk_denoiser_args_t denoiser_args = {
.cmdbuf = cmdbuf, .cmdbuf = cmdbuf,
.in = { .in = {
.image_view = frame_src->view, .image_view = frame_dst->view,
.width = FRAME_WIDTH, .width = FRAME_WIDTH,
.height = FRAME_HEIGHT, .height = FRAME_HEIGHT,
}, },
@ -1006,13 +998,6 @@ static void createLayouts( void ) {
.stageFlags = VK_SHADER_STAGE_RAYGEN_BIT_KHR, .stageFlags = VK_SHADER_STAGE_RAYGEN_BIT_KHR,
}; };
g_rtx.desc_bindings[RayDescBinding_PrevFrame] = (VkDescriptorSetLayoutBinding){
.binding = RayDescBinding_PrevFrame,
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
.descriptorCount = 1,
.stageFlags = VK_SHADER_STAGE_RAYGEN_BIT_KHR,
};
VK_DescriptorsCreate(&g_rtx.descriptors); VK_DescriptorsCreate(&g_rtx.descriptors);
} }