Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Unified Diff: src/gpu/vk/GrVkUniformHandler.h

Issue 1718693002: Add vulkan files into skia repo. (Closed) Base URL: https://skia.googlesource.com/skia.git@merge
Patch Set: fix path Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/vk/GrVkUniformBuffer.cpp ('k') | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/gpu/vk/GrVkUniformBuffer.cpp ('k') | src/gpu/vk/GrVkUniformHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698