mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
vulkan: flush batched draws before clear(). minor code cleanup.
This commit is contained in:
@@ -115,6 +115,11 @@ love::graphics::Buffer *Graphics::newBuffer(const love::graphics::Buffer::Settin
|
|||||||
|
|
||||||
void Graphics::clear(OptionalColorD color, OptionalInt stencil, OptionalDouble depth)
|
void Graphics::clear(OptionalColorD color, OptionalInt stencil, OptionalDouble depth)
|
||||||
{
|
{
|
||||||
|
if (!color.hasValue && !stencil.hasValue && !depth.hasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
flushBatchedDraws();
|
||||||
|
|
||||||
if (!renderPassState.active)
|
if (!renderPassState.active)
|
||||||
startRenderPass();
|
startRenderPass();
|
||||||
|
|
||||||
@@ -163,6 +168,11 @@ void Graphics::clear(OptionalColorD color, OptionalInt stencil, OptionalDouble d
|
|||||||
|
|
||||||
void Graphics::clear(const std::vector<OptionalColorD> &colors, OptionalInt stencil, OptionalDouble depth)
|
void Graphics::clear(const std::vector<OptionalColorD> &colors, OptionalInt stencil, OptionalDouble depth)
|
||||||
{
|
{
|
||||||
|
if (colors.empty() && !stencil.hasValue && !depth.hasValue)
|
||||||
|
return;
|
||||||
|
|
||||||
|
flushBatchedDraws();
|
||||||
|
|
||||||
if (!renderPassState.active)
|
if (!renderPassState.active)
|
||||||
startRenderPass();
|
startRenderPass();
|
||||||
|
|
||||||
@@ -188,12 +198,12 @@ void Graphics::clear(const std::vector<OptionalColorD> &colors, OptionalInt sten
|
|||||||
|
|
||||||
if (stencil.hasValue)
|
if (stencil.hasValue)
|
||||||
{
|
{
|
||||||
depthStencilAttachment.aspectMask = VK_IMAGE_ASPECT_STENCIL_BIT;
|
depthStencilAttachment.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
depthStencilAttachment.clearValue.depthStencil.stencil = static_cast<uint32_t>(stencil.value);
|
depthStencilAttachment.clearValue.depthStencil.stencil = static_cast<uint32_t>(stencil.value);
|
||||||
}
|
}
|
||||||
if (depth.hasValue)
|
if (depth.hasValue)
|
||||||
{
|
{
|
||||||
depthStencilAttachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
depthStencilAttachment.aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
depthStencilAttachment.clearValue.depthStencil.depth = static_cast<float>(depth.value);
|
depthStencilAttachment.clearValue.depthStencil.depth = static_cast<float>(depth.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1500,7 +1510,7 @@ QueueFamilyIndices Graphics::findQueueFamilies(VkPhysicalDevice device)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &queueFamily : queueFamilies)
|
for (const auto &queueFamily : queueFamilies)
|
||||||
{
|
{
|
||||||
if (queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT && queueFamily.queueFlags & VK_QUEUE_COMPUTE_BIT)
|
if ((queueFamily.queueFlags & VK_QUEUE_GRAPHICS_BIT) && (queueFamily.queueFlags & VK_QUEUE_COMPUTE_BIT))
|
||||||
indices.graphicsFamily = i;
|
indices.graphicsFamily = i;
|
||||||
|
|
||||||
VkBool32 presentSupport = false;
|
VkBool32 presentSupport = false;
|
||||||
@@ -1772,8 +1782,8 @@ void Graphics::createSwapChain()
|
|||||||
VkPresentModeKHR presentMode = chooseSwapPresentMode(swapChainSupport.presentModes);
|
VkPresentModeKHR presentMode = chooseSwapPresentMode(swapChainSupport.presentModes);
|
||||||
VkExtent2D extent = chooseSwapExtent(swapChainSupport.capabilities);
|
VkExtent2D extent = chooseSwapExtent(swapChainSupport.capabilities);
|
||||||
|
|
||||||
if (swapChainSupport.capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR ||
|
if ((swapChainSupport.capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR) ||
|
||||||
swapChainSupport.capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR)
|
(swapChainSupport.capabilities.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR))
|
||||||
{
|
{
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
width = extent.width;
|
width = extent.width;
|
||||||
|
|||||||
Reference in New Issue
Block a user