Skip to content

Commit

Permalink
Fixed a Vulkan validation layer error about a live sampler object at …
Browse files Browse the repository at this point in the history
…exit after changing resolution.
  • Loading branch information
apanteleev committed Oct 18, 2024
1 parent 4f0f557 commit 42e25a5
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/refresh/vkpt/god_rays.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ VkResult vkpt_initialize_god_rays(void)
god_rays.eccentricity = Cvar_Get("gr_eccentricity", "0.75", 0);
god_rays.enable = Cvar_Get("gr_enable", "1", 0);


VkSamplerReductionModeCreateInfo redutcion_create_info = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO,
.reductionMode = VK_SAMPLER_REDUCTION_MODE_MIN
};

const VkSamplerCreateInfo sampler_create_info = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = &redutcion_create_info,
.magFilter = VK_FILTER_LINEAR,
.minFilter = VK_FILTER_LINEAR,
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
};

_VK(vkCreateSampler(qvk.device, &sampler_create_info, NULL, &god_rays.shadow_sampler));

return VK_SUCCESS;
}

Expand Down Expand Up @@ -221,25 +241,6 @@ void vkpt_god_rays_prepare_ubo(
static void create_image_views(void)
{
god_rays.shadow_image_view = vkpt_shadow_map_get_view();

VkSamplerReductionModeCreateInfo redutcion_create_info = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO,
.reductionMode = VK_SAMPLER_REDUCTION_MODE_MIN
};

const VkSamplerCreateInfo sampler_create_info = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.pNext = &redutcion_create_info,
.magFilter = VK_FILTER_LINEAR,
.minFilter = VK_FILTER_LINEAR,
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
};

_VK(vkCreateSampler(qvk.device, &sampler_create_info, NULL, &god_rays.shadow_sampler));
}

static void create_pipeline_layout(void)
Expand Down

0 comments on commit 42e25a5

Please sign in to comment.