tests: Add VkRenderpassObj to render framework
authorTony Barbour <tony@LunarG.com>
Tue, 9 Aug 2016 21:42:33 +0000 (15:42 -0600)
committerTony Barbour <tony@LunarG.com>
Fri, 12 Aug 2016 15:38:13 +0000 (09:38 -0600)
Change-Id: I04e4ee692180597cf9aae8443bb75205ebf092b9

tests/vkrenderframework.cpp
tests/vkrenderframework.h

index c3336f5..cd775f4 100644 (file)
@@ -585,6 +585,37 @@ void VkDescriptorSetObj::CreateVKDescriptorSet(
     }
 }
 
+VkRenderpassObj::VkRenderpassObj(VkDeviceObj *dev) {
+    // Create a renderPass with a single color attachment
+    VkAttachmentReference attach = {};
+    attach.layout = VK_IMAGE_LAYOUT_GENERAL;
+
+    VkSubpassDescription subpass = {};
+    subpass.pColorAttachments = &attach;
+    subpass.colorAttachmentCount = 1;
+
+    VkRenderPassCreateInfo rpci = {};
+    rpci.subpassCount = 1;
+    rpci.pSubpasses = &subpass;
+    rpci.attachmentCount = 1;
+
+    VkAttachmentDescription attach_desc = {};
+    attach_desc.format = VK_FORMAT_B8G8R8A8_UNORM;
+    attach_desc.samples = VK_SAMPLE_COUNT_1_BIT;
+    attach_desc.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+    attach_desc.finalLayout = VK_IMAGE_LAYOUT_GENERAL;
+
+    rpci.pAttachments = &attach_desc;
+    rpci.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+
+    device = dev->device();
+    vkCreateRenderPass(device, &rpci, NULL, &m_renderpass);
+}
+
+VkRenderpassObj::~VkRenderpassObj() {
+    vkDestroyRenderPass(device, m_renderpass, NULL);
+}
+
 VkImageObj::VkImageObj(VkDeviceObj *dev) {
     m_device = dev;
     m_descriptorImageInfo.imageView = VK_NULL_HANDLE;
index 3bd9a9a..15d4b53 100644 (file)
@@ -267,6 +267,17 @@ class VkIndexBufferObj : public VkConstantBufferObj {
     VkIndexType m_indexType;
 };
 
+class VkRenderpassObj {
+  public:
+    VkRenderpassObj(VkDeviceObj *device);
+    ~VkRenderpassObj();
+    VkRenderPass handle() {return m_renderpass;}
+
+  protected:
+    VkRenderPass m_renderpass;
+    VkDevice device;
+};
+
 class VkImageObj : public vk_testing::Image {
   public:
     VkImageObj(VkDeviceObj *dev);