comp: Use CLAMP_TO_EDGE for swapchains

Avoids sampling black at the edges of layers.
This commit is contained in:
Christoph Haag 2020-08-20 02:20:49 +02:00
parent 6c084e2cbf
commit cf5596adba
4 changed files with 13 additions and 7 deletions

View file

@ -382,7 +382,9 @@ vk_create_semaphore_from_native(struct vk_bundle *vk,
}
VkResult
vk_create_sampler(struct vk_bundle *vk, VkSampler *out_sampler)
vk_create_sampler(struct vk_bundle *vk,
VkSamplerAddressMode clamp_mode,
VkSampler *out_sampler)
{
VkSampler sampler;
VkResult ret;
@ -392,9 +394,9 @@ vk_create_sampler(struct vk_bundle *vk, VkSampler *out_sampler)
.magFilter = VK_FILTER_LINEAR,
.minFilter = VK_FILTER_LINEAR,
.mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
.addressModeU = clamp_mode,
.addressModeV = clamp_mode,
.addressModeW = clamp_mode,
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
.unnormalizedCoordinates = VK_FALSE,
};

View file

@ -372,7 +372,9 @@ vk_create_image_simple(struct vk_bundle *vk,
* @ingroup aux_vk
*/
VkResult
vk_create_sampler(struct vk_bundle *vk, VkSampler *out_sampler);
vk_create_sampler(struct vk_bundle *vk,
VkSamplerAddressMode clamp_mode,
VkSampler *out_sampler);
/*!
* @ingroup aux_vk

View file

@ -425,7 +425,8 @@ _init_frame_buffer(struct comp_layer_renderer *self,
&self->framebuffers[eye].image);
vk_check_error("vk_create_image_simple", res, false);
vk_create_sampler(vk, &self->framebuffers[eye].sampler);
vk_create_sampler(vk, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
&self->framebuffers[eye].sampler);
VkImageSubresourceRange subresource_range = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,

View file

@ -125,7 +125,8 @@ do_post_create_vulkan_setup(struct comp_compositor *c,
U_TYPED_ARRAY_CALLOC(VkImageView, info->array_size);
sc->images[i].array_size = info->array_size;
vk_create_sampler(&c->vk, &sc->images[i].sampler);
vk_create_sampler(&c->vk, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
&sc->images[i].sampler);
for (uint32_t layer = 0; layer < info->array_size; ++layer) {
VkImageSubresourceRange subresource_range = {