xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/vulkan/SamplerVk.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // SamplerVk.cpp:
7 //    Implements the class methods for SamplerVk.
8 //
9 
10 #include "libANGLE/renderer/vulkan/SamplerVk.h"
11 
12 #include "common/debug.h"
13 #include "libANGLE/Context.h"
14 #include "libANGLE/renderer/vulkan/vk_utils.h"
15 
16 namespace rx
17 {
18 
SamplerVk(const gl::SamplerState & state)19 SamplerVk::SamplerVk(const gl::SamplerState &state) : SamplerImpl(state) {}
20 
21 SamplerVk::~SamplerVk() = default;
22 
onDestroy(const gl::Context * context)23 void SamplerVk::onDestroy(const gl::Context *context)
24 {
25     mSampler.reset();
26 }
27 
syncState(const gl::Context * context,const bool dirty)28 angle::Result SamplerVk::syncState(const gl::Context *context, const bool dirty)
29 {
30     ContextVk *contextVk = vk::GetImpl(context);
31 
32     vk::Renderer *renderer = contextVk->getRenderer();
33     if (mSampler)
34     {
35         if (!dirty)
36         {
37             return angle::Result::Continue;
38         }
39         mSampler.reset();
40     }
41 
42     vk::SamplerDesc desc(contextVk, mState, false, nullptr, static_cast<angle::FormatID>(0));
43     ANGLE_TRY(renderer->getSamplerCache().getSampler(contextVk, desc, &mSampler));
44 
45     return angle::Result::Continue;
46 }
47 
48 }  // namespace rx
49