47 VkDescriptorSetLayout desc_set_layouts[] = {
52 VkPushConstantRange push_constant_range_atrous = {
53 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
55 .size =
sizeof(uint32_t)
59 .setLayoutCount =
LENGTH(desc_set_layouts),
60 .pSetLayouts = desc_set_layouts,
61 .pushConstantRangeCount = 1,
62 .pPushConstantRanges = &push_constant_range_atrous
67 .setLayoutCount =
LENGTH(desc_set_layouts),
68 .pSetLayouts = desc_set_layouts,
73 .setLayoutCount =
LENGTH(desc_set_layouts),
74 .pSetLayouts = desc_set_layouts,
93 VkSpecializationMapEntry specEntries[] = {
94 { .constantID = 0, .offset = 0, .size =
sizeof(uint32_t) }
97 uint32_t spec_data[] = {
104 VkSpecializationInfo specInfo[] = {
105 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[0] },
106 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[1] },
107 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[2] },
108 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[3] },
113 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
114 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_SEED_RNG_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
118 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
119 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_FWD_PROJECT_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
123 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
124 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_GRADIENT_IMG_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
128 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
129 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_GRADIENT_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
133 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
134 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_TEMPORAL_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
138 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
139 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_LF_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
143 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
144 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[0]),
148 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
149 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[1]),
153 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
154 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[2]),
158 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
159 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[3]),
163 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
164 .stage =
SHADER_STAGE(QVK_MOD_CHECKERBOARD_INTERLEAVE_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
168 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
169 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_TAA_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
173 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
174 .stage =
SHADER_STAGE(QVK_MOD_COMPOSITING_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
192 #define BARRIER_COMPUTE(cmd_buf, img) \
194 VkImageSubresourceRange subresource_range = { \
195 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, \
198 .baseArrayLayer = 0, \
201 IMAGE_BARRIER(cmd_buf, \
203 .subresourceRange = subresource_range, \
204 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, \
205 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT, \
206 .oldLayout = VK_IMAGE_LAYOUT_GENERAL, \
207 .newLayout = VK_IMAGE_LAYOUT_GENERAL, \
211 #define BARRIER_TO_CLEAR(cmd_buf, img) \
213 VkImageSubresourceRange subresource_range = { \
214 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, \
217 .baseArrayLayer = 0, \
220 IMAGE_BARRIER(cmd_buf, \
222 .subresourceRange = subresource_range, \
223 .srcAccessMask = 0, \
224 .dstAccessMask = 0, \
225 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED, \
226 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, \
230 #define BARRIER_FROM_CLEAR(cmd_buf, img) \
232 VkImageSubresourceRange subresource_range = { \
233 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, \
236 .baseArrayLayer = 0, \
239 IMAGE_BARRIER(cmd_buf, \
241 .subresourceRange = subresource_range, \
242 .srcAccessMask = 0, \
243 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT, \
244 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, \
245 .newLayout = VK_IMAGE_LAYOUT_GENERAL, \
253 VkDescriptorSet desc_sets[] = {
258 VkClearColorValue clear_grd_smpl_pos = {
259 .uint32 = { 0, 0, 0, 0 }
262 VkImageSubresourceRange subresource_range = {
263 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
270 int current_sample_pos_image = VKPT_IMG_ASVGF_GRAD_SMPL_POS_A + (
qvk.
frame_counter & 1);
273 vkCmdClearColorImage(cmd_buf,
qvk.
images[current_sample_pos_image],
274 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_grd_smpl_pos, 1, &subresource_range);
291 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
293 vkCmdDispatch(cmd_buf,
303 if (do_gradient_samples)
308 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
310 vkCmdDispatch(cmd_buf,
327 VkDescriptorSet desc_sets[] = {
341 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
343 vkCmdDispatch(cmd_buf,
353 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
357 const int num_atrous_iterations_gradient = 7;
358 for(
int i = 0; i < num_atrous_iterations_gradient; i++) {
368 vkCmdDispatch(cmd_buf,
382 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
384 vkCmdDispatch(cmd_buf,
402 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
406 const int num_atrous_iterations = 4;
407 for(
int i = 0; i < num_atrous_iterations; i++)
420 vkCmdDispatch(cmd_buf,
425 if (i == num_atrous_iterations - 1)
434 vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
pipeline_asvgf[specialization]);
435 vkCmdDispatch(cmd_buf,
462 VkDescriptorSet desc_sets[] = {
476 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
479 vkCmdDispatch(cmd_buf,
494 VkDescriptorSet desc_sets[] = {
500 #ifdef VKPT_DEVICE_GROUPS
505 VkOffset2D offset_left = { 0, 0 };
509 vkpt_mgpu_image_copy(cmd_buf,
518 vkpt_mgpu_image_copy(cmd_buf,
519 VKPT_IMG_ASVGF_COLOR,
520 VKPT_IMG_ASVGF_COLOR,
527 vkpt_mgpu_global_barrier(cmd_buf);
536 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
542 vkCmdDispatch(cmd_buf,
557 VkDescriptorSet desc_sets[] = {
566 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
572 dispatch_size.width += 8;
575 dispatch_size.height += 8;
577 vkCmdDispatch(cmd_buf,
578 (dispatch_size.width + 15) / 16,
579 (dispatch_size.height + 15) / 16,