2021-11-05 09:11:40 -07:00
|
|
|
#include "vk_denoiser.h"
|
|
|
|
|
2022-01-31 20:50:39 -08:00
|
|
|
#include "ray_resources.h"
|
2022-01-30 22:24:55 -08:00
|
|
|
#include "ray_pass.h"
|
2021-11-05 12:08:15 -07:00
|
|
|
|
2022-01-31 20:40:41 -08:00
|
|
|
#define LIST_OUTPUTS(X) \
|
2022-01-28 22:58:07 -08:00
|
|
|
X(0, denoised) \
|
2022-01-31 20:40:41 -08:00
|
|
|
|
|
|
|
#define LIST_INPUTS(X) \
|
2022-01-28 22:58:07 -08:00
|
|
|
X(1, base_color_a) \
|
|
|
|
X(2, light_poly_diffuse) \
|
|
|
|
X(3, light_poly_specular) \
|
|
|
|
X(4, light_point_diffuse) \
|
|
|
|
X(5, light_point_specular) \
|
2022-02-02 19:04:45 -08:00
|
|
|
X(6, emissive) \
|
2022-02-04 18:38:36 -08:00
|
|
|
X(7, position_t) \
|
|
|
|
X(8, normals_gs) \
|
2021-11-05 09:11:40 -07:00
|
|
|
|
2022-01-30 22:24:55 -08:00
|
|
|
static const VkDescriptorSetLayoutBinding bindings[] = {
|
2022-01-28 22:58:07 -08:00
|
|
|
#define BIND_IMAGE(index, name) \
|
2022-01-30 22:24:55 -08:00
|
|
|
{ \
|
2022-01-28 22:58:07 -08:00
|
|
|
.binding = index, \
|
|
|
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, \
|
|
|
|
.descriptorCount = 1, \
|
|
|
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT, \
|
2022-01-30 22:24:55 -08:00
|
|
|
},
|
2022-01-31 20:40:41 -08:00
|
|
|
LIST_OUTPUTS(BIND_IMAGE)
|
|
|
|
LIST_INPUTS(BIND_IMAGE)
|
2022-01-28 22:58:07 -08:00
|
|
|
#undef BIND_IMAGE
|
2022-01-30 22:24:55 -08:00
|
|
|
};
|
2022-01-07 22:43:27 -08:00
|
|
|
|
2022-01-30 22:24:55 -08:00
|
|
|
static const int semantics[] = {
|
2022-01-31 20:40:41 -08:00
|
|
|
#define IN(index, name, ...) (RayResource_##name + 1),
|
|
|
|
#define OUT(index, name, ...) -(RayResource_##name + 1),
|
|
|
|
LIST_OUTPUTS(OUT)
|
|
|
|
LIST_INPUTS(IN)
|
|
|
|
#undef IN
|
|
|
|
#undef OUT
|
2022-01-30 22:24:55 -08:00
|
|
|
};
|
2021-11-05 09:11:40 -07:00
|
|
|
|
2022-01-30 22:24:55 -08:00
|
|
|
struct ray_pass_s *R_VkRayDenoiserCreate( void ) {
|
|
|
|
const ray_pass_create_compute_t rpcc = {
|
|
|
|
.debug_name = "denoiser",
|
|
|
|
.layout = {
|
|
|
|
.bindings = bindings,
|
|
|
|
.bindings_semantics = semantics,
|
|
|
|
.bindings_count = COUNTOF(bindings),
|
|
|
|
.push_constants = {0},
|
|
|
|
},
|
|
|
|
.shader = "denoiser.comp.spv",
|
|
|
|
.specialization = NULL,
|
|
|
|
};
|
2021-11-05 12:08:15 -07:00
|
|
|
|
2022-01-30 22:24:55 -08:00
|
|
|
return RayPassCreateCompute( &rpcc );
|
2021-11-07 12:46:27 -08:00
|
|
|
}
|
|
|
|
|