• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright 2016 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 
8 #ifndef GrVkSampler_DEFINED
9 #define GrVkSampler_DEFINED
10 
11 #include "GrVkResource.h"
12 
13 #include "vk/GrVkDefines.h"
14 
15 class GrSamplerState;
16 class GrVkGpu;
17 
18 
19 class GrVkSampler : public GrVkResource {
20 public:
21     static GrVkSampler* Create(const GrVkGpu* gpu, const GrSamplerState&, uint32_t maxMipLevel);
22 
sampler()23     VkSampler sampler() const { return fSampler; }
24 
25     // Helpers for hashing GrVkSampler
26     static uint16_t GenerateKey(const GrSamplerState&, uint32_t maxMipLevel);
27 
GetKey(const GrVkSampler & sampler)28     static const uint16_t& GetKey(const GrVkSampler& sampler) { return sampler.fKey; }
Hash(const uint16_t & key)29     static uint32_t Hash(const uint16_t& key) { return key; }
30 
31 #ifdef SK_TRACE_VK_RESOURCES
dumpInfo()32     void dumpInfo() const override {
33         SkDebugf("GrVkSampler: %d (%d refs)\n", fSampler, this->getRefCnt());
34     }
35 #endif
36 
37 private:
GrVkSampler(VkSampler sampler,uint16_t key)38     GrVkSampler(VkSampler sampler, uint16_t key) : INHERITED(), fSampler(sampler), fKey(key) {}
39 
40     void freeGPUData(const GrVkGpu* gpu) const override;
41 
42     VkSampler  fSampler;
43     uint16_t   fKey;
44 
45     typedef GrVkResource INHERITED;
46 };
47 
48 #endif
49