blob: e761001d1fc8e93e37f4e681dc4f02a4db30ed9a [file] [log] [blame]
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -06001/*
2 * Vulkan Tests
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 */
27
28#ifndef VKRENDERFRAMEWORK_H
29#define VKRENDERFRAMEWORK_H
30
31#include "vktestframework.h"
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060032#include "vk_debug_report_lunarg.h"
33#include "vk_debug_marker_lunarg.h"
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060034
35
Tony Barbour6918cd52015-04-09 12:58:51 -060036class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060037{
38public:
Tony Barbourd1c35722015-04-16 15:59:00 -060039 VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060040 VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<VkExtensionProperties> extension_names);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060041
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060042 VkDevice device() { return obj(); }
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060043 void get_device_queue();
44
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -060045 uint32_t id;
46 VkPhysicalDeviceProperties props;
Tony Barbourd1c35722015-04-16 15:59:00 -060047 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060048
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060049 VkQueue m_queue;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060050};
51
Tony Barbour6918cd52015-04-09 12:58:51 -060052class VkMemoryRefManager
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060053{
54public:
55 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbourd1c35722015-04-16 15:59:00 -060056 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060057 void EmitAddMemoryRefs(VkQueue queue);
58 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbourd1c35722015-04-16 15:59:00 -060059 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060060
61protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -060062 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060063
64};
65
Tony Barbour6918cd52015-04-09 12:58:51 -060066class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060067{
68public:
Tony Barbour6918cd52015-04-09 12:58:51 -060069 VkDepthStencilObj();
70 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060071 bool Initialized();
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060072 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060073
74protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -060075 VkDeviceObj *m_device;
76 bool m_initialized;
77 vk_testing::DepthStencilView m_depthStencilView;
78 VkFormat m_depth_stencil_fmt;
79 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060080};
81
Tony Barbour6918cd52015-04-09 12:58:51 -060082class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060083{
84public:
Tony Barbour6918cd52015-04-09 12:58:51 -060085 VkRenderFramework();
86 ~VkRenderFramework();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060087
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060088 VkDevice device() {return m_device->device();}
Tony Barbourd1c35722015-04-16 15:59:00 -060089 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060090 VkRenderPass renderPass() {return m_renderPass;}
91 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060092 void InitViewport(float width, float height);
93 void InitViewport();
94 void InitRenderTarget();
95 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -060096 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
97 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -060098 void InitFramework();
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -060099 void InitFramework(std::vector<const char *> instance_extension_names,
100 std::vector<const char *> device_extension_names,
101 PFN_vkDbgMsgCallback=NULL,
102 void *userData=NULL);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600103 void ShutdownFramework();
104 void InitState();
105
106
107protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600108 VkApplicationInfo app_info;
109 VkInstance inst;
110 VkPhysicalDevice objs[16];
111 uint32_t gpu_count;
112 VkDeviceObj *m_device;
113 VkCmdBuffer m_cmdBuffer;
114 VkRenderPass m_renderPass;
115 VkFramebuffer m_framebuffer;
116 VkDynamicRsState m_stateRaster;
117 VkDynamicCbState m_colorBlend;
118 VkDynamicVpState m_stateViewport;
119 VkDynamicDsState m_stateDepthStencil;
120 vector<VkImageObj*> m_renderTargets;
121 float m_width, m_height;
122 VkFormat m_render_target_fmt;
123 VkFormat m_depth_stencil_fmt;
124 VkColorAttachmentBindInfo m_colorBindings[8];
125 VkClearColor m_clear_color;
Chris Forbese182fe02015-06-15 09:32:35 +1200126 bool m_clear_via_load_op;
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600127 float m_depth_clear_color;
128 uint32_t m_stencil_clear_color;
129 VkDepthStencilObj *m_depthStencil;
130 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchterf579fa62015-06-10 17:39:03 -0600131 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
Courtney Goeltzenleuchterd971b612015-06-17 20:51:59 -0600132 VkDbgMsgCallback m_globalMsgCallback;
133 VkDbgMsgCallback m_devMsgCallback;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600134
135 /*
136 * SetUp and TearDown are called by the Google Test framework
137 * to initialize a test framework based on this class.
138 */
139 virtual void SetUp() {
140 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
141 this->app_info.pNext = NULL;
142 this->app_info.pAppName = "base";
143 this->app_info.appVersion = 1;
144 this->app_info.pEngineName = "unittest";
145 this->app_info.engineVersion = 1;
146 this->app_info.apiVersion = VK_API_VERSION;
147
148 InitFramework();
149 }
150
151 virtual void TearDown() {
152 ShutdownFramework();
153 }
154};
155
Tony Barbour6918cd52015-04-09 12:58:51 -0600156class VkDescriptorSetObj;
157class VkIndexBufferObj;
158class VkConstantBufferObj;
159class VkPipelineObj;
160class VkDescriptorSetObj;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600161
Tony Barbour6918cd52015-04-09 12:58:51 -0600162class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600163{
164public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600165 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600166 VkCmdBuffer GetBufferHandle();
167 VkResult BeginCommandBuffer();
168 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
169 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
170 VkResult EndCommandBuffer();
Tony Barbourd1c35722015-04-16 15:59:00 -0600171 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour6918cd52015-04-09 12:58:51 -0600172 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600173 void AddDepthStencil();
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600174 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600175 void PrepareAttachments();
176 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbourd1c35722015-04-16 15:59:00 -0600177 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600178 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour6918cd52015-04-09 12:58:51 -0600179 void BindPipeline(VkPipelineObj &pipeline);
180 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbourd1c35722015-04-16 15:59:00 -0600181 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour6918cd52015-04-09 12:58:51 -0600182 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600183 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
184 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
185 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600186 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
187 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
188 void QueueCommandBuffer();
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600189 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600190
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600191 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600192
193protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600194 VkDeviceObj *m_device;
195 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600196};
197
Tony Barbour6918cd52015-04-09 12:58:51 -0600198class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600199{
200public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600201 VkConstantBufferObj(VkDeviceObj *device);
202 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
203 ~VkConstantBufferObj();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600204 void BufferMemoryBarrier(
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600205 VkFlags outputMask =
Courtney Goeltzenleuchterf69f8a22015-04-29 17:16:21 -0600206 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600207 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
208 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
209 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterb9776ab2015-04-15 15:29:59 -0600210 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600211 VkFlags inputMask =
Courtney Goeltzenleuchterf69f8a22015-04-29 17:16:21 -0600212 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600213 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
214 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
215 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
216 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
217 VK_MEMORY_INPUT_SHADER_READ_BIT |
218 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
219 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterb9776ab2015-04-15 15:29:59 -0600220 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600221
Tony Barbourd1c35722015-04-16 15:59:00 -0600222 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600223
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800224 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600225
226protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600227 VkDeviceObj *m_device;
228 vk_testing::BufferView m_bufferView;
229 int m_numVertices;
230 int m_stride;
231 VkCommandBufferObj *m_commandBuffer;
232 vk_testing::Fence m_fence;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600233};
234
Tony Barbour6918cd52015-04-09 12:58:51 -0600235class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600236{
237public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600238 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600239 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbourd1c35722015-04-16 15:59:00 -0600240 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600241 VkIndexType GetIndexType();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600242
243protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600244 VkIndexType m_indexType;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600245};
246
Tony Barbour6918cd52015-04-09 12:58:51 -0600247class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600248{
249public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600250 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600251 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600252
253public:
254 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600255 VkFormat fmt, VkFlags usage,
Tony Barbour4c97d7a2015-04-22 15:10:33 -0600256 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
257 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600258
259 // void clear( CommandBuffer*, uint32_t[4] );
260
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600261 void layout( VkImageLayout layout )
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600262 {
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800263 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600264 }
265
Tony Barbourd1c35722015-04-16 15:59:00 -0600266 VkDeviceMemory memory() const
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600267 {
Tony Barbourd1c35722015-04-16 15:59:00 -0600268 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600269 return mems.empty() ? VK_NULL_HANDLE : mems[0];
270 }
271
Tony Barbour6918cd52015-04-09 12:58:51 -0600272 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600273 VkImageAspect aspect,
274 VkFlags output_mask,
275 VkFlags input_mask,
276 VkImageLayout image_layout);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600277
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600278 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600279
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600280 VkImage image() const
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600281 {
282 return obj();
283 }
284
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600285 VkColorAttachmentView targetView()
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600286 {
287 if (!m_targetView.initialized())
288 {
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600289 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600290 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
291 VK_NULL_HANDLE,
292 obj(),
Tony Barbourd1c35722015-04-16 15:59:00 -0600293 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600294 0,
295 0,
296 1
297 };
298 m_targetView.init(*m_device, createView);
299 }
300 return m_targetView.obj();
301 }
302
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600303 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
304 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600305
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600306 VkImageLayout layout() const
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600307 {
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800308 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600309 }
310 uint32_t width() const
311 {
312 return extent().width;
313 }
314 uint32_t height() const
315 {
316 return extent().height;
317 }
Tony Barbour6918cd52015-04-09 12:58:51 -0600318 VkDeviceObj* device() const
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600319 {
320 return m_device;
321 }
322
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600323 VkResult MapMemory(void** ptr);
324 VkResult UnmapMemory();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600325
326protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600327 VkDeviceObj *m_device;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600328
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600329 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800330 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600331};
332
Tony Barbour6918cd52015-04-09 12:58:51 -0600333class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600334{
335public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600336 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600337
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800338 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600339
340protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600341 VkDeviceObj *m_device;
342 vk_testing::ImageView m_textureView;
343 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600344};
345
Tony Barbour6918cd52015-04-09 12:58:51 -0600346class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600347{
348public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600349 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600350
351protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600352 VkDeviceObj *m_device;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600353
354};
355
Tony Barbour6918cd52015-04-09 12:58:51 -0600356class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600357{
358public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600359 VkDescriptorSetObj(VkDeviceObj *device);
360 ~VkDescriptorSetObj();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600361
362 int AppendDummy();
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600363 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour6918cd52015-04-09 12:58:51 -0600364 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
365 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600366
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600367 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski0fadf5f2015-04-17 14:11:39 -0500368 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600369
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600370 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600371
372protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600373 VkDeviceObj *m_device;
374 vector<VkDescriptorTypeCount> m_type_counts;
375 int m_nextSlot;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600376
Chia-I Wu9d00ed72015-05-25 16:27:55 +0800377 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
378 vector<VkWriteDescriptorSet> m_writes;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600379
380 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski0fadf5f2015-04-17 14:11:39 -0500381 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600382 vk_testing::DescriptorSet *m_set;
383};
384
385
Tony Barbour6918cd52015-04-09 12:58:51 -0600386class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600387{
388public:
Tony Barbourd1c35722015-04-16 15:59:00 -0600389 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600390 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600391
392protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600393 VkPipelineShaderStageCreateInfo stage_info;
394 VkShaderStage m_stage;
395 VkDeviceObj *m_device;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600396
397};
398
Tony Barbour6918cd52015-04-09 12:58:51 -0600399class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600400{
401public:
Tony Barbour6918cd52015-04-09 12:58:51 -0600402 VkPipelineObj(VkDeviceObj *device);
403 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600404 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
405 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour6918cd52015-04-09 12:58:51 -0600406 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600407 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
408 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Chris Forbes95292b12015-05-25 11:13:26 +1200409 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600410
411protected:
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600412 VkPipelineVertexInputCreateInfo m_vi_state;
413 VkPipelineIaStateCreateInfo m_ia_state;
414 VkPipelineRsStateCreateInfo m_rs_state;
415 VkPipelineCbStateCreateInfo m_cb_state;
416 VkPipelineDsStateCreateInfo m_ds_state;
Tony Barbourd81b8882015-05-15 09:37:57 -0600417 VkPipelineVpStateCreateInfo m_vp_state;
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600418 VkPipelineMsStateCreateInfo m_ms_state;
419 VkDeviceObj *m_device;
420 vector<VkShaderObj*> m_shaderObjs;
421 vector<VkConstantBufferObj*> m_vertexBufferObjs;
422 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchterfb4efc62015-04-10 08:34:15 -0600423 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterd6079ec2015-04-22 10:09:35 -0600424 int m_vertexBufferCount;
Courtney Goeltzenleuchterd8e229c2015-04-08 15:36:08 -0600425
426};
427
428#endif // VKRENDERFRAMEWORK_H