blob: 9a6f59e8b6d24c3e466f29030d7e030a67d0366d [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"
32
33
Tony Barbour01999182015-04-09 12:58:51 -060034class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060035{
36public:
Tony Barbour8205d902015-04-16 15:59:00 -060037 VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060038
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060039 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060040 void get_device_queue();
41
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060042 uint32_t id;
43 VkPhysicalDeviceProperties props;
Tony Barbour8205d902015-04-16 15:59:00 -060044 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060045
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060046 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060047};
48
Tony Barbour01999182015-04-09 12:58:51 -060049class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050{
51public:
52 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -060053 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060054 void EmitAddMemoryRefs(VkQueue queue);
55 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbour8205d902015-04-16 15:59:00 -060056 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060057
58protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060059 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060060
61};
62
Tony Barbour01999182015-04-09 12:58:51 -060063class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060064{
65public:
Tony Barbour01999182015-04-09 12:58:51 -060066 VkDepthStencilObj();
67 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060068 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060069 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060070
71protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060072 VkDeviceObj *m_device;
73 bool m_initialized;
74 vk_testing::DepthStencilView m_depthStencilView;
75 VkFormat m_depth_stencil_fmt;
76 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060077};
78
Tony Barbour01999182015-04-09 12:58:51 -060079class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060080{
81public:
Tony Barbour01999182015-04-09 12:58:51 -060082 VkRenderFramework();
83 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060084
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060085 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060086 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060087 VkRenderPass renderPass() {return m_renderPass;}
88 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060089 void InitViewport(float width, float height);
90 void InitViewport();
91 void InitRenderTarget();
92 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060093 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
94 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060095 void InitFramework();
96 void ShutdownFramework();
97 void InitState();
98
99
100protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600101 VkApplicationInfo app_info;
102 VkInstance inst;
103 VkPhysicalDevice objs[16];
104 uint32_t gpu_count;
105 VkDeviceObj *m_device;
106 VkCmdBuffer m_cmdBuffer;
107 VkRenderPass m_renderPass;
108 VkFramebuffer m_framebuffer;
109 VkDynamicRsState m_stateRaster;
110 VkDynamicCbState m_colorBlend;
111 VkDynamicVpState m_stateViewport;
112 VkDynamicDsState m_stateDepthStencil;
113 vector<VkImageObj*> m_renderTargets;
114 float m_width, m_height;
115 VkFormat m_render_target_fmt;
116 VkFormat m_depth_stencil_fmt;
117 VkColorAttachmentBindInfo m_colorBindings[8];
118 VkClearColor m_clear_color;
119 float m_depth_clear_color;
120 uint32_t m_stencil_clear_color;
121 VkDepthStencilObj *m_depthStencil;
122 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600123
124 /*
125 * SetUp and TearDown are called by the Google Test framework
126 * to initialize a test framework based on this class.
127 */
128 virtual void SetUp() {
129 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
130 this->app_info.pNext = NULL;
131 this->app_info.pAppName = "base";
132 this->app_info.appVersion = 1;
133 this->app_info.pEngineName = "unittest";
134 this->app_info.engineVersion = 1;
135 this->app_info.apiVersion = VK_API_VERSION;
136
137 InitFramework();
138 }
139
140 virtual void TearDown() {
141 ShutdownFramework();
142 }
143};
144
Tony Barbour01999182015-04-09 12:58:51 -0600145class VkDescriptorSetObj;
146class VkIndexBufferObj;
147class VkConstantBufferObj;
148class VkPipelineObj;
149class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600150
Tony Barbour01999182015-04-09 12:58:51 -0600151class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600152{
153public:
Tony Barbour01999182015-04-09 12:58:51 -0600154 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600155 VkCmdBuffer GetBufferHandle();
156 VkResult BeginCommandBuffer();
157 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
158 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
159 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600160 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600161 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600162 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600163 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600164 void PrepareAttachments();
165 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600166 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600167 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600168 void BindPipeline(VkPipelineObj &pipeline);
169 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600170 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600171 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600172 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
173 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
174 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600175 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
176 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
177 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600178 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600179
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600180 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181
182protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600183 VkDeviceObj *m_device;
184 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600185};
186
Tony Barbour01999182015-04-09 12:58:51 -0600187class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600188{
189public:
Tony Barbour01999182015-04-09 12:58:51 -0600190 VkConstantBufferObj(VkDeviceObj *device);
191 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
192 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600193 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600194 VkFlags outputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600195 VK_MEMORY_OUTPUT_CPU_WRITE_BIT |
196 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
197 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
198 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600199 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600200 VkFlags inputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600201 VK_MEMORY_INPUT_CPU_READ_BIT |
202 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
203 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
204 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
205 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
206 VK_MEMORY_INPUT_SHADER_READ_BIT |
207 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
208 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600209 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600210
Tony Barbour8205d902015-04-16 15:59:00 -0600211 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600212
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600213 VkBufferViewAttachInfo m_bufferViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600214
215protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600216 VkDeviceObj *m_device;
217 vk_testing::BufferView m_bufferView;
218 int m_numVertices;
219 int m_stride;
220 VkCommandBufferObj *m_commandBuffer;
221 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600222};
223
Tony Barbour01999182015-04-09 12:58:51 -0600224class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600225{
226public:
Tony Barbour01999182015-04-09 12:58:51 -0600227 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600228 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600229 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600230 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600231
232protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600233 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600234};
235
Tony Barbour01999182015-04-09 12:58:51 -0600236class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600237{
238public:
Tony Barbour01999182015-04-09 12:58:51 -0600239 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600240 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600241
242public:
243 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600244 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600245 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
246 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600247
248 // void clear( CommandBuffer*, uint32_t[4] );
249
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600250 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600251 {
252 m_imageInfo.layout = layout;
253 }
254
Tony Barbour8205d902015-04-16 15:59:00 -0600255 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600256 {
Tony Barbour8205d902015-04-16 15:59:00 -0600257 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600258 return mems.empty() ? VK_NULL_HANDLE : mems[0];
259 }
260
Tony Barbour01999182015-04-09 12:58:51 -0600261 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600262 VkImageAspect aspect,
263 VkFlags output_mask,
264 VkFlags input_mask,
265 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600266
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600267 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600268
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600269 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600270 {
271 return obj();
272 }
273
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600274 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600275 {
276 if (!m_targetView.initialized())
277 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600278 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600279 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
280 VK_NULL_HANDLE,
281 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600282 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600283 0,
284 0,
285 1
286 };
287 m_targetView.init(*m_device, createView);
288 }
289 return m_targetView.obj();
290 }
291
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600292 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
293 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600294
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600295 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600296 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600297 return ( VkImageLayout )m_imageInfo.layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600298 }
299 uint32_t width() const
300 {
301 return extent().width;
302 }
303 uint32_t height() const
304 {
305 return extent().height;
306 }
Tony Barbour01999182015-04-09 12:58:51 -0600307 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600308 {
309 return m_device;
310 }
311
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600312 VkResult MapMemory(void** ptr);
313 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600314
315protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600316 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600317
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600318 vk_testing::ColorAttachmentView m_targetView;
319 VkImageViewAttachInfo m_imageInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600320};
321
Tony Barbour01999182015-04-09 12:58:51 -0600322class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600323{
324public:
Tony Barbour01999182015-04-09 12:58:51 -0600325 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600326 VkImageViewAttachInfo m_textureViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600327
328
329protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600330 VkDeviceObj *m_device;
331 vk_testing::ImageView m_textureView;
332 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600333};
334
Tony Barbour01999182015-04-09 12:58:51 -0600335class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600336{
337public:
Tony Barbour01999182015-04-09 12:58:51 -0600338 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600339
340protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600341 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600342
343};
344
Tony Barbour01999182015-04-09 12:58:51 -0600345class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600346{
347public:
Tony Barbour01999182015-04-09 12:58:51 -0600348 VkDescriptorSetObj(VkDeviceObj *device);
349 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600350
351 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600352 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600353 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
354 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600355
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600356 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500357 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600358
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600359 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600360
361protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600362 VkDeviceObj *m_device;
363 vector<VkDescriptorTypeCount> m_type_counts;
364 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600365
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600366 vector<VkUpdateBuffers> m_updateBuffers;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600368 vector<VkSamplerImageViewInfo> m_samplerTextureInfo;
369 vector<VkUpdateSamplerTextures> m_updateSamplerTextures;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370
371 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500372 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600373 vk_testing::DescriptorSet *m_set;
374};
375
376
Tony Barbour01999182015-04-09 12:58:51 -0600377class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600378{
379public:
Tony Barbour8205d902015-04-16 15:59:00 -0600380 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600381 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600382
383protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600384 VkPipelineShaderStageCreateInfo stage_info;
385 VkShaderStage m_stage;
386 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600387
388};
389
Tony Barbour01999182015-04-09 12:58:51 -0600390class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600391{
392public:
Tony Barbour01999182015-04-09 12:58:51 -0600393 VkPipelineObj(VkDeviceObj *device);
394 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600395 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
396 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600397 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600398 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
399 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Tony Barbour01999182015-04-09 12:58:51 -0600400 void CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600401
402protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600403 VkPipelineVertexInputCreateInfo m_vi_state;
404 VkPipelineIaStateCreateInfo m_ia_state;
405 VkPipelineRsStateCreateInfo m_rs_state;
406 VkPipelineCbStateCreateInfo m_cb_state;
407 VkPipelineDsStateCreateInfo m_ds_state;
408 VkPipelineMsStateCreateInfo m_ms_state;
409 VkDeviceObj *m_device;
410 vector<VkShaderObj*> m_shaderObjs;
411 vector<VkConstantBufferObj*> m_vertexBufferObjs;
412 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600413 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600414 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600415
416};
417
418#endif // VKRENDERFRAMEWORK_H