aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/renderer_vulkan/pipeline_helper.h
diff options
context:
space:
mode:
authorWollnashorn <Wollnashorn@users.noreply.github.com>2023-06-16 13:26:44 +0200
committerWollnashorn <Wollnashorn@users.noreply.github.com>2023-06-16 13:45:14 +0200
commit2dc0ff79ece34286c7078922668fd9f0a19b47b7 (patch)
treea474956c3fdc432f7259c70337d2c304baf80740 /src/video_core/renderer_vulkan/pipeline_helper.h
parenta3b7b5b22af8ef83fc765afac9d6f6b8dac7f62b (diff)
video_core: Use sampler IDs instead pointers in the pipeline config
The previous approach of storing pointers returned by `GetGraphicsSampler`/`GetComputeSampler` caused UB, as these functions can cause reallocation of the sampler slot vector and therefore invalidate the pointers
Diffstat (limited to 'src/video_core/renderer_vulkan/pipeline_helper.h')
-rw-r--r--src/video_core/renderer_vulkan/pipeline_helper.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h
index 0a9dce937..71c783709 100644
--- a/src/video_core/renderer_vulkan/pipeline_helper.h
+++ b/src/video_core/renderer_vulkan/pipeline_helper.h
@@ -178,7 +178,7 @@ public:
inline void PushImageDescriptors(TextureCache& texture_cache,
GuestDescriptorQueue& guest_descriptor_queue,
const Shader::Info& info, RescalingPushConstant& rescaling,
- const Sampler**& samplers,
+ const VideoCommon::SamplerId*& samplers,
const VideoCommon::ImageViewInOut*& views) {
const u32 num_texture_buffers = Shader::NumDescriptors(info.texture_buffer_descriptors);
const u32 num_image_buffers = Shader::NumDescriptors(info.image_buffer_descriptors);
@@ -187,9 +187,10 @@ inline void PushImageDescriptors(TextureCache& texture_cache,
for (const auto& desc : info.texture_descriptors) {
for (u32 index = 0; index < desc.count; ++index) {
const VideoCommon::ImageViewId image_view_id{(views++)->id};
+ const VideoCommon::SamplerId sampler_id{*(samplers++)};
ImageView& image_view{texture_cache.GetImageView(image_view_id)};
const VkImageView vk_image_view{image_view.Handle(desc.type)};
- const Sampler& sampler{**(samplers++)};
+ const Sampler& sampler{texture_cache.GetSampler(sampler_id)};
const bool use_fallback_sampler{sampler.HasAddedAnisotropy() &&
!image_view.SupportsAnisotropy()};
const VkSampler vk_sampler{use_fallback_sampler ? sampler.HandleWithDefaultAnisotropy()