Talvos  0.1
SPIR-V interpreter and dynamic analysis framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PipelineContext.h
Go to the documentation of this file.
1 // Copyright (c) 2018 the Talvos developers. All rights reserved.
2 //
3 // This file is distributed under a three-clause BSD license. For full license
4 // terms please see the LICENSE file distributed with this source code.
5 
8 
9 #ifndef TALVOS_PIPELINECONTEXT_H
10 #define TALVOS_PIPELINECONTEXT_H
11 
12 #include <map>
13 #include <vector>
14 
15 #include "vulkan/vulkan_core.h"
16 
17 namespace talvos
18 {
19 
20 class ComputePipeline;
22 
24 typedef std::map<uint32_t, uint64_t> VertexBindingMap;
25 
28 {
29  uint64_t Address;
30  uint64_t NumBytes;
31 };
32 
34 typedef std::map<std::pair<uint32_t, uint32_t>, BindingInfo> DescriptorSet;
35 
37 typedef std::map<uint32_t, talvos::DescriptorSet> DescriptorSetMap;
38 
43 {
44 public:
46  static const uint32_t PUSH_CONSTANT_MEM_SIZE = 128;
47 
50 
52  void bindComputePipeline(const ComputePipeline *PL);
53 
56 
58  void bindGraphicsPipeline(const GraphicsPipeline *PL);
59 
61  void bindVertexBuffer(uint32_t Binding, uint64_t Address);
62 
64  void clear();
65 
68 
70  const ComputePipeline *getComputePipeline() const { return ComputePL; }
71 
74 
76  const GraphicsPipeline *getGraphicsPipeline() const { return GraphicsPL; }
77 
79  const uint8_t *getPushConstantData() const { return PushConstantData; }
80 
82  const std::vector<VkRect2D> &getScissors() const { return Scissors; }
83 
86 
88  const std::vector<VkViewport> &getViewports() const { return Viewports; }
89 
91  void setPushConstantData(uint32_t Offset, uint32_t NumBytes,
92  const uint8_t *Data);
93 
94 private:
95  const ComputePipeline *ComputePL = nullptr;
96  const GraphicsPipeline *GraphicsPL = nullptr;
97 
100 
102 
103  std::vector<VkViewport> Viewports;
104 
105  std::vector<VkRect2D> Scissors;
106 
108 };
109 
110 }; // namespace talvos
111 
112 #endif
const GraphicsPipeline * getGraphicsPipeline() const
Returns the graphics pipeline.
Structure holding information about a descriptor binding.
VertexBindingMap VertexBindings
The vertex bindings.
const DescriptorSetMap & getGraphicsDescriptors() const
Returns the descriptor bindings for draw commands.
std::map< uint32_t, uint64_t > VertexBindingMap
Mapping from binding indexes to device memory addresses for vertex buffers.
DescriptorSetMap GraphicsDSM
The descriptors for draw commands.
void bindComputeDescriptors(const DescriptorSetMap &DSM)
Bind descriptor sets used for compute commands.
This class encapsulates pipeline state and bound resources.
const ComputePipeline * getComputePipeline() const
Returns the compute pipeline.
std::vector< VkRect2D > Scissors
The scissor rectangles.
uint8_t PushConstantData[PUSH_CONSTANT_MEM_SIZE]
Push constant data.
std::vector< VkViewport > Viewports
The viewports.
std::map< uint32_t, talvos::DescriptorSet > DescriptorSetMap
Mapping from set numbers to descriptor sets.
const std::vector< VkRect2D > & getScissors() const
Returns the scissor rectangles.
const GraphicsPipeline * GraphicsPL
The graphics pipeline.
void clear()
Clear the pipeline context.
This class encapsulates a graphics pipeline.
uint64_t Address
The memory address of the descriptor resource.
void bindVertexBuffer(uint32_t Binding, uint64_t Address)
Bind a vertex buffer.
const DescriptorSetMap & getComputeDescriptors() const
Returns the descriptor bindings for compute commands.
void bindComputePipeline(const ComputePipeline *PL)
Bind a compute pipeline.
void bindGraphicsPipeline(const GraphicsPipeline *PL)
Bind a graphics pipeline.
uint64_t NumBytes
The number of bytes that have been bound.
void bindGraphicsDescriptors(const DescriptorSetMap &DSM)
Bind descriptor sets used for draw commands.
const std::vector< VkViewport > & getViewports() const
Returns the viewports.
static const uint32_t PUSH_CONSTANT_MEM_SIZE
The number of bytes used for push constant data.
const uint8_t * getPushConstantData() const
Returns a pointer to the push constant data.
DescriptorSetMap ComputeDSM
The descriptors for compute commands.
std::map< std::pair< uint32_t, uint32_t >, BindingInfo > DescriptorSet
Mapping from a binding and array element index to an address in memory.
void setPushConstantData(uint32_t Offset, uint32_t NumBytes, const uint8_t *Data)
Set push constant data.
This class encapsulates a compute pipeline.
const ComputePipeline * ComputePL
The compute pipeline.
const VertexBindingMap & getVertexBindings() const
Returns the vertex bindings.