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 GrVkPipelineStateDataManager_DEFINED 9#define GrVkPipelineStateDataManager_DEFINED 10 11#include "src/gpu/GrUniformDataManager.h" 12 13#include "include/gpu/vk/GrVkTypes.h" 14#include "src/gpu/vk/GrVkUniformHandler.h" 15 16class GrGpuBuffer; 17class GrVkCommandBuffer; 18class GrVkGpu; 19 20class GrVkPipelineStateDataManager : public GrUniformDataManager { 21public: 22 typedef GrVkUniformHandler::UniformInfoArray UniformInfoArray; 23 24 GrVkPipelineStateDataManager(const UniformInfoArray&, uint32_t uniformSize, 25 bool usePushConstants); 26 27 // Returns the uniform buffer that holds all the uniform data. If there are no uniforms it 28 // returns nullptr. If there was an error in creating or uploading the uniforms the value of the 29 // returned bool will be false and the buffer will be nullptr. Otherwise the bool will be true. 30 std::pair<sk_sp<GrGpuBuffer>, bool> uploadUniforms(GrVkGpu* gpu, VkPipelineLayout, 31 GrVkCommandBuffer* commandBuffer); 32 33 void releaseData(); 34 35 // TODO: we might need more of these once std430 size/alignment issues are worked out 36 void set1iv(UniformHandle, int arrayCount, const int32_t v[]) const override; 37 void set1fv(UniformHandle, int arrayCount, const float v[]) const override; 38 void set2iv(UniformHandle, int arrayCount, const int32_t v[]) const override; 39 void set2fv(UniformHandle, int arrayCount, const float v[]) const override; 40 void setMatrix2fv(UniformHandle, int arrayCount, const float matrices[]) const override; 41 42private: 43 sk_sp<GrGpuBuffer> fUniformBuffer; 44 bool fUsePushConstants; 45 46 using INHERITED = GrUniformDataManager; 47}; 48 49#endif 50