egdaniel | 09aa1fc | 2016-04-20 07:09:46 -0700 | [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 GrVkGLSLSampler_DEFINED |
| 9 | #define GrVkGLSLSampler_DEFINED |
| 10 | |
| 11 | #include "glsl/GrGLSLSampler.h" |
| 12 | |
| 13 | #include "glsl/GrGLSLShaderVar.h" |
| 14 | |
| 15 | class GrVkGLSLSampler : public GrGLSLSampler { |
| 16 | public: |
| 17 | GrVkGLSLSampler(uint32_t visibility, |
| 18 | GrPixelConfig config, |
| 19 | GrSLType type, |
| 20 | GrSLPrecision precision, |
| 21 | const char* name, |
| 22 | uint32_t binding, |
| 23 | uint32_t set) : INHERITED(visibility, config), fBinding(binding) { |
egdaniel | 990dbc8 | 2016-07-13 14:09:30 -0700 | [diff] [blame^] | 24 | SkASSERT(GrSLTypeIsCombinedSamplerType(type)); |
egdaniel | 09aa1fc | 2016-04-20 07:09:46 -0700 | [diff] [blame] | 25 | fShaderVar.setType(type); |
| 26 | fShaderVar.setTypeModifier(GrGLSLShaderVar::kUniform_TypeModifier); |
| 27 | fShaderVar.setPrecision(precision); |
| 28 | fShaderVar.accessName()->set(name); |
| 29 | SkString layoutQualifier; |
| 30 | layoutQualifier.appendf("set=%d, binding=%d", set, binding); |
| 31 | fShaderVar.setLayoutQualifier(layoutQualifier.c_str()); |
| 32 | } |
| 33 | |
| 34 | GrSLType type() const override { return fShaderVar.getType(); } |
| 35 | uint32_t binding() const { return fBinding; } |
| 36 | |
| 37 | const char* onGetSamplerNameForTexture2D() const override { return fShaderVar.c_str(); } |
| 38 | const char* getSamplerNameForTexelFetch() const override { return fShaderVar.c_str(); } |
| 39 | |
| 40 | private: |
| 41 | GrGLSLShaderVar fShaderVar; |
| 42 | uint32_t fBinding; |
| 43 | |
| 44 | friend class GrVkUniformHandler; |
| 45 | |
| 46 | typedef GrGLSLSampler INHERITED; |
| 47 | }; |
| 48 | |
| 49 | #endif |