Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 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 | |
jvanverth | e50f3e7 | 2016-03-28 07:03:06 -0700 | [diff] [blame] | 13 | #include "vk/GrVkDefines.h" |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 14 | |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 15 | class GrSamplerParams; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 16 | class GrVkGpu; |
| 17 | |
| 18 | |
| 19 | class GrVkSampler : public GrVkResource { |
| 20 | public: |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 21 | static GrVkSampler* Create(const GrVkGpu* gpu, const GrSamplerParams&, uint32_t mipLevels); |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 22 | |
| 23 | VkSampler sampler() const { return fSampler; } |
| 24 | |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 25 | // Helpers for hashing GrVkSampler |
Brian Salomon | 514baff | 2016-11-17 15:17:07 -0500 | [diff] [blame] | 26 | static uint16_t GenerateKey(const GrSamplerParams&, uint32_t mipLevels); |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 27 | |
jvanverth | 6234006 | 2016-04-26 08:01:44 -0700 | [diff] [blame] | 28 | static const uint16_t& GetKey(const GrVkSampler& sampler) { return sampler.fKey; } |
| 29 | static uint32_t Hash(const uint16_t& key) { return key; } |
jvanverth | 7ec9241 | 2016-07-06 09:24:57 -0700 | [diff] [blame] | 30 | |
| 31 | #ifdef SK_TRACE_VK_RESOURCES |
| 32 | void dumpInfo() const override { |
| 33 | SkDebugf("GrVkSampler: %d (%d refs)\n", fSampler, this->getRefCnt()); |
| 34 | } |
| 35 | #endif |
| 36 | |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 37 | private: |
jvanverth | 6234006 | 2016-04-26 08:01:44 -0700 | [diff] [blame] | 38 | GrVkSampler(VkSampler sampler, uint16_t key) : INHERITED(), fSampler(sampler), fKey(key) {} |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 39 | |
| 40 | void freeGPUData(const GrVkGpu* gpu) const override; |
| 41 | |
| 42 | VkSampler fSampler; |
jvanverth | 6234006 | 2016-04-26 08:01:44 -0700 | [diff] [blame] | 43 | uint16_t fKey; |
Greg Daniel | 164a9f0 | 2016-02-22 09:56:40 -0500 | [diff] [blame] | 44 | |
| 45 | typedef GrVkResource INHERITED; |
| 46 | }; |
| 47 | |
egdaniel | 8b6394c | 2016-03-04 07:35:10 -0800 | [diff] [blame] | 48 | #endif |