blob: 58f229f3730224ed2aa386abf35e59379d9f3e0a [file] [log] [blame]
Courtney Goeltzenleuchter9cc421e2015-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 Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060032#include "vk_debug_report_lunarg.h"
33#include "vk_debug_marker_lunarg.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060034
35
Tony Barbour01999182015-04-09 12:58:51 -060036class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060037{
38public:
Tony Barbour8205d902015-04-16 15:59:00 -060039 VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060040 VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<VkExtensionProperties> extension_names);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060041
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060042 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060043 void get_device_queue();
44
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060045 uint32_t id;
46 VkPhysicalDeviceProperties props;
Tony Barbour8205d902015-04-16 15:59:00 -060047 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060048
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060049 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050};
51
Tony Barbour01999182015-04-09 12:58:51 -060052class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060053{
54public:
55 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -060056 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060057 void EmitAddMemoryRefs(VkQueue queue);
58 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbour8205d902015-04-16 15:59:00 -060059 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060060
61protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060062 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060063
64};
65
Tony Barbour01999182015-04-09 12:58:51 -060066class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060067{
68public:
Tony Barbour01999182015-04-09 12:58:51 -060069 VkDepthStencilObj();
70 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060071 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060072 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060073
74protected:
Courtney Goeltzenleuchterec69b9c2015-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 Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060080};
81
Tony Barbour01999182015-04-09 12:58:51 -060082class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060083{
84public:
Tony Barbour01999182015-04-09 12:58:51 -060085 VkRenderFramework();
86 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060087
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060088 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060089 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060090 VkRenderPass renderPass() {return m_renderPass;}
91 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-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 Goeltzenleuchter382489d2015-04-10 08:34:15 -060096 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
97 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060098 void InitFramework();
Courtney Goeltzenleuchter1c7c65d2015-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 Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600103 void ShutdownFramework();
104 void InitState();
105
106
107protected:
Courtney Goeltzenleuchterec69b9c2015-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 Forbes23e6db62015-06-15 09:32:35 +1200126 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-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 Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600131 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
Courtney Goeltzenleuchter18e8a492015-06-08 15:16:04 -0600132 PFN_vkDbgDestroyMsgCallback m_dbgDestroyMsgCallback;
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600133 VkDbgMsgCallback m_globalMsgCallback;
134 VkDbgMsgCallback m_devMsgCallback;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600135
136 /*
137 * SetUp and TearDown are called by the Google Test framework
138 * to initialize a test framework based on this class.
139 */
140 virtual void SetUp() {
141 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
142 this->app_info.pNext = NULL;
143 this->app_info.pAppName = "base";
144 this->app_info.appVersion = 1;
145 this->app_info.pEngineName = "unittest";
146 this->app_info.engineVersion = 1;
147 this->app_info.apiVersion = VK_API_VERSION;
148
149 InitFramework();
150 }
151
152 virtual void TearDown() {
153 ShutdownFramework();
154 }
155};
156
Tony Barbour01999182015-04-09 12:58:51 -0600157class VkDescriptorSetObj;
158class VkIndexBufferObj;
159class VkConstantBufferObj;
160class VkPipelineObj;
161class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600162
Tony Barbour01999182015-04-09 12:58:51 -0600163class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600164{
165public:
Tony Barbour01999182015-04-09 12:58:51 -0600166 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600167 VkCmdBuffer GetBufferHandle();
168 VkResult BeginCommandBuffer();
169 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
170 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
171 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600172 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600173 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600174 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600175 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600176 void PrepareAttachments();
177 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600178 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600179 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600180 void BindPipeline(VkPipelineObj &pipeline);
181 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600182 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600183 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600184 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
185 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
186 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600187 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
188 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
189 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600190 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600191
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600192 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600193
194protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600195 VkDeviceObj *m_device;
196 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600197};
198
Tony Barbour01999182015-04-09 12:58:51 -0600199class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600200{
201public:
Tony Barbour01999182015-04-09 12:58:51 -0600202 VkConstantBufferObj(VkDeviceObj *device);
203 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
204 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600205 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600206 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600207 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600208 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
209 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
210 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600211 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600212 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600213 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600214 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
215 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
216 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
217 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
218 VK_MEMORY_INPUT_SHADER_READ_BIT |
219 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
220 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600221 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600222
Tony Barbour8205d902015-04-16 15:59:00 -0600223 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600224
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800225 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600226
227protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600228 VkDeviceObj *m_device;
229 vk_testing::BufferView m_bufferView;
230 int m_numVertices;
231 int m_stride;
232 VkCommandBufferObj *m_commandBuffer;
233 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600234};
235
Tony Barbour01999182015-04-09 12:58:51 -0600236class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600237{
238public:
Tony Barbour01999182015-04-09 12:58:51 -0600239 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600240 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600241 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600242 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600243
244protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600245 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600246};
247
Tony Barbour01999182015-04-09 12:58:51 -0600248class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600249{
250public:
Tony Barbour01999182015-04-09 12:58:51 -0600251 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600252 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600253
254public:
255 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600256 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600257 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
258 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600259
260 // void clear( CommandBuffer*, uint32_t[4] );
261
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600262 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600263 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800264 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600265 }
266
Tony Barbour8205d902015-04-16 15:59:00 -0600267 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600268 {
Tony Barbour8205d902015-04-16 15:59:00 -0600269 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600270 return mems.empty() ? VK_NULL_HANDLE : mems[0];
271 }
272
Tony Barbour01999182015-04-09 12:58:51 -0600273 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600274 VkImageAspect aspect,
275 VkFlags output_mask,
276 VkFlags input_mask,
277 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600278
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600279 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600280
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600281 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600282 {
283 return obj();
284 }
285
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600286 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600287 {
288 if (!m_targetView.initialized())
289 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600290 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600291 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
292 VK_NULL_HANDLE,
293 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600294 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600295 0,
296 0,
297 1
298 };
299 m_targetView.init(*m_device, createView);
300 }
301 return m_targetView.obj();
302 }
303
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600304 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
305 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600306
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600307 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600308 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800309 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600310 }
311 uint32_t width() const
312 {
313 return extent().width;
314 }
315 uint32_t height() const
316 {
317 return extent().height;
318 }
Tony Barbour01999182015-04-09 12:58:51 -0600319 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600320 {
321 return m_device;
322 }
323
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600324 VkResult MapMemory(void** ptr);
325 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600326
327protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600328 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600329
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600330 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800331 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600332};
333
Tony Barbour01999182015-04-09 12:58:51 -0600334class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600335{
336public:
Tony Barbour01999182015-04-09 12:58:51 -0600337 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600338
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800339 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600340
341protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600342 VkDeviceObj *m_device;
343 vk_testing::ImageView m_textureView;
344 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600345};
346
Tony Barbour01999182015-04-09 12:58:51 -0600347class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600348{
349public:
Tony Barbour01999182015-04-09 12:58:51 -0600350 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600351
352protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600353 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600354
355};
356
Tony Barbour01999182015-04-09 12:58:51 -0600357class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600358{
359public:
Tony Barbour01999182015-04-09 12:58:51 -0600360 VkDescriptorSetObj(VkDeviceObj *device);
361 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600362
363 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600364 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600365 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
366 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600368 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500369 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600371 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600372
373protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600374 VkDeviceObj *m_device;
375 vector<VkDescriptorTypeCount> m_type_counts;
376 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600377
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800378 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
379 vector<VkWriteDescriptorSet> m_writes;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600380
381 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500382 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600383 vk_testing::DescriptorSet *m_set;
384};
385
386
Tony Barbour01999182015-04-09 12:58:51 -0600387class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600388{
389public:
Tony Barbour8205d902015-04-16 15:59:00 -0600390 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600391 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600392
393protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600394 VkPipelineShaderStageCreateInfo stage_info;
395 VkShaderStage m_stage;
396 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600397
398};
399
Tony Barbour01999182015-04-09 12:58:51 -0600400class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600401{
402public:
Tony Barbour01999182015-04-09 12:58:51 -0600403 VkPipelineObj(VkDeviceObj *device);
404 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600405 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
406 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600407 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600408 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
409 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Chris Forbesdc2188c2015-05-25 11:13:26 +1200410 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600411
412protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600413 VkPipelineVertexInputCreateInfo m_vi_state;
414 VkPipelineIaStateCreateInfo m_ia_state;
415 VkPipelineRsStateCreateInfo m_rs_state;
416 VkPipelineCbStateCreateInfo m_cb_state;
417 VkPipelineDsStateCreateInfo m_ds_state;
Tony Barbour5e245132015-05-15 09:37:57 -0600418 VkPipelineVpStateCreateInfo m_vp_state;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600419 VkPipelineMsStateCreateInfo m_ms_state;
420 VkDeviceObj *m_device;
421 vector<VkShaderObj*> m_shaderObjs;
422 vector<VkConstantBufferObj*> m_vertexBufferObjs;
423 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600424 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600425 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600426
427};
428
429#endif // VKRENDERFRAMEWORK_H