c/render: Add and use new samplers

This commit is contained in:
Jakob Bornecrantz 2023-05-18 19:00:07 +01:00
parent 7b8d3c0907
commit 8d738248b0
3 changed files with 48 additions and 3 deletions

View file

@ -580,7 +580,7 @@ render_compute_projection_timewarp(struct render_compute *crc,
VK_IMAGE_LAYOUT_GENERAL, //
subresource_range); //
VkSampler sampler = r->compute.default_sampler;
VkSampler sampler = r->samplers.clamp_to_edge;
VkSampler distortion_samplers[6] = {
sampler, sampler, sampler, sampler, sampler, sampler,
};
@ -700,7 +700,7 @@ render_compute_projection(struct render_compute *crc,
VK_IMAGE_LAYOUT_GENERAL, //
subresource_range); //
VkSampler sampler = r->compute.default_sampler;
VkSampler sampler = r->samplers.clamp_to_edge;
VkSampler distortion_samplers[6] = {
sampler, sampler, sampler, sampler, sampler, sampler,
};
@ -821,7 +821,7 @@ render_compute_clear(struct render_compute *crc, //
VK_IMAGE_LAYOUT_GENERAL, //
subresource_range); //
VkSampler sampler = r->compute.default_sampler;
VkSampler sampler = r->samplers.mock;
VkSampler src_samplers[2] = {sampler, sampler};
VkImageView src_image_views[2] = {r->mock.color.image_view, r->mock.color.image_view};
VkSampler distortion_samplers[6] = {sampler, sampler, sampler, sampler, sampler, sampler};

View file

@ -237,6 +237,21 @@ struct render_resources
//! Command buffer for recording everything.
VkCommandBuffer cmd;
struct
{
//! Sampler for mock/null images.
VkSampler mock;
//! Sampler that repeats the texture in all directions.
VkSampler repeat;
//! Sampler that clamps the coordinates to the edge in all directions.
VkSampler clamp_to_edge;
//! Sampler that clamps color samples to black in all directions.
VkSampler clamp_to_border_black;
} samplers;
struct
{
//! The binding index for the source texture.

View file

@ -575,6 +575,31 @@ render_resources_init(struct render_resources *r,
}
/*
* Common samplers.
*/
C(vk_create_sampler( //
vk, // vk_bundle
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // clamp_mode
&r->samplers.mock)); // out_sampler
C(vk_create_sampler( //
vk, // vk_bundle
VK_SAMPLER_ADDRESS_MODE_REPEAT, // clamp_mode
&r->samplers.repeat)); // out_sampler
C(vk_create_sampler( //
vk, // vk_bundle
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // clamp_mode
&r->samplers.clamp_to_edge)); // out_sampler
C(vk_create_sampler( //
vk, // vk_bundle
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, // clamp_mode
&r->samplers.clamp_to_border_black)); // out_sampler
/*
* Command buffer pool, needs to go first.
*/
@ -961,6 +986,11 @@ render_resources_close(struct render_resources *r)
struct vk_bundle *vk = r->vk;
D(Sampler, r->samplers.mock);
D(Sampler, r->samplers.repeat);
D(Sampler, r->samplers.clamp_to_edge);
D(Sampler, r->samplers.clamp_to_border_black);
D(ImageView, r->mock.color.image_view);
D(Image, r->mock.color.image);
DF(Memory, r->mock.color.memory);