From 20369dd9ab622f423d9499b07587d548365b16cb Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Sun, 3 Oct 2021 10:30:06 -0700 Subject: [PATCH] rtx: move push constant definition to a common place; specialize shader constants --- ref_vk/shaders/ray.rgen | 9 +++------ ref_vk/shaders/ray_interop.h | 7 +++++++ ref_vk/vk_const.h | 4 ++-- ref_vk/vk_rtx.c | 8 ++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ref_vk/shaders/ray.rgen b/ref_vk/shaders/ray.rgen index 629a138e..357a994a 100644 --- a/ref_vk/shaders/ray.rgen +++ b/ref_vk/shaders/ray.rgen @@ -59,12 +59,9 @@ layout (set = 0, binding = 8, align = 1) readonly buffer UBOLightClusters { layout(set = 0, binding = 9, rgba8) uniform readonly image2D previous_frame; -layout (push_constant) uniform PushConstants { - uint random_seed; - int bounces; - float prev_frame_blend_factor; - float pixel_cone_spread_angle; -} push_constants; +layout (push_constant) uniform PC__ { + PushConstants push_constants; +}; layout(location = 0) rayPayloadEXT RayPayload payload; layout(location = 1) rayPayloadEXT bool shadow; diff --git a/ref_vk/shaders/ray_interop.h b/ref_vk/shaders/ray_interop.h index 3cfe01ee..419e724b 100644 --- a/ref_vk/shaders/ray_interop.h +++ b/ref_vk/shaders/ray_interop.h @@ -35,6 +35,13 @@ struct PointLight { vec4 color; }; +struct PushConstants { + uint random_seed; + int bounces; + float prev_frame_blend_factor; + float pixel_cone_spread_angle; +}; + #ifndef GLSL #undef uint #undef vec3 diff --git a/ref_vk/vk_const.h b/ref_vk/vk_const.h index 4f024f7a..79b3abc7 100644 --- a/ref_vk/vk_const.h +++ b/ref_vk/vk_const.h @@ -12,5 +12,5 @@ #define MAX_POINT_LIGHTS 255 #define MAX_VISIBLE_POINT_LIGHTS 31 #define MAX_VISIBLE_SURFACE_LIGHTS 255 -#define MAX_LIGHT_CLUSTERS 32768 -#define LIGHT_GRID_CELL_SIZE 256 +#define MAX_LIGHT_CLUSTERS 262144 //131072 //32768 +#define LIGHT_GRID_CELL_SIZE 128 diff --git a/ref_vk/vk_rtx.c b/ref_vk/vk_rtx.c index 23918fd9..bdd016d4 100644 --- a/ref_vk/vk_rtx.c +++ b/ref_vk/vk_rtx.c @@ -45,12 +45,7 @@ typedef struct { float padding_; } vk_light_t; -typedef struct { - uint32_t random_seed; - int bounces; - float prev_frame_blend_factor; - float pixel_cone_spread_angle; -} vk_rtx_push_constants_t; +typedef struct PushConstants vk_rtx_push_constants_t; typedef struct { int min_cell[4], size[3]; // 4th element is padding @@ -377,6 +372,7 @@ static void createPipeline( void ) .stage = VK_SHADER_STAGE_##bit##_BIT_KHR, \ .module = loadShader(filename), \ .pName = "main", \ + .pSpecializationInfo = &spec, \ } VkPipelineShaderStageCreateInfo shaders[ShaderStageIndex_COUNT];