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