|
@@ -358,15 +358,17 @@ void RenderInterface_VK::SetScissorRegion(int x, int y, int width, int height)
|
|
|
info_clear_color.depth = 1.0f;
|
|
info_clear_color.depth = 1.0f;
|
|
|
info_clear_color.stencil = 0;
|
|
info_clear_color.stencil = 0;
|
|
|
|
|
|
|
|
- VkImageSubresourceRange info_range{};
|
|
|
|
|
- info_range.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
|
- info_range.baseMipLevel = 0;
|
|
|
|
|
- info_range.baseArrayLayer = 0;
|
|
|
|
|
- info_range.levelCount = 1;
|
|
|
|
|
- info_range.layerCount = 1;
|
|
|
|
|
|
|
+ VkClearAttachment clear_attachment = {};
|
|
|
|
|
+ clear_attachment.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
|
+ clear_attachment.clearValue.depthStencil = info_clear_color;
|
|
|
|
|
+ clear_attachment.colorAttachment = 1;
|
|
|
|
|
|
|
|
- vkCmdClearDepthStencilImage(m_p_current_command_buffer, m_texture_depthstencil.m_p_vk_image,
|
|
|
|
|
- VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, &info_clear_color, 1, &info_range);
|
|
|
|
|
|
|
+ VkClearRect clear_rect = {};
|
|
|
|
|
+ clear_rect.layerCount = 1;
|
|
|
|
|
+ clear_rect.rect.extent.width = m_width;
|
|
|
|
|
+ clear_rect.rect.extent.height = m_height;
|
|
|
|
|
+
|
|
|
|
|
+ vkCmdClearAttachments(m_p_current_command_buffer, 1, &clear_attachment, 1, &clear_rect);
|
|
|
|
|
|
|
|
RenderGeometry(vertices, 4, indices, 6, 0, Rml::Vector2f(0.0f, 0.0f));
|
|
RenderGeometry(vertices, 4, indices, 6, 0, Rml::Vector2f(0.0f, 0.0f));
|
|
|
|
|
|
|
@@ -785,8 +787,18 @@ void RenderInterface_VK::SetViewport(int width, int height)
|
|
|
if (window_extent.width == 0 || window_extent.height == 0)
|
|
if (window_extent.width == 0 || window_extent.height == 0)
|
|
|
return;
|
|
return;
|
|
|
|
|
|
|
|
|
|
+#ifdef RMLUI_VK_DEBUG
|
|
|
|
|
+ Rml::Log::Message(Rml::Log::Type::LT_DEBUG, "Rml width: %d height: %d | Vulkan width: %d height: %d", m_width, m_height, window_extent.width,
|
|
|
|
|
+ window_extent.height);
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+ // we need to sync the data from Vulkan so we can't use native Rml's data about width and height so be careful otherwise we create framebuffer
|
|
|
|
|
+ // with Rml's width and height but they're different to what Vulkan determines for our window (e.g. device/swapchain)
|
|
|
|
|
+ m_width = window_extent.width;
|
|
|
|
|
+ m_height = window_extent.height;
|
|
|
|
|
+
|
|
|
Initialize_Swapchain(window_extent);
|
|
Initialize_Swapchain(window_extent);
|
|
|
- CreateResourcesDependentOnSize();
|
|
|
|
|
|
|
+ CreateResourcesDependentOnSize(window_extent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool RenderInterface_VK::IsSwapchainValid()
|
|
bool RenderInterface_VK::IsSwapchainValid()
|
|
@@ -1202,7 +1214,7 @@ void RenderInterface_VK::Initialize_Allocator() noexcept
|
|
|
|
|
|
|
|
VmaAllocatorCreateInfo info = {};
|
|
VmaAllocatorCreateInfo info = {};
|
|
|
|
|
|
|
|
- info.vulkanApiVersion = VK_API_VERSION_1_0;
|
|
|
|
|
|
|
+ info.vulkanApiVersion = RMLUI_VK_API_VERSION;
|
|
|
info.device = m_p_device;
|
|
info.device = m_p_device;
|
|
|
info.instance = m_p_instance;
|
|
info.instance = m_p_instance;
|
|
|
info.physicalDevice = m_p_physical_device;
|
|
info.physicalDevice = m_p_physical_device;
|
|
@@ -1573,7 +1585,7 @@ void RenderInterface_VK::Destroy_ReportDebugCallback() noexcept
|
|
|
|
|
|
|
|
uint32_t RenderInterface_VK::GetUserAPIVersion() const noexcept
|
|
uint32_t RenderInterface_VK::GetUserAPIVersion() const noexcept
|
|
|
{
|
|
{
|
|
|
- uint32_t result = VK_API_VERSION_1_0;
|
|
|
|
|
|
|
+ uint32_t result = RMLUI_VK_API_VERSION;
|
|
|
|
|
|
|
|
#if defined VK_VERSION_1_1
|
|
#if defined VK_VERSION_1_1
|
|
|
VkResult status = vkEnumerateInstanceVersion(&result);
|
|
VkResult status = vkEnumerateInstanceVersion(&result);
|
|
@@ -1585,7 +1597,7 @@ uint32_t RenderInterface_VK::GetUserAPIVersion() const noexcept
|
|
|
|
|
|
|
|
uint32_t RenderInterface_VK::GetRequiredVersionAndValidateMachine() noexcept
|
|
uint32_t RenderInterface_VK::GetRequiredVersionAndValidateMachine() noexcept
|
|
|
{
|
|
{
|
|
|
- constexpr uint32_t kRequiredVersion = VK_API_VERSION_1_0;
|
|
|
|
|
|
|
+ constexpr uint32_t kRequiredVersion = RMLUI_VK_API_VERSION;
|
|
|
const uint32_t user_version = GetUserAPIVersion();
|
|
const uint32_t user_version = GetUserAPIVersion();
|
|
|
|
|
|
|
|
RMLUI_VK_ASSERTMSG(kRequiredVersion <= user_version, "Your machine doesn't support Vulkan");
|
|
RMLUI_VK_ASSERTMSG(kRequiredVersion <= user_version, "Your machine doesn't support Vulkan");
|
|
@@ -2177,7 +2189,7 @@ void RenderInterface_VK::Create_Pipelines() noexcept
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void RenderInterface_VK::CreateSwapchainFrameBuffers() noexcept
|
|
|
|
|
|
|
+void RenderInterface_VK::CreateSwapchainFrameBuffers(const VkExtent2D& real_render_image_size) noexcept
|
|
|
{
|
|
{
|
|
|
RMLUI_VK_ASSERTMSG(m_p_render_pass, "you must create a VkRenderPass before calling this method");
|
|
RMLUI_VK_ASSERTMSG(m_p_render_pass, "you must create a VkRenderPass before calling this method");
|
|
|
RMLUI_VK_ASSERTMSG(m_p_device, "you must have a valid VkDevice here");
|
|
RMLUI_VK_ASSERTMSG(m_p_device, "you must have a valid VkDevice here");
|
|
@@ -2196,8 +2208,8 @@ void RenderInterface_VK::CreateSwapchainFrameBuffers() noexcept
|
|
|
info.renderPass = m_p_render_pass;
|
|
info.renderPass = m_p_render_pass;
|
|
|
info.attachmentCount = static_cast<uint32_t>(attachments.size());
|
|
info.attachmentCount = static_cast<uint32_t>(attachments.size());
|
|
|
info.pAttachments = attachments.data();
|
|
info.pAttachments = attachments.data();
|
|
|
- info.width = m_width;
|
|
|
|
|
- info.height = m_height;
|
|
|
|
|
|
|
+ info.width = real_render_image_size.width;
|
|
|
|
|
+ info.height = real_render_image_size.height;
|
|
|
info.layers = 1;
|
|
info.layers = 1;
|
|
|
|
|
|
|
|
int index = 0;
|
|
int index = 0;
|
|
@@ -2285,7 +2297,7 @@ void RenderInterface_VK::Create_DepthStencilImage() noexcept
|
|
|
info.arrayLayers = 1;
|
|
info.arrayLayers = 1;
|
|
|
info.samples = VK_SAMPLE_COUNT_1_BIT;
|
|
info.samples = VK_SAMPLE_COUNT_1_BIT;
|
|
|
info.tiling = VK_IMAGE_TILING_OPTIMAL;
|
|
info.tiling = VK_IMAGE_TILING_OPTIMAL;
|
|
|
- info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
|
|
|
|
|
|
+ info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
|
|
|
|
|
|
VmaAllocation p_allocation = {};
|
|
VmaAllocation p_allocation = {};
|
|
|
VkImage p_image = {};
|
|
VkImage p_image = {};
|
|
@@ -2337,17 +2349,17 @@ void RenderInterface_VK::Create_DepthStencilImageViews() noexcept
|
|
|
m_texture_depthstencil.m_p_vk_image_view = p_image_view;
|
|
m_texture_depthstencil.m_p_vk_image_view = p_image_view;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-void RenderInterface_VK::CreateResourcesDependentOnSize() noexcept
|
|
|
|
|
|
|
+void RenderInterface_VK::CreateResourcesDependentOnSize(const VkExtent2D& real_render_image_size) noexcept
|
|
|
{
|
|
{
|
|
|
- m_viewport.height = static_cast<float>(m_height);
|
|
|
|
|
- m_viewport.width = static_cast<float>(m_width);
|
|
|
|
|
|
|
+ m_viewport.height = static_cast<float>(real_render_image_size.height);
|
|
|
|
|
+ m_viewport.width = static_cast<float>(real_render_image_size.width);
|
|
|
m_viewport.minDepth = 0.0f;
|
|
m_viewport.minDepth = 0.0f;
|
|
|
m_viewport.maxDepth = 1.0f;
|
|
m_viewport.maxDepth = 1.0f;
|
|
|
m_viewport.x = 0.0f;
|
|
m_viewport.x = 0.0f;
|
|
|
m_viewport.y = 0.0f;
|
|
m_viewport.y = 0.0f;
|
|
|
|
|
|
|
|
- m_scissor.extent.width = m_width;
|
|
|
|
|
- m_scissor.extent.height = m_height;
|
|
|
|
|
|
|
+ m_scissor.extent.width = real_render_image_size.width;
|
|
|
|
|
+ m_scissor.extent.height = real_render_image_size.height;
|
|
|
m_scissor.offset.x = 0;
|
|
m_scissor.offset.x = 0;
|
|
|
m_scissor.offset.y = 0;
|
|
m_scissor.offset.y = 0;
|
|
|
|
|
|
|
@@ -2365,7 +2377,7 @@ void RenderInterface_VK::CreateResourcesDependentOnSize() noexcept
|
|
|
SetTransform(nullptr);
|
|
SetTransform(nullptr);
|
|
|
|
|
|
|
|
CreateRenderPass();
|
|
CreateRenderPass();
|
|
|
- CreateSwapchainFrameBuffers();
|
|
|
|
|
|
|
+ CreateSwapchainFrameBuffers(real_render_image_size);
|
|
|
Create_Pipelines();
|
|
Create_Pipelines();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -2539,7 +2551,7 @@ void RenderInterface_VK::CreateRenderPass() noexcept
|
|
|
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
|
attachments[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
|
|
attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
|
attachments[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
|
|
attachments[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
attachments[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
|
- attachments[1].finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
|
|
|
|
|
|
+ attachments[1].finalLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
|
|
|
|
|
|
RMLUI_VK_ASSERTMSG(attachments[1].format != VkFormat::VK_FORMAT_UNDEFINED,
|
|
RMLUI_VK_ASSERTMSG(attachments[1].format != VkFormat::VK_FORMAT_UNDEFINED,
|
|
|
"can't obtain depth format, your device doesn't support depth/stencil operations");
|
|
"can't obtain depth format, your device doesn't support depth/stencil operations");
|
|
@@ -2552,7 +2564,7 @@ void RenderInterface_VK::CreateRenderPass() noexcept
|
|
|
|
|
|
|
|
// depth stencil
|
|
// depth stencil
|
|
|
color_references[1].attachment = 1;
|
|
color_references[1].attachment = 1;
|
|
|
- color_references[1].layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
|
|
|
|
|
|
|
+ color_references[1].layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
|
|
|
|
|
|
VkSubpassDescription subpass = {};
|
|
VkSubpassDescription subpass = {};
|
|
|
|
|
|