OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrVkSampler_DEFINED | 8 #ifndef GrVkSampler_DEFINED |
9 #define GrVkSampler_DEFINED | 9 #define GrVkSampler_DEFINED |
10 | 10 |
11 #include "GrVkResource.h" | 11 #include "GrVkResource.h" |
12 | 12 |
13 #include "vulkan/vulkan.h" | 13 #include "vulkan/vulkan.h" |
14 | 14 |
15 class GrTextureAccess; | 15 class GrTextureAccess; |
| 16 class GrTextureParams; |
16 class GrVkGpu; | 17 class GrVkGpu; |
17 | 18 |
18 | 19 |
19 class GrVkSampler : public GrVkResource { | 20 class GrVkSampler : public GrVkResource { |
20 public: | 21 public: |
21 static GrVkSampler* Create(const GrVkGpu* gpu, const GrTextureAccess& textur
eAccess); | 22 static GrVkSampler* Create(const GrVkGpu* gpu, const GrTextureParams&); |
22 | 23 |
23 VkSampler sampler() const { return fSampler; } | 24 VkSampler sampler() const { return fSampler; } |
24 | 25 |
| 26 // Helpers for hashing GrVkSampler |
| 27 static uint8_t GenerateKey(const GrTextureParams&); |
| 28 |
| 29 static const uint8_t& GetKey(const GrVkSampler& sampler) { return sampler.fK
ey; } |
| 30 static uint32_t Hash(const uint8_t& key) { return key; } |
25 private: | 31 private: |
26 GrVkSampler(VkSampler sampler) : INHERITED(), fSampler(sampler) {} | 32 GrVkSampler(VkSampler sampler, uint8_t key) : INHERITED(), fSampler(sampler)
, fKey(key) {} |
27 | 33 |
28 void freeGPUData(const GrVkGpu* gpu) const override; | 34 void freeGPUData(const GrVkGpu* gpu) const override; |
29 | 35 |
30 VkSampler fSampler; | 36 VkSampler fSampler; |
| 37 uint8_t fKey; |
31 | 38 |
32 typedef GrVkResource INHERITED; | 39 typedef GrVkResource INHERITED; |
33 }; | 40 }; |
34 | 41 |
35 #endif | 42 #endif |
| 43 |
OLD | NEW |