|
TGUI 1.14-dev
|
Render target implementation that uses Vulkan. More...
#include <TGUI/Backend/Renderer/Vulkan/BackendRenderTargetVulkan.hpp>
Classes | |
| struct | DrawCommand |
| struct | FrameResources |
Public Member Functions | |
| BackendRenderTargetVulkan (std::shared_ptr< BackendRendererVulkan > renderer) | |
| Constructor. | |
| ~BackendRenderTargetVulkan () override | |
| Destructor. | |
| void | setClearColor (const Color &color) override |
| This function isn't used by this backend. | |
| void | clearScreen () override |
| This function isn't used by this backend. | |
| void | setView (FloatRect view, FloatRect viewport, Vector2f targetSize) override |
| Informs the render target about which part of the window is used for rendering. | |
| void | drawGui (const std::shared_ptr< RootContainer > &) override |
| This function is not used by this backend, use drawGui(root, VkCommandBuffer) instead. | |
| void | setRenderPass (VkRenderPass renderPass, VkFormat colorFormat, std::uint32_t maxFramesInFlight, std::uint32_t subpass=0, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT) |
| Informs the render target about the render pass in which the gui will be drawn. | |
| void | setDynamicRenderingFormats (VkFormat colorFormat, std::uint32_t maxFramesInFlight, VkFormat depthFormat=VK_FORMAT_UNDEFINED, VkFormat stencilFormat=VK_FORMAT_UNDEFINED, VkSampleCountFlagBits samples=VK_SAMPLE_COUNT_1_BIT) |
| Informs the render target that the gui will be drawn with dynamic rendering (vkCmdBeginRendering). | |
| bool | drawGui (const std::shared_ptr< RootContainer > &root, VkCommandBuffer cmdBuffer) |
| Draws the gui and all of its widgets. | |
| void | drawVertexArray (const RenderStates &states, const Vertex *vertices, std::size_t vertexCount, const unsigned int *indices, std::size_t indexCount, const std::shared_ptr< BackendTexture > &texture) override |
| Draws a vertex array. This is called by the other draw functions. | |
| Public Member Functions inherited from tgui::BackendRenderTarget | |
| BackendRenderTarget (const BackendRenderTarget &)=delete | |
| BackendRenderTarget (BackendRenderTarget &&)=delete | |
| BackendRenderTarget & | operator= (const BackendRenderTarget &)=delete |
| BackendRenderTarget & | operator= (BackendRenderTarget &&)=delete |
| BackendRenderTarget ()=default | |
| Default constructor. | |
| virtual | ~BackendRenderTarget ()=default |
| Virtual destructor. | |
| virtual void | drawWidget (const RenderStates &states, const std::shared_ptr< Widget > &widget) |
| Draws a widget, if the widget is visible. | |
| virtual void | addClippingLayer (const RenderStates &states, FloatRect rect) |
| Adds another clipping region. | |
| virtual void | removeClippingLayer () |
| Removes the last added clipping region. | |
| virtual void | drawBorders (const RenderStates &states, const Borders &borders, Vector2f size, Color color) |
| Draws borders inside a provided rectangle. | |
| virtual void | drawFilledRect (const RenderStates &states, Vector2f size, Color color) |
| Draws a colored rectangle. | |
| virtual void | drawSprite (const RenderStates &states, const Sprite &sprite) |
| Draws a texture. | |
| virtual void | drawText (const RenderStates &states, const Text &text) |
| Draws some text. | |
| virtual void | drawTextOutline (const RenderStates &states, const Text &text) |
| Draws only the outline of some text. | |
| virtual void | drawTextWithoutOutline (const RenderStates &states, const Text &text) |
| Draws some text, but without rendering its outline. | |
| virtual void | drawTriangle (const RenderStates &states, const Vertex &point1, const Vertex &point2, const Vertex &point3) |
| Draws a single triangles (using the color that is specified in the vertices). | |
| virtual void | drawCircle (const RenderStates &states, float size, const Color &backgroundColor, float borderThickness=0, const Color &borderColor={}) |
| Draws a circle. | |
| virtual void | drawRoundedRectangle (const RenderStates &states, const Vector2f &size, const Color &backgroundColor, float radius, const Borders &borders={0}, const Color &borderColor=Color::Black) |
| Draws a rounded rectangle. | |
| Vector2f | getPixelsPerPoint () const |
| Returns the current mapping between the screen pixels and the points in the current view. | |
Protected Member Functions | |
| void | updateClipping (FloatRect clipRect, FloatRect clipViewport) override |
| Called from addClippingLayer and removeClippingLayer to apply the clipping. | |
| void | retirePipeline () |
| void | setMaxFramesInFlight (std::uint32_t maxFramesInFlight) |
| void | destroyFrameResources () |
Protected Attributes | |
| std::shared_ptr< BackendRendererVulkan > | m_renderer |
| std::unique_ptr< BackendTextureVulkan > | m_emptyTexture |
| Transform | m_projectionTransform |
| VkPipeline | m_pipeline = VK_NULL_HANDLE |
| VkRenderPass | m_renderPass = VK_NULL_HANDLE |
| std::uint32_t | m_subpass = 0 |
| VkFormat | m_colorFormat = VK_FORMAT_UNDEFINED |
| VkFormat | m_depthFormat = VK_FORMAT_UNDEFINED |
| VkFormat | m_stencilFormat = VK_FORMAT_UNDEFINED |
| VkSampleCountFlagBits | m_samples = VK_SAMPLE_COUNT_1_BIT |
| std::vector< FrameResources > | m_frames |
| std::size_t | m_currentFrame = 0 |
| std::vector< Vertex > | m_vertices |
| std::vector< unsigned int > | m_indices |
| VkRect2D | m_clipRect = {} |
| Protected Attributes inherited from tgui::BackendRenderTarget | |
| FloatRect | m_viewRect |
| FloatRect | m_viewport |
| Vector2f | m_targetSize |
| std::vector< std::pair< FloatRect, FloatRect > > | m_clipLayers |
| Vector2f | m_pixelsPerPoint = {1, 1} |
Render target implementation that uses Vulkan.
Before the gui can be drawn, either setRenderPass or setDynamicRenderingFormats has to be called to specify where the gui will be rendered to.
| tgui::BackendRenderTargetVulkan::BackendRenderTargetVulkan | ( | std::shared_ptr< BackendRendererVulkan > | renderer | ) |
Constructor.
| renderer | Renderer that holds the Vulkan device |
|
override |
Destructor.
The destructor waits until the queue is idle, to make sure the GPU no longer uses any of the resources.
|
overridevirtual |
This function isn't used by this backend.
Implements tgui::BackendRenderTarget.
|
inlineoverridevirtual |
This function is not used by this backend, use drawGui(root, VkCommandBuffer) instead.
Implements tgui::BackendRenderTarget.
| bool tgui::BackendRenderTargetVulkan::drawGui | ( | const std::shared_ptr< RootContainer > & | root, |
| VkCommandBuffer | cmdBuffer ) |
Draws the gui and all of its widgets.
| root | Root container that holds all widgets in the gui |
| cmdBuffer | Command buffer to record the draw commands in, which must be inside an active render pass |
This function should be called once per frame. Textures may still be uploaded to the GPU during this call, which happens by submitting a separate command buffer to the queue. The command buffer must be submitted to the queue that was passed to the renderer in the VulkanContext, because the texture uploads are only synchronized with work that is submitted to that same queue.
|
overridevirtual |
Draws a vertex array. This is called by the other draw functions.
| states | Render states to use for drawing |
| vertices | Pointer to first element in array of vertices |
| vertexCount | Amount of elements in the vertex array |
| indices | Pointer to first element in array of indices |
| indexCount | Amount of elements in the indices array |
| texture | Texture to use, or nullptr when drawing colored triangles |
Implements tgui::BackendRenderTarget.
|
overridevirtual |
This function isn't used by this backend.
Implements tgui::BackendRenderTarget.
| void tgui::BackendRenderTargetVulkan::setDynamicRenderingFormats | ( | VkFormat | colorFormat, |
| std::uint32_t | maxFramesInFlight, | ||
| VkFormat | depthFormat = VK_FORMAT_UNDEFINED, | ||
| VkFormat | stencilFormat = VK_FORMAT_UNDEFINED, | ||
| VkSampleCountFlagBits | samples = VK_SAMPLE_COUNT_1_BIT ) |
Informs the render target that the gui will be drawn with dynamic rendering (vkCmdBeginRendering).
| colorFormat | Format of the color attachment |
| maxFramesInFlight | Maximum number of frames that your render loop lets the GPU execute at the same time (e.g. the amount of per-frame fences that you wait on). When drawGui is called, the frame that was drawn maxFramesInFlight frames earlier must have finished executing, otherwise TGUI can overwrite buffers that the GPU is still reading from. A value that is higher than needed only costs a bit of memory. |
| depthFormat | Format of the depth attachment, or VK_FORMAT_UNDEFINED if there is none |
| stencilFormat | Format of the stencil attachment, or VK_FORMAT_UNDEFINED if there is none |
| samples | Amount of samples of the attachments |
Exactly one color attachment must be used. sRGB formats are supported, but alpha blending then happens in linear space, so semi-transparent parts can look slightly different than with a UNORM format. Changing maxFramesInFlight waits until the queue is idle, as the resources of all frames are recreated. It thus shouldn't be changed while a command buffer in which the gui was drawn still has to be submitted. Dynamic rendering requires Vulkan 1.3 or the VK_KHR_dynamic_rendering extension, and the dynamicRendering feature has to be enabled on the device.
| void tgui::BackendRenderTargetVulkan::setRenderPass | ( | VkRenderPass | renderPass, |
| VkFormat | colorFormat, | ||
| std::uint32_t | maxFramesInFlight, | ||
| std::uint32_t | subpass = 0, | ||
| VkSampleCountFlagBits | samples = VK_SAMPLE_COUNT_1_BIT ) |
Informs the render target about the render pass in which the gui will be drawn.
| renderPass | Render pass that will be active when drawGui is called |
| colorFormat | Format of the color attachment of the subpass |
| maxFramesInFlight | Maximum number of frames that your render loop lets the GPU execute at the same time (e.g. the amount of per-frame fences that you wait on). When drawGui is called, the frame that was drawn maxFramesInFlight frames earlier must have finished executing, otherwise TGUI can overwrite buffers that the GPU is still reading from. A value that is higher than needed only costs a bit of memory. |
| subpass | Index of the subpass that will be active when drawGui is called |
| samples | Amount of samples of the color attachment |
The subpass must have exactly one color attachment. sRGB formats are supported, but alpha blending then happens in linear space, so semi-transparent parts can look slightly different than with a UNORM format. Changing maxFramesInFlight waits until the queue is idle, as the resources of all frames are recreated. It thus shouldn't be changed while a command buffer in which the gui was drawn still has to be submitted.
|
overridevirtual |
Informs the render target about which part of the window is used for rendering.
| view | Defines which part of the gui is being shown |
| viewport | Defines which part of the window is being rendered to |
| targetSize | Size of the window |
Reimplemented from tgui::BackendRenderTarget.
|
overrideprotectedvirtual |
Called from addClippingLayer and removeClippingLayer to apply the clipping.
| clipRect | View rectangle to apply |
| clipViewport | Viewport to apply |
Both rectangles may be empty when nothing that will be drawn is going to be visible.
Implements tgui::BackendRenderTarget.