18#ifndef INCLUDED_RENDERER_VULKAN_DEVICECOMMANDCONTEXT
19#define INCLUDED_RENDERER_VULKAN_DEVICECOMMANDCONTEXT
25#include <glad/vulkan.h>
39class CComputePipelineState;
42class CGraphicsPipelineState;
43class CRingCommandContext;
45class CVertexInputLayout;
59 const Rect& destinationRegion,
const Rect& sourceRegion,
64 void ClearFramebuffer(
const bool color,
const bool depth,
const bool stencil)
override;
72 const void* data,
const size_t dataSize,
75 const void* data,
const size_t dataSize,
97 const uint32_t bindingSlot,
const void* data,
const uint32_t dataSize)
override;
107 const uint32_t firstIndex,
const uint32_t indexCount,
const int32_t vertexOffset)
override;
114 const int32_t vertexOffset)
override;
125 const uint32_t groupCountZ)
override;
132 const int32_t bindingSlot,
133 const float value)
override;
135 const int32_t bindingSlot,
136 const float valueX,
const float valueY)
override;
138 const int32_t bindingSlot,
139 const float valueX,
const float valueY,
140 const float valueZ)
override;
142 const int32_t bindingSlot,
143 const float valueX,
const float valueY,
144 const float valueZ,
const float valueW)
override;
151 void Flush()
override;
156 static std::unique_ptr<IDeviceCommandContext>
Create(
CDevice* device);
A wrapper for backend shader program to handle high-level operations like file reloading and handling...
Definition: ShaderProgram.h:34
A conntainer close to std::vector but the elements are stored in place: There is a fixed capacity and...
Definition: StaticVector.h:89
Simplifed version of std::span (C++20) as we don't support the original one yet.
Definition: Span.h:37
A holder for precompiled compute pipeline description.
Definition: PipelineState.h:207
Definition: IDeviceCommandContext.h:42
std::function< void(u8 *)> UploadBufferFunction
Definition: IDeviceCommandContext.h:122
IFramebuffer stores attachments which should be used by backend as rendering destinations.
Definition: IFramebuffer.h:85
A holder for precompiled graphics pipeline description.
Definition: PipelineState.h:198
Definition: ITexture.h:34
Definition: PipelineState.h:91
Definition: DeviceCommandContext.cpp:197
Definition: DeviceCommandContext.h:48
void BeginFramebufferPass(IFramebuffer *framebuffer) override
Starts a framebuffer pass, performs attachment load operations.
Definition: DeviceCommandContext.cpp:571
CFramebuffer * m_Framebuffer
Definition: DeviceCommandContext.h:175
IDevice * GetDevice() override
Definition: DeviceCommandContext.cpp:389
CBuffer * m_BoundIndexBuffer
Definition: DeviceCommandContext.h:186
std::unique_ptr< CUploadRing > m_UniformUploadRing
Definition: DeviceCommandContext.h:190
std::unique_ptr< CRingCommandContext > m_CommandContext
Definition: DeviceCommandContext.h:171
void DrawInstanced(const uint32_t firstVertex, const uint32_t vertexCount, const uint32_t firstInstance, const uint32_t instanceCount) override
Definition: DeviceCommandContext.cpp:890
void EndComputePass() override
Finishes a compute pass.
Definition: DeviceCommandContext.cpp:923
std::unique_ptr< CUploadRing > m_IndexUploadRing
Definition: DeviceCommandContext.h:190
void DrawIndexedInRange(const uint32_t firstIndex, const uint32_t indexCount, const uint32_t start, const uint32_t end) override
Definition: DeviceCommandContext.cpp:909
void DrawIndexed(const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset) override
Definition: DeviceCommandContext.cpp:882
bool m_InsidePass
Definition: DeviceCommandContext.h:182
void SetScissors(const uint32_t scissorCount, const Rect *scissors) override
Definition: DeviceCommandContext.cpp:766
void SetUniform(const int32_t bindingSlot, const float value) override
Definition: DeviceCommandContext.cpp:984
void UploadTextureRegion(ITexture *texture, const Format dataFormat, const void *data, const size_t dataSize, const uint32_t xOffset, const uint32_t yOffset, const uint32_t width, const uint32_t height, const uint32_t level=0, const uint32_t layer=0) override
Definition: DeviceCommandContext.cpp:726
void SetVertexBufferData(const uint32_t bindingSlot, const void *data, const uint32_t dataSize) override
Definition: DeviceCommandContext.cpp:835
void ApplyPipelineStateIfDirty()
Definition: DeviceCommandContext.cpp:1167
void UploadBuffer(IBuffer *buffer, const void *data, const uint32_t dataSize) override
Definition: DeviceCommandContext.cpp:736
void SetVertexInputLayout(IVertexInputLayout *vertexInputLayout) override
Binds the vertex input layout.
Definition: DeviceCommandContext.cpp:818
void UpdateOutdatedConstants()
Definition: DeviceCommandContext.cpp:1146
void BindVertexBuffer(const uint32_t bindingSlot, CBuffer *buffer, uint32_t offset)
Definition: DeviceCommandContext.cpp:1202
void SetStorageTexture(const int32_t bindingSlot, ITexture *texture) override
Sets a read & write resource to the binding slot.
Definition: DeviceCommandContext.cpp:975
void EndPass() override
Definition: DeviceCommandContext.cpp:870
std::unique_ptr< CUploadRing > m_VertexUploadRing
Definition: DeviceCommandContext.h:190
std::unique_ptr< CRingCommandContext > m_PrependCommandContext
Definition: DeviceCommandContext.h:170
void BeginPass() override
Definition: DeviceCommandContext.cpp:864
VkPipeline m_LastBoundPipeline
Definition: DeviceCommandContext.h:179
void ClearFramebuffer(const bool color, const bool depth, const bool stencil) override
Clears all mentioned attachments.
Definition: DeviceCommandContext.cpp:519
void ResolveFramebuffer(IFramebuffer *destinationFramebuffer, IFramebuffer *sourceFramebuffer) override
Resolves multisample source framebuffer attachments to destination attachments.
Definition: DeviceCommandContext.cpp:480
void SetVertexBuffer(const uint32_t bindingSlot, IBuffer *buffer, const uint32_t offset) override
Definition: DeviceCommandContext.cpp:829
void SetGraphicsPipelineState(IGraphicsPipelineState *pipelineState) override
Binds the graphics pipeline state.
Definition: DeviceCommandContext.cpp:394
void Draw(const uint32_t firstVertex, const uint32_t vertexCount) override
Definition: DeviceCommandContext.cpp:876
void EndFramebufferPass() override
Finishes a framebuffer pass, performs attachment store operations.
Definition: DeviceCommandContext.cpp:655
~CDeviceCommandContext() override
Definition: DeviceCommandContext.cpp:379
void BlitFramebuffer(IFramebuffer *destinationFramebuffer, IFramebuffer *sourceFramebuffer, const Rect &destinationRegion, const Rect &sourceRegion, const Sampler::Filter filter) override
Copies source region into destination region automatically applying compatible format conversion and ...
Definition: DeviceCommandContext.cpp:426
void BeginScopedLabel(const char *name) override
Definition: DeviceCommandContext.cpp:1025
void PreDraw()
Definition: DeviceCommandContext.cpp:1138
CGraphicsPipelineState * m_GraphicsPipelineState
Definition: DeviceCommandContext.h:173
void Flush() override
Definition: DeviceCommandContext.cpp:1042
void SetIndexBuffer(IBuffer *buffer) override
Definition: DeviceCommandContext.cpp:847
bool m_InsideFramebufferPass
Definition: DeviceCommandContext.h:181
void ReadbackFramebufferSync(const uint32_t x, const uint32_t y, const uint32_t width, const uint32_t height, void *data) override
Readbacks the current backbuffer to data in R8G8B8_UNORM format somewhen between the function call an...
Definition: DeviceCommandContext.cpp:700
bool m_DebugBarrierAfterFramebufferPass
Definition: DeviceCommandContext.h:205
void SetViewports(const uint32_t viewportCount, const Rect *viewports) override
Definition: DeviceCommandContext.cpp:802
void BeginComputePass() override
Starts a compute pass, can't be called inside a framebuffer pass.
Definition: DeviceCommandContext.cpp:916
bool m_DebugScopedLabels
Definition: DeviceCommandContext.h:168
bool m_InsideComputePass
Definition: DeviceCommandContext.h:183
void SetIndexBufferData(const void *data, const uint32_t dataSize) override
Definition: DeviceCommandContext.cpp:852
CDevice * m_Device
Definition: DeviceCommandContext.h:166
CVertexInputLayout * m_VertexInputLayout
Definition: DeviceCommandContext.h:174
static std::unique_ptr< IDeviceCommandContext > Create(CDevice *device)
Definition: DeviceCommandContext.cpp:310
CComputePipelineState * m_ComputePipelineState
Definition: DeviceCommandContext.h:176
void Dispatch(const uint32_t groupCountX, const uint32_t groupCountY, const uint32_t groupCountZ) override
Dispatches groupCountX * groupCountY * groupCountZ compute groups.
Definition: DeviceCommandContext.cpp:937
void SetTexture(const int32_t bindingSlot, ITexture *texture) override
Sets a read-only texture to the binding slot.
Definition: DeviceCommandContext.cpp:951
uint32_t m_BoundIndexBufferOffset
Definition: DeviceCommandContext.h:187
VkDescriptorSet m_UniformDescriptorSet
Definition: DeviceCommandContext.h:193
PS::StaticVector< QueuedReadback, 2 > m_QueuedReadbacks
Definition: DeviceCommandContext.h:203
void SetComputePipelineState(IComputePipelineState *pipelineState) override
Binds the graphics pipeline state.
Definition: DeviceCommandContext.cpp:410
void EndScopedLabel() override
Definition: DeviceCommandContext.cpp:1035
bool m_IsPipelineStateDirty
Definition: DeviceCommandContext.h:178
void BindIndexBuffer(CBuffer *buffer, uint32_t offset)
Definition: DeviceCommandContext.cpp:1211
VkDescriptorPool m_UniformDescriptorPool
Definition: DeviceCommandContext.h:192
CShaderProgram * m_ShaderProgram
Definition: DeviceCommandContext.h:177
void UploadBufferRegion(IBuffer *buffer, const void *data, const uint32_t dataOffset, const uint32_t dataSize) override
Definition: DeviceCommandContext.cpp:750
void UploadTexture(ITexture *texture, const Format dataFormat, const void *data, const size_t dataSize, const uint32_t level=0, const uint32_t layer=0) override
Definition: DeviceCommandContext.cpp:718
void DrawIndexedInstanced(const uint32_t firstIndex, const uint32_t indexCount, const uint32_t firstInstance, const uint32_t instanceCount, const int32_t vertexOffset) override
Definition: DeviceCommandContext.cpp:899
Definition: Framebuffer.h:41
Definition: PipelineState.h:44
Definition: ShaderProgram.h:82
Filter
Definition: Sampler.h:36
Format
Definition: Format.h:28
Backend
Definition: Backend.h:28
Definition: VideoMode.h:29
Definition: IDeviceCommandContext.h:58
Definition: DeviceCommandContext.h:197
uint32_t height
Definition: DeviceCommandContext.h:199
uint32_t x
Definition: DeviceCommandContext.h:198
void * data
Definition: DeviceCommandContext.h:201
uint32_t width
Definition: DeviceCommandContext.h:199
uint32_t y
Definition: DeviceCommandContext.h:198
unsigned int uint32_t
Definition: wposix_types.h:53