Index: src/gpu/vk/GrVkUniformHandler.h |
diff --git a/src/gpu/vk/GrVkUniformHandler.h b/src/gpu/vk/GrVkUniformHandler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f84bcff0a250ec6e88885f6a8d9927c4287509de |
--- /dev/null |
+++ b/src/gpu/vk/GrVkUniformHandler.h |
@@ -0,0 +1,85 @@ |
+/* |
+* Copyright 2016 Google Inc. |
+* |
+* Use of this source code is governed by a BSD-style license that can be |
+* found in the LICENSE file. |
+*/ |
+ |
+#ifndef GrVkUniformHandler_DEFINED |
+#define GrVkUniformHandler_DEFINED |
+ |
+#include "glsl/GrGLSLUniformHandler.h" |
+ |
+#include "GrAllocator.h" |
+#include "glsl/GrGLSLShaderVar.h" |
+ |
+static const int kUniformsPerBlock = 8; |
+ |
+class GrVkUniformHandler : public GrGLSLUniformHandler { |
+public: |
+ enum { |
+ kSamplerDescSet = 0, |
+ kUniformBufferDescSet = 1, |
+ }; |
+ enum { |
+ kVertexBinding = 0, |
+ kFragBinding = 1, |
+ }; |
+ |
+ // fUBOffset is only valid if the GrSLType of the fVariable is not a sampler |
+ struct UniformInfo { |
+ GrGLSLShaderVar fVariable; |
+ uint32_t fVisibility; |
+ uint32_t fSetNumber; |
+ uint32_t fBinding; |
+ uint32_t fUBOffset; |
+ }; |
+ typedef GrTAllocator<UniformInfo> UniformInfoArray; |
+ |
+ const GrGLSLShaderVar& getUniformVariable(UniformHandle u) const override { |
+ return fUniforms[u.toIndex()].fVariable; |
+ } |
+ |
+ const char* getUniformCStr(UniformHandle u) const override { |
+ return this->getUniformVariable(u).c_str(); |
+ } |
+ |
+private: |
+ explicit GrVkUniformHandler(GrGLSLProgramBuilder* program) |
+ : INHERITED(program) |
+ , fUniforms(kUniformsPerBlock) |
+ , fCurrentVertexUBOOffset(0) |
+ , fCurrentFragmentUBOOffset(0) |
+ , fCurrentSamplerBinding(0) { |
+ } |
+ |
+ UniformHandle internalAddUniformArray(uint32_t visibility, |
+ GrSLType type, |
+ GrSLPrecision precision, |
+ const char* name, |
+ bool mangleName, |
+ int arrayCount, |
+ const char** outName) override; |
+ |
+ void appendUniformDecls(GrShaderFlags, SkString*) const override; |
+ |
+ bool hasVertexUniforms() const { return fCurrentVertexUBOOffset > 0; } |
+ bool hasFragmentUniforms() const { return fCurrentFragmentUBOOffset > 0; } |
+ |
+ |
+ const UniformInfo& getUniformInfo(UniformHandle u) const { |
+ return fUniforms[u.toIndex()]; |
+ } |
+ |
+ |
+ UniformInfoArray fUniforms; |
+ uint32_t fCurrentVertexUBOOffset; |
+ uint32_t fCurrentFragmentUBOOffset; |
+ uint32_t fCurrentSamplerBinding; |
+ |
+ friend class GrVkProgramBuilder; |
+ |
+ typedef GrGLSLUniformHandler INHERITED; |
+}; |
+ |
+#endif |