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 GrVkProgramDataManager_DEFINED 9#define GrVkProgramDataManager_DEFINED 10 11#include "glsl/GrGLSLProgramDataManager.h" 12 13#include "vk/GrVkUniformHandler.h" 14 15class GrVkGpu; 16class GrVkUniformBuffer; 17 18class GrVkProgramDataManager : public GrGLSLProgramDataManager { 19public: 20 typedef GrVkUniformHandler::UniformInfoArray UniformInfoArray; 21 22 GrVkProgramDataManager(const UniformInfoArray&, 23 uint32_t vertexUniformSize, 24 uint32_t fragmentUniformSize); 25 26 void set1f(UniformHandle, float v0) const override; 27 void set1fv(UniformHandle, int arrayCount, const float v[]) const override; 28 void set2f(UniformHandle, float, float) const override; 29 void set2fv(UniformHandle, int arrayCount, const float v[]) const override; 30 void set3f(UniformHandle, float, float, float) const override; 31 void set3fv(UniformHandle, int arrayCount, const float v[]) const override; 32 void set4f(UniformHandle, float, float, float, float) const override; 33 void set4fv(UniformHandle, int arrayCount, const float v[]) const override; 34 // matrices are column-major, the first two upload a single matrix, the latter two upload 35 // arrayCount matrices into a uniform array. 36 void setMatrix3f(UniformHandle, const float matrix[]) const override; 37 void setMatrix4f(UniformHandle, const float matrix[]) const override; 38 void setMatrix3fv(UniformHandle, int arrayCount, const float matrices[]) const override; 39 void setMatrix4fv(UniformHandle, int arrayCount, const float matrices[]) const override; 40 41 // for nvpr only 42 void setPathFragmentInputTransform(VaryingHandle u, int components, 43 const SkMatrix& matrix) const override { 44 SkFAIL("Only supported in NVPR, which is not in vulkan"); 45 } 46 47 void uploadUniformBuffers(const GrVkGpu* gpu, 48 GrVkUniformBuffer* vertexBuffer, 49 GrVkUniformBuffer* fragmentBuffer) const; 50private: 51 struct Uniform { 52 uint32_t fBinding; 53 uint32_t fOffset; 54 SkDEBUGCODE( 55 GrSLType fType; 56 int fArrayCount; 57 uint32_t fSetNumber; 58 ); 59 }; 60 61 uint32_t fVertexUniformSize; 62 uint32_t fFragmentUniformSize; 63 64 SkTArray<Uniform, true> fUniforms; 65 66 mutable SkAutoMalloc fVertexUniformData; 67 mutable SkAutoMalloc fFragmentUniformData; 68}; 69 70#endif