Renderer API reference¶
Classes¶
Vortex2D::Renderer::Clear
Vortex2D::Renderer::Drawable
Vortex2D::Renderer::Ellipse
Vortex2D::Renderer::GenericBuffer
Vortex2D::Renderer::IndirectBuffer
Vortex2D::Renderer::Instance
Vortex2D::Renderer::IntRectangle
Vortex2D::Renderer::Rectangle
Vortex2D::Renderer::RenderState
Vortex2D::Renderer::RenderTarget
Vortex2D::Renderer::RenderTexture
Vortex2D::Renderer::RenderWindow
Vortex2D::Renderer::Sprite
Vortex2D::Renderer::Timer
Vortex2D::Renderer::Transformable
Vortex2D::Renderer::UniformBuffer
Vortex2D::Renderer::VertexBuffer
Vortex2D::Renderer::Work
API Reference¶
-
namespace
Renderer
¶ Typedefs
-
using
Vortex2D::Renderer::DescriptorTypeBindings = typedef std::map<uint32_t, vk::DescriptorType>
-
typedef std::vector<glm::vec2>
Path
¶
Functions
-
void
BufferBarrier
(vk::Buffer buffer, vk::CommandBuffer commandBuffer, vk::AccessFlags oldAccess, vk::AccessFlags newAccess)¶ Inserts a barrier for the given buffer, command buffer and access.
- Parameters
buffer
: the vulkan buffer handlecommandBuffer
: the command buffer to inserts the barrieroldAccess
: old accessnewAccess
: new access
-
template <template< typename > class BufferType, typename T>
voidCopyTo
(BufferType<T> &buffer, T &t)¶ Copy the content of a buffer in an object.
-
template <template< typename > class BufferType, typename T>
voidCopyTo
(BufferType<T> &buffer, std::vector<T> &t)¶ Copy the content of a buffer to a vector. Vector needs to have the correct size already.
-
template <template< typename > class BufferType, typename T>
voidCopyFrom
(BufferType<T> &buffer, const T &t)¶ Copy the content of an object to the buffer.
-
template <template< typename > class BufferType, typename T>
voidCopyFrom
(BufferType<T> &buffer, const std::vector<T> &t)¶ Copy the content of a vector to the buffer.
-
void VORTEX2D_API Vortex2D::Renderer::ExecuteCommand(const Device & device, CommandBuffer::CommandFn commandFn)
Runs immediately a set of commands and waits for them to finish.
- Parameters
device
: vulkan devicecommandFn
: lambda that runs the commands.
-
bool
operator==
(const ShaderLayout &left, const ShaderLayout &right)¶
-
bool
operator==
(const PipelineLayout &left, const PipelineLayout &right)¶
-
vk::DescriptorType
GetDescriptorType
(uint32_t bind, const PipelineLayout &layout)¶
-
VORTEX2D_API void Vortex2D::Renderer::Bind(const Device & device, vk::DescriptorSet dstSet, const PipelineLayout & layout, const std::vector< BindingInput > & bindingInputs)
Bind the resources (buffer or texture/sampler) to a DescriptorSet.
- Parameters
device
: vulkan devicedstSet
: vulkan descriptor setlayout
: pipeline layoutbindingInputs
: list of resources (buffer or texture/sampler)
-
bool
HasLayer
(const char *extension, const std::vector<vk::LayerProperties> &availableExtensions)¶
-
bool
HasExtension
(const char *extension, const std::vector<vk::ExtensionProperties> &availableExtensions)¶
-
VORTEX2D_API vk::UniquePipeline Vortex2D::Renderer::MakeComputePipeline(vk::Device device, vk::ShaderModule shader, vk::PipelineLayout layout, uint32_t localX, uint32_t localY)
-
bool
operator==
(const RenderState &left, const RenderState right)¶
-
VORTEX2D_API ComputeSize Vortex2D::Renderer::MakeStencilComputeSize(const glm::ivec2 & size, int radius)
Create a ComputeSize for a stencil type shader.
- Return
- calculate ComputeSize
- Parameters
size
: the domain sizeradius
: the stencil size
-
VORTEX2D_API ComputeSize Vortex2D::Renderer::MakeCheckerboardComputeSize(const glm::ivec2 & size)
Create a ComputeSize for a checkerboard type shader.
- Return
- calculate ComputeSize
- Parameters
size
: the domain size
-
class
AbstractShape
: public Vortex2D::Renderer::Drawable, public Vortex2D::Renderer::Transformable¶ - #include <Shapes.h>
An polygonal shape where the fragment shader can be specified for customisation.
Subclassed by Vortex2D::Renderer::IntRectangle, Vortex2D::Renderer::Rectangle
Public Functions
-
AbstractShape
(const Device &device, const SpirvBinary &fragShader, const std::vector<glm::vec2> &vertices)¶
-
AbstractShape
(AbstractShape &&other)¶
-
virtual VORTEX2D_API
~AbstractShape
()¶
-
void
Initialize
(const RenderState &renderState)¶ Initialize the drawable for a particular state. This might include creating the correct pipeline. If it was already initialized, it will do nothing.
- Parameters
renderState
: the state to initialize with.
-
void
Update
(const glm::mat4 &projection, const glm::mat4 &view)¶ Update the MVP matrix of the drawable.
- Parameters
projection
: the projection matrixview
: the view matrix
-
void
Draw
(vk::CommandBuffer commandBuffer, const RenderState &renderState)¶ Draw for the given render state. This has to be initialized before.
- Parameters
commandBuffer
: the command buffer to record into.renderState
: the render state to use.
Public Members
-
glm::vec4
Colour
¶
-
-
class
AbstractSprite
: public Vortex2D::Renderer::Drawable, public Vortex2D::Renderer::Transformable¶ - #include <Sprite.h>
a Sprite, i.e. a drawable that can render a texture. The fragment shader can be specified for customisation.
Subclassed by Vortex2D::Fluid::DistanceField, Vortex2D::Renderer::Sprite
Public Functions
-
AbstractSprite
(const Device &device, const SpirvBinary &fragShaderName, Texture &texture)¶
-
AbstractSprite
(AbstractSprite &&other)¶
-
virtual VORTEX2D_API
~AbstractSprite
()¶
-
void
Initialize
(const RenderState &renderState)¶ Initialize the drawable for a particular state. This might include creating the correct pipeline. If it was already initialized, it will do nothing.
- Parameters
renderState
: the state to initialize with.
-
void
Update
(const glm::mat4 &projection, const glm::mat4 &view)¶ Update the MVP matrix of the drawable.
- Parameters
projection
: the projection matrixview
: the view matrix
-
void
Draw
(vk::CommandBuffer commandBuffer, const RenderState &renderState)¶ Draw for the given render state. This has to be initialized before.
- Parameters
commandBuffer
: the command buffer to record into.renderState
: the render state to use.
-
template <typename T>
voidPushConstant
(vk::CommandBuffer commandBuffer, uint32_t offset, const T &data)¶
Public Members
-
glm::vec4
Colour
= {1.0f, 1.0f, 1.0f, 1.0f}¶
-
-
struct
BindingInput
¶ - #include <DescriptorSet.h>
The texture/sampler or buffer that can be binded to a shader.
Public Functions
-
BindingInput
(Renderer::GenericBuffer &buffer, uint32_t bind = DefaultBind)¶
-
BindingInput
(Renderer::Texture &texture, uint32_t bind = DefaultBind)¶
-
BindingInput
(vk::Sampler sampler, Renderer::Texture &texture, uint32_t bind = DefaultBind)¶
Public Static Attributes
-
constexpr uint32_t
DefaultBind
= static_cast<uint32_t>(-1)¶
-
-
template <typename T>
classBuffer
: public Vortex2D::Renderer::GenericBuffer¶ - #include <Buffer.h>
a storage buffer type of buffer
-
class
Clear
: public Vortex2D::Renderer::Drawable¶ - #include <Shapes.h>
A drawable that simply clears the target.
Public Functions
-
Clear
(const glm::vec4 &colour)¶
-
void
Initialize
(const RenderState &renderState)¶ Initialize the drawable for a particular state. This might include creating the correct pipeline. If it was already initialized, it will do nothing.
- Parameters
renderState
: the state to initialize with.
-
void
Update
(const glm::mat4 &projection, const glm::mat4 &view)¶ Update the MVP matrix of the drawable.
- Parameters
projection
: the projection matrixview
: the view matrix
-
void
Draw
(vk::CommandBuffer commandBuffer, const RenderState &renderState)¶ Draw for the given render state. This has to be initialized before.
- Parameters
commandBuffer
: the command buffer to record into.renderState
: the render state to use.
-
-
class
CommandBuffer
¶ - #include <CommandBuffer.h>
Can record commands, then submit them (multiple times). A fence can used to wait on the completion of the commands.
Public Types
-
using
CommandFn
= std::function<void(vk::CommandBuffer)>¶
Public Functions
-
CommandBuffer
(const Device &device, bool synchronise = true)¶ Creates a command buffer which can be synchronized.
- Parameters
device
: vulkan devicesynchronise
: flag to determine if the command buffer can be waited on.
-
~CommandBuffer
()¶
-
CommandBuffer
(CommandBuffer &&other)¶
-
CommandBuffer &
operator=
(CommandBuffer &&other)¶
-
void
Record
(CommandFn commandFn)¶ Record some commands. The commads are recorded in the lambda which is immediately executed.
- Parameters
commandFn
: a functor, or simply a lambda, where commands are recorded.
-
void
Record
(const RenderTarget &renderTarget, vk::Framebuffer framebuffer, CommandFn commandFn)¶ Record some commands inside a render pass. The commads are recorded in the lambda which is immediately executed.
- Parameters
renderTarget
: the render target which contains the render pass to record intoframebuffer
: the frame buffer where the render pass will render.commandFn
: a functor, or simply a lambda, where commands are recorded.
-
void
Wait
()¶ Wait for the command submit to finish. Does nothing if the synchronise flag was false.
-
void
Reset
()¶ Reset the command buffer so it can be recorded again.
-
void
Submit
(const std::initializer_list<vk::Semaphore> &waitSemaphores = {}, const std::initializer_list<vk::Semaphore> &signalSemaphores = {})¶ submit the command buffer
-
operator bool
() const¶ explicit conversion operator to bool, indicates if the command was properly recorded and can be sumitted.
-
using
-
struct
ComputeSize
¶ - #include <Work.h>
Used for a compute shader, and defines the group size, local size and domain size.
Public Functions
-
ComputeSize
(const glm::ivec2 &size)¶ Creates a ComputeSize using a 2D domain size and the default 2D local size.
- Parameters
size
: the domain size
-
ComputeSize
(int size)¶ Creates a ComputeSize using a 1D domain size and the default 1D local size.
- Parameters
size
: the domain size
Public Static Functions
-
glm::ivec2
GetLocalSize2D
()¶ The default local size for 2D compute shaders.
- Return
- a 2d vector
-
int
GetLocalSize1D
()¶ The default local size for 1D compute shaders.
- Return
- a integer value
-
glm::ivec2
GetWorkSize
(const glm::ivec2 &size)¶ Computes the 2D group size given a domain size.
- Return
- the group size
- Parameters
size
: the domain size of the shader
-
glm::ivec2
GetWorkSize
(int size)¶ Computes the 1D group size given a domain size.
- Return
- the group size
- Parameters
size
: the domain size of the shader
-
ComputeSize
Default2D
()¶ A default ComputeSize using the default 2D local size. The domain size is (1,1)
- Return
- a default compute size
-
ComputeSize
Default1D
()¶ A default ComputeSize using the default 1D local size. The domain size is (1,1)
- Return
- a default compute size
-
-
struct
DescriptorImage
¶ - #include <DescriptorSet.h>
The texture or sampler that can be binded to a shader.
Public Functions
-
struct
DescriptorSet
¶ - #include <DescriptorSet.h>
The binding of an object for a shader.
-
class
Device
¶ - #include <Device.h>
Encapsulation around the vulkan device. Allows to create command buffers, layout, bindings, memory and shaders.
Public Functions
-
Device
(vk::PhysicalDevice physicalDevice, bool validation = true)¶
-
Device
(vk::PhysicalDevice physicalDevice, vk::SurfaceKHR surface, bool validation = true)¶
-
Device
(vk::PhysicalDevice physicalDevice, int familyIndex, bool validation = true)¶
-
~Device
()¶
-
vk::Device
Handle
() const¶
-
vk::Queue
Queue
() const¶
-
vk::PhysicalDevice
GetPhysicalDevice
() const¶
-
int
GetFamilyIndex
() const¶
-
std::vector<vk::CommandBuffer>
CreateCommandBuffers
(uint32_t size) const¶
-
void
FreeCommandBuffers
(vk::ArrayProxy<const vk::CommandBuffer> commandBuffers) const¶
-
VmaAllocator
Allocator
() const¶
-
LayoutManager &
GetLayoutManager
() const¶
-
vk::ShaderModule
GetShaderModule
(const SpirvBinary &spirv) const¶
-
-
struct
DispatchParams
¶ - #include <Work.h>
Parameters for indirect compute: group size, local size, etc.
Public Functions
-
DispatchParams
(int count)¶
-
-
struct
Drawable
¶ - #include <Drawable.h>
Interface of a drawable object.
Subclassed by Vortex2D::Fluid::Circle, Vortex2D::Fluid::Polygon, Vortex2D::Renderer::AbstractShape, Vortex2D::Renderer::AbstractSprite, Vortex2D::Renderer::Clear, Vortex2D::Renderer::Ellipse
Public Functions
-
virtual
~Drawable
()¶
-
virtual void
Initialize
(const RenderState &renderState) = 0¶ Initialize the drawable for a particular state. This might include creating the correct pipeline. If it was already initialized, it will do nothing.
- Parameters
renderState
: the state to initialize with.
-
virtual void
Update
(const glm::mat4 &projection, const glm::mat4 &view) = 0¶ Update the MVP matrix of the drawable.
- Parameters
projection
: the projection matrixview
: the view matrix
-
virtual void
Draw
(vk::CommandBuffer commandBuffer, const RenderState &renderState) = 0¶ Draw for the given render state. This has to be initialized before.
- Parameters
commandBuffer
: the command buffer to record into.renderState
: the render state to use.
-
virtual
-
class
Ellipse
: public Vortex2D::Renderer::Drawable, public Vortex2D::Renderer::Transformable¶ - #include <Shapes.h>
A solid colour ellipse. Implements the Drawable interface and Transformable interface.
Public Functions
-
void
Initialize
(const RenderState &renderState)¶ Initialize the drawable for a particular state. This might include creating the correct pipeline. If it was already initialized, it will do nothing.
- Parameters
renderState
: the state to initialize with.
-
void
Update
(const glm::mat4 &projection, const glm::mat4 &view)¶ Update the MVP matrix of the drawable.
- Parameters
projection
: the projection matrixview
: the view matrix
-
void
Draw
(vk::CommandBuffer commandBuffer, const RenderState &renderState)¶ Draw for the given render state. This has to be initialized before.
- Parameters
commandBuffer
: the command buffer to record into.renderState
: the render state to use.
Public Members
-
glm::vec4
Colour
¶
-
void
-
class
GenericBuffer
¶ - #include <Buffer.h>
A vulkan buffer which can be on the host or the device.
Subclassed by Vortex2D::Renderer::Buffer< float >, Vortex2D::Renderer::Buffer< glm::ivec2 >, Vortex2D::Renderer::Buffer< glm::vec2 >, Vortex2D::Renderer::Buffer< int >, Vortex2D::Renderer::Buffer< Renderer::DispatchParams >, Vortex2D::Renderer::Buffer< Vortex2D::Fluid::Particle >, Vortex2D::Renderer::Buffer< Vortex2D::Fluid::RigidBody::Velocity >, Vortex2D::Renderer::Buffer< Vortex2D::Fluid::RigidBody::Vortex2D::Fluid::Velocity >, Vortex2D::Renderer::IndirectBuffer< Renderer::DispatchParams >, Vortex2D::Renderer::UniformBuffer< glm::mat4 >, Vortex2D::Renderer::UniformBuffer< glm::vec4 >, Vortex2D::Renderer::UniformBuffer< Size >, Vortex2D::Renderer::UniformBuffer< Vortex2D::Fluid::RigidBody::Velocity >, Vortex2D::Renderer::VertexBuffer< glm::vec2 >, Vortex2D::Renderer::VertexBuffer< Vortex2D::Renderer::AbstractSprite::Vertex >, Vortex2D::Renderer::Buffer< T >, Vortex2D::Renderer::IndirectBuffer< T >, Vortex2D::Renderer::UniformBuffer< T >, Vortex2D::Renderer::VertexBuffer< T >
Public Functions
-
GenericBuffer
(const Device &device, vk::BufferUsageFlags usageFlags, VmaMemoryUsage memoryUsage, vk::DeviceSize deviceSize)¶
-
~GenericBuffer
()¶
-
GenericBuffer
(GenericBuffer &&other)¶
-
void
CopyFrom
(vk::CommandBuffer commandBuffer, GenericBuffer &srcBuffer)¶ Copy a buffer to this buffer.
- Parameters
commandBuffer
: command buffer to run the copy on.srcBuffer
: the source buffer.
-
void
CopyFrom
(vk::CommandBuffer commandBuffer, Texture &srcTexture)¶ Copy a texture to this buffer.
- Parameters
commandBuffer
: command buffer to run the copy on.srcTexture
: the source texture
-
vk::Buffer
Handle
() const¶ The vulkan handle.
-
vk::DeviceSize
Size
() const¶ The size in bytes of the buffer.
-
void
Barrier
(vk::CommandBuffer commandBuffer, vk::AccessFlags oldAccess, vk::AccessFlags newAccess)¶ Inserts a barrier for this buffer.
- Parameters
commandBuffer
: the command buffer to run the barrieroldAccess
: old accessnewAccess
: new access
Friends
-
template <template< typename > class BufferType, typename T>
voidCopyFrom
(BufferType<T> &buffer, const T &t)¶ Copy the content of an object to the buffer.
-
template <template< typename > class BufferType, typename T>
voidCopyTo
(BufferType<T> &buffer, T &t)¶ Copy the content of a buffer in an object.
-
template <template< typename > class BufferType, typename T>
voidCopyTo
(BufferType<T> &buffer, std::vector<T> &t)¶ Copy the content of a buffer to a vector. Vector needs to have the correct size already.
-
template <template< typename > class BufferType, typename T>
voidCopyFrom
(BufferType<T> &buffer, const std::vector<T> &t)¶ Copy the content of a vector to the buffer.
-
-
class
GraphicsPipeline
¶ - #include <Pipeline.h>
graphics pipeline which caches the pipeline per render states.
Public Functions
-
GraphicsPipeline
()¶
-
void
Create
(vk::Device device, const RenderState &renderState)¶
-
void
Bind
(vk::CommandBuffer commandBuffer, const RenderState &renderState)¶
-
class
Builder
¶ - #include <Pipeline.h>
Builder for graphics pipeline.
Public Functions
-
Builder
()¶
-
GraphicsPipeline::Builder &
Shader
(vk::ShaderModule shader, vk::ShaderStageFlagBits shaderStage)¶ Set the shader.
- Return
- *this
- Parameters
shader
: the loaded shadershaderStage
: shader state (vertex, fragment or compute)
-
GraphicsPipeline::Builder &
VertexAttribute
(uint32_t location, uint32_t binding, vk::Format format, uint32_t offset)¶ Sets the vertex attributes.
- Return
- *this
- Parameters
location
: location in the shaderbinding
: binding in the shaderformat
: vertex formatoffset
: offset in the vertex
-
GraphicsPipeline::Builder &
VertexBinding
(uint32_t binding, uint32_t stride, vk::VertexInputRate inputRate = vk::VertexInputRate::eVertex)¶ Sets the vertex binding.
- Return
- *this
- Parameters
binding
: binding in the shaderstride
: stride in bytesinputRate
: inpute rate
-
GraphicsPipeline::Builder &
Topology
(vk::PrimitiveTopology topology)¶
-
GraphicsPipeline::Builder &
Layout
(vk::PipelineLayout pipelineLayout)¶
-
vk::UniquePipeline
Create
(vk::Device device, const RenderState &renderState)¶
-
-
-
template <typename T>
classIndirectBuffer
: public Vortex2D::Renderer::GenericBuffer¶ - #include <Buffer.h>
an indirect buffer type of buffer, used for compute indirect dispatch
-
class
Instance
¶ - #include <Instance.h>
Vulkan instance, which extensions enabled.
-
class
IntRectangle
: public Vortex2D::Renderer::AbstractShape¶ - #include <Shapes.h>
A solid colour rectangle as Rectangle, however uses integer colors and is meant to be drawn to a framebuffer wiht integer colours.
-
class
LayoutManager
¶ - #include <DescriptorSet.h>
Caches and creates layouts and bindings.
Public Functions
-
void
CreateDescriptorPool
()¶ Create or re-create the descriptor pool, will render invalid existing descriptor sets.
-
DescriptorSet
MakeDescriptorSet
(const PipelineLayout &layout)¶ Create the descriptor set given the layout.
- Return
- built descriptor set
- Parameters
layout
: pipeline/shader layout
-
vk::DescriptorSetLayout
GetDescriptorSetLayout
(const PipelineLayout &layout)¶ Create, cache and return a descriptor layout given the pipeline layout.
- Return
- cached descriptor set layout
- Parameters
layout
: pipeline layout
-
vk::PipelineLayout
GetPipelineLayout
(const PipelineLayout &layout)¶ create, cache and return a vulkan pipeline layout given the layout
- Return
- vulkan pipeline layout
- Parameters
layout
: pipeline layout
-
void
-
struct
PipelineLayout
¶ - #include <DescriptorSet.h>
Represents the layout of a pipeline: vertex + fragment or compute.
Public Members
-
std::vector<ShaderLayout>
layouts
¶
-
std::vector<ShaderLayout>
-
template <typename T>
classproperty
¶ - #include <Transformable.h>
Simple class to simulate properties like in C#.
-
class
Rectangle
: public Vortex2D::Renderer::AbstractShape¶ - #include <Shapes.h>
A solid colour rectangle defined by two triangles. Implements the Drawable interface and Transformable interface.
-
class
RenderCommand
¶ - #include <CommandBuffer.h>
A special command buffer that has been recorded by a RenderTarget. It can be used to submit the rendering. The object has to stay alive untill rendering is complete.
Public Functions
-
RenderCommand
()¶
-
~RenderCommand
()¶
-
RenderCommand
(RenderCommand &&other)¶
-
RenderCommand &
operator=
(RenderCommand &&other)¶
-
void
Submit
(const glm::mat4 &view = glm::mat4())¶ Submit the render command with a transform matrix.
- Parameters
view
: a transform matrix
Friends
-
friend
Vortex2D::Renderer::RenderTexture
-
friend
Vortex2D::Renderer::RenderWindow
-
-
class
RenderpassBuilder
¶ - #include <RenderTarget.h>
Factory for a vulkan render pass.
Public Functions
-
RenderpassBuilder &
Attachement
(vk::Format format)¶ Format of the render pass.
- Return
- Parameters
format
:
-
RenderpassBuilder &
AttachementLoadOp
(vk::AttachmentLoadOp value)¶ operation to perform when loading the framebuffer (clear, load, etc)
- Return
- Parameters
value
:
-
RenderpassBuilder &
AttachementStoreOp
(vk::AttachmentStoreOp value)¶ operation to perform when storing the framebuffer (clear, save, etc)
- Return
- Parameters
value
:
-
RenderpassBuilder &
AttachementInitialLayout
(vk::ImageLayout layout)¶ Layout of the image to be before render pass.
- Return
- Parameters
layout
:
-
RenderpassBuilder &
AttachementFinalLayout
(vk::ImageLayout layout)¶ Layout of the image to be after render pass.
- Return
- Parameters
layout
:
-
RenderpassBuilder &
Subpass
(vk::PipelineBindPoint bindPoint)¶ Define subpass of the render pass.
- Return
- Parameters
bindPoint
:
-
RenderpassBuilder &
SubpassColorAttachment
(vk::ImageLayout layout, uint32_t attachment)¶ Set the color attachment with index.
- Return
- Parameters
layout
:attachment
: index of the attachment
-
RenderpassBuilder &
Dependency
(uint32_t srcSubpass, uint32_t dstSubpass)¶ Dependency of the subpasses.
- Return
- Parameters
srcSubpass
:dstSubpass
:
-
RenderpassBuilder &
DependencySrcStageMask
(vk::PipelineStageFlags value)¶
-
RenderpassBuilder &
DependencyDstStageMask
(vk::PipelineStageFlags value)¶
-
RenderpassBuilder &
DependencySrcAccessMask
(vk::AccessFlags value)¶
-
RenderpassBuilder &
DependencyDstAccessMask
(vk::AccessFlags value)¶
-
vk::UniqueRenderPass
Create
(vk::Device device)¶ Create the render pass.
- Return
- Parameters
device
:
-
RenderpassBuilder &
-
class
RenderState
¶ - #include <RenderState.h>
the various state to render to a target: size, render pass and blend.
Public Functions
-
RenderState
(const RenderTarget &renderTarget)¶ Initialize for a render target with default blend.
- Parameters
renderTarget
:
-
RenderState
(const RenderTarget &renderTarget, vk::PipelineColorBlendAttachmentState colorBlend)¶ Initialize for a render target with a given blend.
- Parameters
renderTarget
:colorBlend
:
-
-
struct
RenderTarget
¶ - #include <RenderTarget.h>
A target that can be rendered to. This is implemented by the RenderWindow and the RenderTexture.
Subclassed by Vortex2D::Renderer::RenderTexture, Vortex2D::Renderer::RenderWindow
Public Functions
-
RenderTarget
(uint32_t width, uint32_t height)¶
-
RenderTarget
(RenderTarget &&other)¶
-
~RenderTarget
()¶
-
virtual VORTEX2D_API RenderCommand Vortex2D::Renderer::RenderTarget::Record(DrawableList drawables, vk::PipelineColorBlendAttachmentState blendMode = {})
= 0
-
virtual VORTEX2D_API void Vortex2D::Renderer::RenderTarget::Submit(RenderCommand & renderCommand)
= 0
-
-
class
RenderTexture
: public Vortex2D::Renderer::RenderTarget, public Vortex2D::Renderer::Texture¶ - #include <RenderTexture.h>
A render target that renders into a texture.
Subclassed by Vortex2D::Fluid::Density, Vortex2D::Fluid::LevelSet, Vortex2D::Fluid::ParticleCount, Vortex2D::Fluid::Velocity
Public Functions
-
RenderCommand
Record
(DrawableList drawables, vk::PipelineColorBlendAttachmentState blendMode = {})¶
-
void
Submit
(RenderCommand &renderCommand)¶
-
RenderCommand
-
class
RenderWindow
: public Vortex2D::Renderer::RenderTarget¶ - #include <RenderWindow.h>
Render to a swapchain, i.e. to the window/surface.
Public Functions
-
RenderWindow
(const Device &device, vk::SurfaceKHR surface, uint32_t width, uint32_t height)¶ Initialize with a given surface and size.
- Parameters
device
: vulkan devicesurface
: vulkan surfacewidth
:height
:
-
RenderCommand
Record
(DrawableList drawables, vk::PipelineColorBlendAttachmentState blendMode = {})¶
-
void
Submit
(RenderCommand &renderCommand)¶
-
void
Display
()¶ Submits all the render command and present the surface for display.
-
-
class
SamplerBuilder
¶ - #include <Texture.h>
Factory for a vullkan sampler.
Public Functions
-
SamplerBuilder
()¶
-
SamplerBuilder &
AddressMode
(vk::SamplerAddressMode mode)¶ Mode of the sampler: repeat, clamp, etc.
- Return
- *this
- Parameters
mode
: vulkan mode
-
SamplerBuilder &
Filter
(vk::Filter filter)¶ Filter of the sampler: linear, nearest, etc.
- Return
- *this
- Parameters
filter
: vulkan filter
-
vk::UniqueSampler
Create
(vk::Device device)¶ Create the vulkan sampler.
- Return
- unique sampler
- Parameters
device
: vulkan device
-
-
struct
ShaderLayout
¶ - #include <DescriptorSet.h>
Represents the layout of a shader (vertex, fragment or compute)
Public Functions
-
ShaderLayout
(const SPIRV::Reflection &reflection)¶
-
-
class
SpirvBinary
¶ - #include <Device.h>
A binary SPIRV shader, to be feed to vulkan.
-
class
Sprite
: public Vortex2D::Renderer::AbstractSprite¶ - #include <Sprite.h>
A sprite that renders a texture with a simple pass-through fragment shader.
Subclassed by Vortex2D::Fluid::Density
-
struct
SwapChainSupportDetails
¶
-
class
Texture
¶ - #include <Texture.h>
A texture, or in vulkan terms, an image.
Subclassed by Vortex2D::Renderer::RenderTexture
Public Functions
-
Texture
(const Device &device, uint32_t width, uint32_t height, vk::Format format, VmaMemoryUsage memoryUsage = VMA_MEMORY_USAGE_GPU_ONLY)¶
-
~Texture
()¶
-
template <typename T>
voidCopyFrom
(const std::vector<T> &data)¶
-
template <typename T>
voidCopyTo
(std::vector<T> &data)¶
-
void
Barrier
(vk::CommandBuffer commandBuffer, vk::ImageLayout oldLayout, vk::AccessFlags oldAccess, vk::ImageLayout newLayout, vk::AccessFlags newAccess)¶
-
vk::ImageView
GetView
() const¶
-
uint32_t
GetWidth
() const¶
-
uint32_t
GetHeight
() const¶
-
vk::Format
GetFormat
() const¶
-
void
Clear
(vk::CommandBuffer commandBuffer, const std::array<int, 4> &colour)¶
-
void
Clear
(vk::CommandBuffer commandBuffer, const std::array<float, 4> &colour)¶
Friends
-
friend
Vortex2D::Renderer::GenericBuffer
-
-
class
Timer
¶ - #include <Timer.h>
Calculates the ellapsed time on the GPU.
Public Functions
-
void
Start
()¶ Start the timer after the current last command buffer.
-
void
Stop
()¶ Stop the timer after the current last command buffer.
-
uint64_t
GetElapsedNs
()¶ Get the elapsed time between the Start and Stop calls. Blocking function which will download the timestamps from the GPU.
- Return
- timestamp in nanoseconds.
-
void
-
struct
Transformable
¶ - #include <Transformable.h>
Class to represent the transformation of an object: position, scale, rotation and anchor.
Subclassed by Vortex2D::Fluid::Circle, Vortex2D::Fluid::Polygon, Vortex2D::Fluid::RigidBody, Vortex2D::Renderer::AbstractShape, Vortex2D::Renderer::AbstractSprite, Vortex2D::Renderer::Ellipse
-
template <typename T>
classUniformBuffer
: public Vortex2D::Renderer::GenericBuffer¶ - #include <Buffer.h>
a uniform buffer type of buffer
-
template <typename T>
classVertexBuffer
: public Vortex2D::Renderer::GenericBuffer¶ - #include <Buffer.h>
a vertex buffer type of buffer
-
class
Work
¶ - #include <Work.h>
Represents a compute shader. It simplifies the process of binding, setting push constants and recording.
Public Functions
-
Work
(const Device &device, const ComputeSize &computeSize, const SpirvBinary &spirv)¶ Constructs an object using a SPIRV binary. It is not bound to any buffers or textures.
- Parameters
device
: vulkan devicecomputeSize
: the compute size. Can be a default one with size (1,1) or one with an actual size.spirv
: binary spirv
-
Work::Bound
Bind
(const std::vector<BindingInput> &inputs)¶ Bind the buffers and/or textures.
- Return
- a bound object, ready to be recorded in a command buffer.
- Parameters
inputs
: a list of buffers and/or textures
-
VORTEX2D_API Bound Vortex2D::Renderer::Work::Bind(ComputeSize computeSize, const std::vector< BindingInput > & inputs)
Bind the buffers and/or textures. This overrides the provided compute size in Work.
- Return
- a bound object, ready to be recorded in a command buffer.
- Parameters
computeSize
: the compute shader compute size.inputs
: a list of buffers and/or textures
-
class
Bound
¶ - #include <Work.h>
Is a bound version of Work. This means a buffer or texture was bound and this can be recorded in a command buffer.
Public Functions
-
Bound
()¶
-
template <typename T>
voidPushConstant
(vk::CommandBuffer commandBuffer, uint32_t offset, const T &data)¶ Adds a constant value, i.e. a push constant.
- Parameters
commandBuffer
: the command buffer where the compute work will also be recorded.offset
: the offset in which the push constant is to be placed.data
: the data to push. A total of 128 bytes can be used.
-
void
Record
(vk::CommandBuffer commandBuffer)¶ Record the compute work in this command buffer. This will also set two additional push constants: the 2D domain size.
- Parameters
commandBuffer
: the command buffer to record into.
-
void
RecordIndirect
(vk::CommandBuffer commandBuffer, IndirectBuffer<DispatchParams> &dispatchParams)¶ Record the compute work in this command buffer. Use the provided parameters to run the compute shader.
- Parameters
commandBuffer
: the command buffer to record into.dispatchParams
: the indirect buffer containing the parameters.
-
void
Dispatch
(vk::CommandBuffer commandBuffer)¶ Record the compute work in this command buffer.
- Parameters
commandBuffer
: the command buffer to record into.
Friends
-
friend
Vortex2D::Renderer::Work
-
-
-
using