1 //
2 // Copyright 2017 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // ProgramPipelineVk.h:
7 //    Defines the class interface for ProgramPipelineVk, implementing ProgramPipelineImpl.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_VULKAN_PROGRAMPIPELINEVK_H_
11 #define LIBANGLE_RENDERER_VULKAN_PROGRAMPIPELINEVK_H_
12 
13 #include "libANGLE/renderer/ProgramPipelineImpl.h"
14 
15 #include "libANGLE/renderer/vulkan/ContextVk.h"
16 #include "libANGLE/renderer/vulkan/ProgramExecutableVk.h"
17 #include "libANGLE/renderer/vulkan/ProgramVk.h"
18 
19 namespace rx
20 {
21 
22 class ProgramPipelineVk : public ProgramPipelineImpl
23 {
24   public:
25     ProgramPipelineVk(const gl::ProgramPipelineState &state);
26     ~ProgramPipelineVk() override;
27 
28     void destroy(const gl::Context *context) override;
29     void reset(ContextVk *contextVk);
30 
getExecutable()31     const ProgramExecutableVk &getExecutable() const { return mExecutable; }
getExecutable()32     ProgramExecutableVk &getExecutable() { return mExecutable; }
33 
getShaderProgram(const gl::State & glState,gl::ShaderType shaderType)34     ProgramVk *getShaderProgram(const gl::State &glState, gl::ShaderType shaderType) const
35     {
36         gl::ProgramPipeline *pipeline = glState.getProgramPipeline();
37         const gl::Program *program    = pipeline->getShaderProgram(shaderType);
38         if (program)
39         {
40             return vk::GetImpl(program);
41         }
42         return nullptr;
43     }
44 
45     void fillProgramStateMap(const ContextVk *contextVk,
46                              gl::ShaderMap<const gl::ProgramState *> *programStatesOut);
47 
48     angle::Result link(const gl::Context *glContext,
49                        const gl::ProgramMergedVaryings &mergedVaryings,
50                        const gl::ProgramVaryingPacking &varyingPacking) override;
51 
52     angle::Result updateUniforms(ContextVk *contextVk);
53 
54     void setAllDefaultUniformsDirty(const gl::State &glState);
55     bool dirtyUniforms(const gl::State &glState);
56     void onProgramBind(ContextVk *contextVk);
57 
58   private:
59     size_t calcUniformUpdateRequiredSpace(ContextVk *contextVk,
60                                           const gl::ProgramExecutable &glExecutable,
61                                           const gl::State &glState,
62                                           gl::ShaderMap<VkDeviceSize> *uniformOffsets) const;
63 
64     ProgramExecutableVk mExecutable;
65 };
66 
67 }  // namespace rx
68 
69 #endif  // LIBANGLE_RENDERER_VULKAN_PROGRAMPIPELINEVK_H_
70