Welcome to mirror list, hosted at ThFree Co, Russian Federation.

vulkan_pipeline.hpp « vulkan « drape - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 635a2109ddd34dcd91c8baa5747cf9f39d2fd1f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once

#include "drape/binding_info.hpp"
#include "drape/graphics_context.hpp"
#include "drape/pointers.hpp"
#include "drape/texture_types.hpp"
#include "drape/vulkan/vulkan_gpu_program.hpp"

#include <vulkan_wrapper.h>
#include <vulkan/vulkan.h>

#include <cstdint>
#include <map>

namespace dp
{
namespace vulkan
{
class VulkanPipeline
{
public:
  struct DepthStencilKey
  {
    void SetDepthTestEnabled(bool enabled);
    void SetDepthTestFunction(TestFunction depthFunction);
    void SetStencilTestEnabled(bool enabled);
    void SetStencilFunction(StencilFace face, TestFunction stencilFunction);
    void SetStencilActions(StencilFace face, StencilAction stencilFailAction,
                           StencilAction depthFailAction, StencilAction passAction);
    bool operator<(DepthStencilKey const & rhs) const;
    bool operator!=(DepthStencilKey const & rhs) const;
    
    bool m_depthEnabled = false;
    bool m_stencilEnabled = false;
    TestFunction m_depthFunction = TestFunction::Always;
    uint64_t m_stencil = 0;
  };

  struct PipelineKey
  {
    PipelineKey() = default;
    PipelineKey(VkRenderPass renderPass, ref_ptr<VulkanGpuProgram> program,
                DepthStencilKey const & depthStencil, std::vector<BindingInfo> && bindingInfo,
                VkPrimitiveTopology primitiveTopology, bool blendingEnabled);
    bool operator<(PipelineKey const & rhs) const;

    VkRenderPass m_renderPass = {};
    ref_ptr<VulkanGpuProgram> m_program;
    DepthStencilKey m_depthStencil;
    std::vector<BindingInfo> m_bindingInfo;
    VkPrimitiveTopology m_primitiveTopology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
    bool m_blendingEnabled = false;
  };

  VulkanPipeline(VkDevice device, int appVersionCode);
  void Dump(VkDevice device);
  void Destroy(VkDevice device);

  VkPipeline GetPipeline(VkDevice device, PipelineKey const & key);

private:
  int const m_appVersionCode;
  VkPipelineCache m_vulkanPipelineCache;

  using PipelineCache = std::map<PipelineKey, VkPipeline>;
  PipelineCache m_pipelineCache;
  bool m_isChanged = false;
};
}  // namespace vulkan
}  // namespace dp