Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- tests/spec/ext_memory_object/vk_common.c | 58 ++++++++++++++++++++++++++++++++ tests/spec/ext_memory_object/vk_common.h | 17 ++++++++++ 2 files changed, 75 insertions(+)
diff --git a/tests/spec/ext_memory_object/vk_common.c b/tests/spec/ext_memory_object/vk_common.c index 6e6458ce4..ba12bff07 100644 --- a/tests/spec/ext_memory_object/vk_common.c +++ b/tests/spec/ext_memory_object/vk_common.c @@ -595,3 +595,61 @@ vk_get_proc_addr_for_mem_fd(VkDevice dev) return get_fd; } + +void +vk_create_simple_pipeline(struct vk_core *core, + const struct vk_image_layout *layout, + const uint32_t *vs, unsigned vs_size, + const uint32_t *fs, unsigned fs_size, + struct vk_simple_pipeline *pipeline) +{ + pipeline->render_pass = vk_create_render_pass( + core->dev, layout->src_format, layout->num_samples, + layout->src_tiling == VK_IMAGE_TILING_OPTIMAL ? + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : + VK_IMAGE_LAYOUT_GENERAL, + layout->src_tiling == VK_IMAGE_TILING_OPTIMAL ? + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL : + VK_IMAGE_LAYOUT_GENERAL); + if (pipeline->render_pass == VK_NULL_HANDLE) + goto fail; + + pipeline->vs = vk_add_shader(core->dev, vs, vs_size); + if (pipeline->vs == VK_NULL_HANDLE) + goto fail; + + pipeline->fs = vk_add_shader(core->dev, fs, fs_size); + if (pipeline->fs == VK_NULL_HANDLE) + goto fail; + + pipeline->pipeline = vk_create_pipeline( + core, layout->w, layout->h, 1, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, + 8, VK_FORMAT_R32G32_SFLOAT, + pipeline->render_pass, + pipeline->fs, pipeline->vs); + if (pipeline->pipeline == VK_NULL_HANDLE) + goto fail; + + return; + +fail: + vk_destroy_simple_pipeline(core->dev, pipeline); + memset(pipeline, 0, sizeof(*pipeline)); +} + +void +vk_destroy_simple_pipeline(VkDevice dev, struct vk_simple_pipeline *pipeline) +{ + if (pipeline->pipeline != VK_NULL_HANDLE) + vkDestroyPipeline(dev, pipeline->pipeline, NULL); + + if (pipeline->vs != VK_NULL_HANDLE) + vkDestroyShaderModule(dev, pipeline->vs, NULL); + + if (pipeline->fs != VK_NULL_HANDLE) + vkDestroyShaderModule(dev, pipeline->fs, NULL); + + if (pipeline->render_pass != VK_NULL_HANDLE) + vkDestroyRenderPass(dev, pipeline->render_pass, NULL); +} diff --git a/tests/spec/ext_memory_object/vk_common.h b/tests/spec/ext_memory_object/vk_common.h index db4bbf20f..0efccf37a 100644 --- a/tests/spec/ext_memory_object/vk_common.h +++ b/tests/spec/ext_memory_object/vk_common.h @@ -39,6 +39,13 @@ struct vk_core { VkQueue queue; }; +struct vk_simple_pipeline { + VkRenderPass render_pass; + VkPipeline pipeline; + VkShaderModule vs; + VkShaderModule fs; +}; + struct vk_vertex_buffer { VkBuffer buf; VkDeviceMemory mem; @@ -153,4 +160,14 @@ vk_get_proc_addr_for_image_mem_req(VkDevice dev); PFN_vkGetMemoryFdKHR vk_get_proc_addr_for_mem_fd(VkDevice dev); +void +vk_create_simple_pipeline(struct vk_core *core, + const struct vk_image_layout *layout, + const uint32_t *vs, unsigned vs_size, + const uint32_t *fs, unsigned fs_size, + struct vk_simple_pipeline *pipeline); + +void +vk_destroy_simple_pipeline(VkDevice dev, struct vk_simple_pipeline *pipeline); + #endif -- 2.14.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit