Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 GrDawnUniformHandler_DEFINED |
| 9 | #define GrDawnUniformHandler_DEFINED |
| 10 | |
| 11 | #include "src/gpu/GrAllocator.h" |
| 12 | #include "src/gpu/glsl/GrGLSLUniformHandler.h" |
| 13 | |
| 14 | class GrDawnGpu; |
| 15 | |
| 16 | class GrDawnUniformHandler : public GrGLSLUniformHandler { |
| 17 | public: |
| 18 | static const int kUniformsPerBlock = 8; |
| 19 | |
| 20 | const GrShaderVar& getUniformVariable(UniformHandle u) const override; |
| 21 | const char* getUniformCStr(UniformHandle u) const override; |
| 22 | |
Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 23 | struct UniformInfo { |
| 24 | GrShaderVar fVar; |
| 25 | int fUBOOffset; |
| 26 | int fVisibility; |
| 27 | }; |
| 28 | typedef GrTAllocator<UniformInfo> UniformInfoArray; |
| 29 | enum { |
Stephen White | dd78efd | 2019-10-23 15:00:20 -0400 | [diff] [blame] | 30 | kUniformBinding = 0, |
Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 31 | }; |
Stephen White | 40c47e1 | 2019-11-01 13:13:03 -0400 | [diff] [blame] | 32 | uint32_t getRTHeightOffset() const; |
Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 33 | |
| 34 | private: |
| 35 | explicit GrDawnUniformHandler(GrGLSLProgramBuilder* program); |
| 36 | |
Brian Salomon | ccb6142 | 2020-01-09 10:46:36 -0500 | [diff] [blame] | 37 | SamplerHandle addSampler(const GrSurfaceProxy*, GrSamplerState, const GrSwizzle&, |
Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 38 | const char* name, const GrShaderCaps*) override; |
| 39 | const char* samplerVariable(SamplerHandle handle) const override; |
| 40 | GrSwizzle samplerSwizzle(SamplerHandle handle) const override; |
| 41 | void appendUniformDecls(GrShaderFlags visibility, SkString*) const override; |
| 42 | UniformHandle internalAddUniformArray(uint32_t visibility, |
| 43 | GrSLType type, |
| 44 | const char* name, |
| 45 | bool mangleName, |
| 46 | int arrayCount, |
| 47 | const char** outName) override; |
| 48 | |
Stephen White | 2adbf9c | 2019-09-10 12:35:02 -0400 | [diff] [blame] | 49 | void updateUniformVisibility(UniformHandle u, uint32_t visibility) override; |
| 50 | |
Stephen White | 170d990 | 2019-08-15 16:48:24 -0400 | [diff] [blame] | 51 | UniformInfoArray fUniforms; |
| 52 | UniformInfoArray fSamplers; |
| 53 | UniformInfoArray fTextures; |
| 54 | SkTArray<GrSwizzle> fSamplerSwizzles; |
| 55 | SkTArray<SkString> fSamplerReferences; |
| 56 | |
Stephen White | dd78efd | 2019-10-23 15:00:20 -0400 | [diff] [blame] | 57 | uint32_t fCurrentUBOOffset = 0; |
Stephen White | 40c47e1 | 2019-11-01 13:13:03 -0400 | [diff] [blame] | 58 | uint32_t fRTHeightOffset = 0; |
Stephen White | 4da34bf | 2019-07-30 10:37:47 -0400 | [diff] [blame] | 59 | |
| 60 | friend class GrDawnProgramBuilder; |
| 61 | typedef GrGLSLUniformHandler INHERITED; |
| 62 | }; |
| 63 | |
| 64 | #endif |