blob: 889f529d12af64a6af953ad5310fb036899df424 [file] [log] [blame]
Stephen White4da34bf2019-07-30 10:37:47 -04001/*
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
14class GrDawnGpu;
15
16class GrDawnUniformHandler : public GrGLSLUniformHandler {
17public:
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 White4da34bf2019-07-30 10:37:47 -040023 struct UniformInfo {
24 GrShaderVar fVar;
25 int fUBOOffset;
26 int fVisibility;
27 };
28 typedef GrTAllocator<UniformInfo> UniformInfoArray;
29 enum {
Stephen Whitedd78efd2019-10-23 15:00:20 -040030 kUniformBinding = 0,
31 kSamplerBindingBase = 1,
Stephen White4da34bf2019-07-30 10:37:47 -040032 };
Stephen White40c47e12019-11-01 13:13:03 -040033 uint32_t getRTHeightOffset() const;
Stephen White4da34bf2019-07-30 10:37:47 -040034
35private:
36 explicit GrDawnUniformHandler(GrGLSLProgramBuilder* program);
37
Robert Phillips66ae3042019-10-10 12:57:58 -040038 SamplerHandle addSampler(const GrTextureProxy*, const GrSamplerState&, const GrSwizzle&,
Stephen White4da34bf2019-07-30 10:37:47 -040039 const char* name, const GrShaderCaps*) override;
40 const char* samplerVariable(SamplerHandle handle) const override;
41 GrSwizzle samplerSwizzle(SamplerHandle handle) const override;
42 void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
43 UniformHandle internalAddUniformArray(uint32_t visibility,
44 GrSLType type,
45 const char* name,
46 bool mangleName,
47 int arrayCount,
48 const char** outName) override;
49
Stephen White2adbf9c2019-09-10 12:35:02 -040050 void updateUniformVisibility(UniformHandle u, uint32_t visibility) override;
51
Stephen White170d9902019-08-15 16:48:24 -040052 UniformInfoArray fUniforms;
53 UniformInfoArray fSamplers;
54 UniformInfoArray fTextures;
55 SkTArray<GrSwizzle> fSamplerSwizzles;
56 SkTArray<SkString> fSamplerReferences;
57
Stephen Whitedd78efd2019-10-23 15:00:20 -040058 uint32_t fCurrentUBOOffset = 0;
Stephen White40c47e12019-11-01 13:13:03 -040059 uint32_t fRTHeightOffset = 0;
Stephen White4da34bf2019-07-30 10:37:47 -040060
61 friend class GrDawnProgramBuilder;
62 typedef GrGLSLUniformHandler INHERITED;
63};
64
65#endif