From 01fb4fd7933e053b9c6a13ee3b8833f608d35061 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 13 Sep 2019 16:38:40 +0100 Subject: [PATCH] Test overlay with negative viewport height from KHR_maintenance1 --- util/test/demos/vk/vk_overlay_test.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/util/test/demos/vk/vk_overlay_test.cpp b/util/test/demos/vk/vk_overlay_test.cpp index f6ef364d8..8a63e1340 100644 --- a/util/test/demos/vk/vk_overlay_test.cpp +++ b/util/test/demos/vk/vk_overlay_test.cpp @@ -75,15 +75,20 @@ void main() int main() { + optDevExts.push_back(VK_KHR_MAINTENANCE1_EXTENSION_NAME); + // initialise, create window, create context, etc if(!Init()) return 3; + bool KHR_maintenance1 = std::find(devExts.begin(), devExts.end(), + VK_KHR_MAINTENANCE1_EXTENSION_NAME) != devExts.end(); + VkPipelineLayout layout = createPipelineLayout(vkh::PipelineLayoutCreateInfo()); // note that the Y position values are inverted for vulkan 1.0 viewport convention, relative to // all other APIs - const DefaultA2V VBData[] = { + DefaultA2V VBData[] = { // this triangle occludes in depth {Vec3f(-0.5f, 0.5f, 0.0f), Vec4f(0.0f, 0.0f, 1.0f, 1.0f), Vec2f(0.0f, 0.0f)}, {Vec3f(-0.5f, 0.0f, 0.0f), Vec4f(0.0f, 0.0f, 1.0f, 1.0f), Vec2f(0.0f, 1.0f)}, @@ -142,6 +147,13 @@ void main() {Vec3f(0.025f, -0.7f, 0.5f), Vec4f(1.0f, 0.5f, 1.0f, 1.0f), Vec2f(1.0f, 0.0f)}, }; + // negate y if we're using negative viewport height + if(KHR_maintenance1) + { + for(DefaultA2V &v : VBData) + v.pos.y = -v.pos.y; + } + AllocatedBuffer vb(allocator, vkh::BufferCreateInfo(sizeof(VBData), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT), @@ -241,6 +253,14 @@ void main() v.y += 10.0f; v.width -= 20.0f; v.height -= 20.0f; + + // if we're using KHR_maintenance1, check that negative viewport height is handled + if(KHR_maintenance1) + { + v.y += v.height; + v.height = -v.height; + } + vkCmdSetViewport(cmd, 0, 1, &v); vkCmdSetScissor(cmd, 0, 1, &mainWindow->scissor); vkh::cmdBindVertexBuffers(cmd, 0, {vb.buffer}, {0});