3#include "../Base/ContextCommon.h"
10#include "RenderTargetsVK.h"
14#include "ContextStateVK.h"
26 void setViewport(
const float x,
const float y,
const float width,
const float height)
override;
27 void setScissor(
const int x,
const int y,
const int width,
const int height)
override;
31 void clearDepth(
const float depth = 1.0f)
override;
59 void draw(
PrimitiveType primitiveType,
const size_t startVertex,
const size_t numVertexes)
override;
60 void drawIndexed(
PrimitiveType primitiveType,
const size_t startIndex,
const size_t numIndexes,
const size_t startVertex)
override;
61 void drawInstanced(
PrimitiveType primitiveType,
const size_t startVertex,
const size_t numVertexes,
const size_t startInstance,
const size_t numInstances)
override;
62 void drawInstancedIndexed(
PrimitiveType primitiveType,
const size_t startInstance,
const size_t numInstances,
const size_t startIndex,
const size_t numIndexes)
override;
63 void dispatchCompute(
const unsigned int threadGroupsX,
const unsigned int threadGroupsY,
const unsigned int threadGroupsZ)
override;
81 void copyTexture(
TextureHandle dstHandle,
unsigned dstSub,
unsigned dstX,
unsigned dstY,
unsigned dstZ,
TextureHandle sourceHandle,
unsigned srcSub)
override;
83 void clearResource(
BufferHandle destinationHandle, uint32_t *Values)
override {}
84 void clearResource(
BufferHandle destinationHandle,
float *Values)
override {}
86 bool updateDescriptorSet();
92 void beginRenderPass();
95 void updateConstantBuffers();
98 EffectHandle getCurrentEffect()
override {
return currentEffect; }
99 IEffects * getEffects() {
return effects; }
114 VkRenderPass renderPass = VK_NULL_HANDLE;
121 VkCommandPool commandPool = VK_NULL_HANDLE;
122 VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
124 VkFence fence = VK_NULL_HANDLE;
125 VkSemaphore presentSemaphore = VK_NULL_HANDLE;
127 std::vector<PoolBufferVK *> orhpanedBuffers;
128 std::vector<TextureHandle> orphanedTextures;
130 VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
135 std::vector<VkClearValue> clearValues;
137 std::array<FrameResources, 3> frameResources;
140 VkPipelineCache pipelineCache = VK_NULL_HANDLE;
141 std::unordered_map<size_t, VkPipeline> PSOs;
143 VkDescriptorPool descriptorPool = VK_NULL_HANDLE;
144 std::vector<VkDescriptorSet> descriptorSets;
146 uint64_t currentFrame = 0;
160 VkDevice device = VK_NULL_HANDLE;
void setRasterizerState(const RasterizerStateHandle handle) override
Set the current rasterizer state.
void clearDepth(const float depth=1.0f) override
Clear the currently set depth/stencil target to the given depth.
void draw(PrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes) override
Draws non-indexed, non-instanced primitives.
void endRenderPass()
End a render pass.
void drawInstanced(PrimitiveType primitiveType, const size_t startVertex, const size_t numVertexes, const size_t startInstance, const size_t numInstances) override
Draws non-indexed, instanced primitives.
void setViewport(const float x, const float y, const float width, const float height) override
Sets the current viewport to the given location and dimensions.
void setBufferCounter(BufferHandle bufferHandle, uint32_t value) override
Set the associated counter of a buffer.
void clearRenderTarget(const float *color) override
Clear the currently set render target to the given value (4 component floating point RGBA).
void setBuffer(const BufferBindingHandle bindingHandle, BufferHandle bufferHandle) override
Sets a buffer to bind to the given binding.
void setInputLayout(const InputLayoutHandle inputLayoutHandle) override
Sets the current input layout.
void * map(BufferHandle bufferHandle, MapMode::EMapMode mapMode, uint32_t *stride=nullptr) override
Maps the given buffer so it can be accessed.
void getBufferCounter(BufferHandle bufferHandle, BufferHandle destinationBufferHandle) override
Get the associated counter of a buffer.
void updateSubTexture(TextureHandle textureHandle, const size_t level, const void *data) override
Update the data of a level in the given texture.
void updateBuffer(BufferHandle bufferHandle, const void *data, size_t size) override
Replace contents of buffer with new data.
void setIndexBuffer(IndexBufferHandle bufferHandle, uint32_t stride=4, uint32_t offset=0) override
Sets the current index buffer.
void unmap(BufferHandle bufferHandle) override
Unmaps the given buffer, applying any synchronization necessary to reflect changes in the mapped memo...
void setDepthStencilState(const DepthStencilStateHandle handle) override
Set the current depth stencil state.
void setBlendState(const BlendStateHandle handle, const float *constant=nullptr) override
Set the current blend state.
void setConstantBuffer(const ConstantBufferBindingHandle bufferBindingHandle, const BufferHandle bufferHandle, const uint32_t offset=0, const uint32_t size=~0u) override
Sets a constant buffer to the given constant buffer binding.
void setEffect(EffectHandle handle) override
Set the current effect.
void drawInstancedIndexed(PrimitiveType primitiveType, const size_t startInstance, const size_t numInstances, const size_t startIndex, const size_t numIndexes) override
Draws indexed, instanced primitives.
void readColorBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer framebuffer) override
Reads data from the current render target into the given bufferHandle.
void drawIndexed(PrimitiveType primitiveType, const size_t startIndex, const size_t numIndexes, const size_t startVertex) override
Draws indexed, non-instanced primitives.
void setScissor(const int x, const int y, const int width, const int height) override
Sets the current scissor rectangle.
void setTexture(const TextureBindingHandle textureBindingHandle, const TextureHandle textureHandle) override
Sets the texture given to the binding given by textureBindingHandle.
void resolveResource(TextureHandle source, TextureHandle destination) override
Resolves the given source resource target into the given destination texture.
void setRenderTarget(const RenderTargetHandle handle, const DepthStencilHandle depthStencilHandle) override
Sets the current render target and an associated depth stencil target.
void setVertexBuffers(const VertexBufferHandle *vertexBufferHandles, const size_t count, const uint32_t *strides, const uint32_t *offsets) override
Sets the current vertex buffers.
void readDepthBuffer(BufferHandle bufferHandle, int x, int y, int width, int height, Framebuffer framebuffer) override
Reads data from the current depth target into the given bufferHandle.
void dispatchCompute(const unsigned int threadGroupsX, const unsigned int threadGroupsY, const unsigned int threadGroupsZ) override
Dispatch computing work on the graphics device using the desired thread group count.
void setVertexArrayObject(VertexArrayObjectHandle vertexArrayObject) override
void updateSubBuffer(BufferHandle bufferHandle, const size_t offset, const size_t size, const void *data) override
Update a region of data in a buffer.
void setSamplerState(const SamplerStateBindingHandle samplerStateBindingHandle, const SamplerStateHandle samplerStateHandle) override
Sets the sampler state binding given to the given sampler state.
Contains all Cogs related functionality.
Framebuffer
Framebuffers to select from when doing framebuffer operations.
PrimitiveType
Primitive types for interpreting vertex data sent to the graphics pipeline.
Provides effects and shader management functionality.
EMapMode
Mapping mode enumeration.