Talvos  0.1
SPIR-V interpreter and dynamic analysis framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PipelineContext.cpp
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 #include <cassert>
10 #include <cstring>
11 
12 #include "talvos/PipelineContext.h"
14 
15 namespace talvos
16 {
17 
19 {
20  for (auto &DS : DSM)
21  ComputeDSM[DS.first] = DS.second;
22 }
23 
25 {
26  ComputePL = PL;
27 }
28 
30 {
31  for (auto &DS : DSM)
32  GraphicsDSM[DS.first] = DS.second;
33 }
34 
36 {
37  GraphicsPL = PL;
38  Viewports = PL->getViewports();
39  Scissors = PL->getScissors();
40 }
41 
42 void PipelineContext::bindVertexBuffer(uint32_t Binding, uint64_t Address)
43 {
44  VertexBindings[Binding] = Address;
45 }
46 
48 {
49  ComputePL = nullptr;
50  GraphicsPL = nullptr;
51  ComputeDSM.clear();
52  GraphicsDSM.clear();
53  Scissors.clear();
54  VertexBindings.clear();
55 }
56 
57 void PipelineContext::setPushConstantData(uint32_t Offset, uint32_t NumBytes,
58  const uint8_t *Data)
59 {
60  assert(Offset + NumBytes <= PUSH_CONSTANT_MEM_SIZE);
61  memcpy(PushConstantData + Offset, Data, NumBytes);
62 }
63 
64 } // namespace talvos
VertexBindingMap VertexBindings
The vertex bindings.
DescriptorSetMap GraphicsDSM
The descriptors for draw commands.
void bindComputeDescriptors(const DescriptorSetMap &DSM)
Bind descriptor sets used for compute commands.
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 GraphicsPipeline * GraphicsPL
The graphics pipeline.
void clear()
Clear the pipeline context.
This class encapsulates a graphics pipeline.
This file declares the GraphicsPipeline class.
const std::vector< VkViewport > & getViewports() const
Returns the static viewports used by this pipeline.
This file declares the PipelineContext class and related typedefs.
void bindVertexBuffer(uint32_t Binding, uint64_t Address)
Bind a vertex buffer.
void bindComputePipeline(const ComputePipeline *PL)
Bind a compute pipeline.
void bindGraphicsPipeline(const GraphicsPipeline *PL)
Bind a graphics pipeline.
void bindGraphicsDescriptors(const DescriptorSetMap &DSM)
Bind descriptor sets used for draw commands.
static const uint32_t PUSH_CONSTANT_MEM_SIZE
The number of bytes used for push constant data.
const std::vector< VkRect2D > & getScissors() const
Returns the static scissor rectangles used by this pipeline.
DescriptorSetMap ComputeDSM
The descriptors for compute commands.
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.