From 321bb0d9c12408101a4ead69075fbab05f104768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 4 Feb 2021 18:20:12 +0100 Subject: [PATCH] Vk: use a compute pipeline for Pipeline move/wrap tests. So much shorter. --- src/Magnum/Vk/Test/PipelineVkTest.cpp | 66 ++++----------------------- 1 file changed, 9 insertions(+), 57 deletions(-) diff --git a/src/Magnum/Vk/Test/PipelineVkTest.cpp b/src/Magnum/Vk/Test/PipelineVkTest.cpp index 4e7226913..2bc5f0534 100644 --- a/src/Magnum/Vk/Test/PipelineVkTest.cpp +++ b/src/Magnum/Vk/Test/PipelineVkTest.cpp @@ -271,42 +271,18 @@ void PipelineVkTest::constructCompute() { } void PipelineVkTest::constructMove() { - RenderPass renderPass{device(), RenderPassCreateInfo{} - .setAttachments({ - AttachmentDescription{PixelFormat::RGBA8Unorm, - AttachmentLoadOperation::Clear, - AttachmentStoreOperation::Store, - ImageLayout::Undefined, - ImageLayout::ColorAttachment} - }) - .addSubpass(SubpassDescription{}.setColorAttachments({ - AttachmentReference{0, ImageLayout::ColorAttachment} - })) - }; - - /* Not sure if this is really needed, but the shader needs those inputs so - playing it safe */ - MeshLayout meshLayout{MeshPrimitive::Triangles}; - meshLayout - .addBinding(0, 2*4*4) - .addAttribute(0, 0, Vk::VertexFormat::Vector4, 0) - .addAttribute(1, 0, Vk::VertexFormat::Vector4, 4*4); - PipelineLayout pipelineLayout{device(), PipelineLayoutCreateInfo{}}; Shader shader{device(), ShaderCreateInfo{ - Utility::Directory::read(Utility::Directory::join(VK_TEST_DIR, "triangle-shaders.spv")) + Utility::Directory::read(Utility::Directory::join(VK_TEST_DIR, "compute-noop.spv")) }}; ShaderSet shaderSet; - shaderSet - .addShader(ShaderStage::Vertex, shader, "ver"_s) - .addShader(ShaderStage::Fragment, shader, "fra"_s); + shaderSet.addShader(ShaderStage::Compute, shader, "main"_s); - Pipeline a{device(), RasterizationPipelineCreateInfo{ - shaderSet, meshLayout, pipelineLayout, renderPass, 0, 1} - .setViewport({{}, {200, 200}}) - }; + Pipeline a{device(), ComputePipelineCreateInfo{ + shaderSet, pipelineLayout + }}; VkPipeline handle = a.handle(); Pipeline b = std::move(a); @@ -326,42 +302,18 @@ void PipelineVkTest::constructMove() { } void PipelineVkTest::wrap() { - RenderPass renderPass{device(), RenderPassCreateInfo{} - .setAttachments({ - AttachmentDescription{PixelFormat::RGBA8Unorm, - AttachmentLoadOperation::Clear, - AttachmentStoreOperation::Store, - ImageLayout::Undefined, - ImageLayout::ColorAttachment} - }) - .addSubpass(SubpassDescription{}.setColorAttachments({ - AttachmentReference{0, ImageLayout::ColorAttachment} - })) - }; - - /* Not sure if this is really needed, but the shader needs those inputs so - playing it safe */ - MeshLayout meshLayout{MeshPrimitive::Triangles}; - meshLayout - .addBinding(0, 2*4*4) - .addAttribute(0, 0, Vk::VertexFormat::Vector4, 0) - .addAttribute(1, 0, Vk::VertexFormat::Vector4, 4*4); - PipelineLayout pipelineLayout{device(), PipelineLayoutCreateInfo{}}; Shader shader{device(), ShaderCreateInfo{ - Utility::Directory::read(Utility::Directory::join(VK_TEST_DIR, "triangle-shaders.spv")) + Utility::Directory::read(Utility::Directory::join(VK_TEST_DIR, "compute-noop.spv")) }}; ShaderSet shaderSet; - shaderSet - .addShader(ShaderStage::Vertex, shader, "ver"_s) - .addShader(ShaderStage::Fragment, shader, "fra"_s); + shaderSet.addShader(ShaderStage::Compute, shader, "main"_s); VkPipeline pipeline{}; - CORRADE_COMPARE(Result(device()->CreateGraphicsPipelines(device(), {}, 1, - RasterizationPipelineCreateInfo{shaderSet, meshLayout, pipelineLayout, renderPass, 0, 1} - .setViewport({{}, {200, 200}}), + CORRADE_COMPARE(Result(device()->CreateComputePipelines(device(), {}, 1, + ComputePipelineCreateInfo{shaderSet, pipelineLayout}, nullptr, &pipeline)), Result::Success); auto wrapped = Pipeline::wrap(device(), pipeline, HandleFlag::DestroyOnDestruction);