blob: 963060239fb501f99076685521f923e01503ded9 [file] [log] [blame]
Greg Daniel164a9f02016-02-22 09:56:40 -05001/*
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
jvanverthe50f3e72016-03-28 07:03:06 -070013#include "vk/GrVkDefines.h"
Greg Daniel164a9f02016-02-22 09:56:40 -050014
Brian Salomon514baff2016-11-17 15:17:07 -050015class GrSamplerParams;
Greg Daniel164a9f02016-02-22 09:56:40 -050016class GrVkGpu;
17
18
19class GrVkSampler : public GrVkResource {
20public:
Brian Salomon514baff2016-11-17 15:17:07 -050021 static GrVkSampler* Create(const GrVkGpu* gpu, const GrSamplerParams&, uint32_t mipLevels);
Greg Daniel164a9f02016-02-22 09:56:40 -050022
23 VkSampler sampler() const { return fSampler; }
24
egdaniel8b6394c2016-03-04 07:35:10 -080025 // Helpers for hashing GrVkSampler
Brian Salomon514baff2016-11-17 15:17:07 -050026 static uint16_t GenerateKey(const GrSamplerParams&, uint32_t mipLevels);
egdaniel8b6394c2016-03-04 07:35:10 -080027
jvanverth62340062016-04-26 08:01:44 -070028 static const uint16_t& GetKey(const GrVkSampler& sampler) { return sampler.fKey; }
29 static uint32_t Hash(const uint16_t& key) { return key; }
jvanverth7ec92412016-07-06 09:24:57 -070030
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 Daniel164a9f02016-02-22 09:56:40 -050037private:
jvanverth62340062016-04-26 08:01:44 -070038 GrVkSampler(VkSampler sampler, uint16_t key) : INHERITED(), fSampler(sampler), fKey(key) {}
Greg Daniel164a9f02016-02-22 09:56:40 -050039
40 void freeGPUData(const GrVkGpu* gpu) const override;
41
42 VkSampler fSampler;
jvanverth62340062016-04-26 08:01:44 -070043 uint16_t fKey;
Greg Daniel164a9f02016-02-22 09:56:40 -050044
45 typedef GrVkResource INHERITED;
46};
47
egdaniel8b6394c2016-03-04 07:35:10 -080048#endif