blob: c84244f0bf67eecca032b36bff3231e60693a259 [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();
Tony Barbour950ebc02015-04-23 12:55:36 -060096 void InitFramework(const std::vector<const char *> &layers);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060097 void ShutdownFramework();
98 void InitState();
99
100
101protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600102 VkApplicationInfo app_info;
103 VkInstance inst;
104 VkPhysicalDevice objs[16];
105 uint32_t gpu_count;
106 VkDeviceObj *m_device;
107 VkCmdBuffer m_cmdBuffer;
108 VkRenderPass m_renderPass;
109 VkFramebuffer m_framebuffer;
110 VkDynamicRsState m_stateRaster;
111 VkDynamicCbState m_colorBlend;
112 VkDynamicVpState m_stateViewport;
113 VkDynamicDsState m_stateDepthStencil;
114 vector<VkImageObj*> m_renderTargets;
115 float m_width, m_height;
116 VkFormat m_render_target_fmt;
117 VkFormat m_depth_stencil_fmt;
118 VkColorAttachmentBindInfo m_colorBindings[8];
119 VkClearColor m_clear_color;
120 float m_depth_clear_color;
121 uint32_t m_stencil_clear_color;
122 VkDepthStencilObj *m_depthStencil;
123 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600124
125 /*
126 * SetUp and TearDown are called by the Google Test framework
127 * to initialize a test framework based on this class.
128 */
129 virtual void SetUp() {
130 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
131 this->app_info.pNext = NULL;
132 this->app_info.pAppName = "base";
133 this->app_info.appVersion = 1;
134 this->app_info.pEngineName = "unittest";
135 this->app_info.engineVersion = 1;
136 this->app_info.apiVersion = VK_API_VERSION;
137
138 InitFramework();
139 }
140
141 virtual void TearDown() {
142 ShutdownFramework();
143 }
144};
145
Tony Barbour01999182015-04-09 12:58:51 -0600146class VkDescriptorSetObj;
147class VkIndexBufferObj;
148class VkConstantBufferObj;
149class VkPipelineObj;
150class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600151
Tony Barbour01999182015-04-09 12:58:51 -0600152class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600153{
154public:
Tony Barbour01999182015-04-09 12:58:51 -0600155 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600156 VkCmdBuffer GetBufferHandle();
157 VkResult BeginCommandBuffer();
158 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
159 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
160 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600161 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600162 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600163 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600164 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600165 void PrepareAttachments();
166 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600167 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600168 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600169 void BindPipeline(VkPipelineObj &pipeline);
170 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600171 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600172 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600173 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
174 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
175 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600176 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
177 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
178 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600179 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600180
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600181 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600182
183protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600184 VkDeviceObj *m_device;
185 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600186};
187
Tony Barbour01999182015-04-09 12:58:51 -0600188class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600189{
190public:
Tony Barbour01999182015-04-09 12:58:51 -0600191 VkConstantBufferObj(VkDeviceObj *device);
192 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
193 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600194 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600195 VkFlags outputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600196 VK_MEMORY_OUTPUT_CPU_WRITE_BIT |
197 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
198 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
199 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600200 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600201 VkFlags inputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600202 VK_MEMORY_INPUT_CPU_READ_BIT |
203 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
204 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
205 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
206 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
207 VK_MEMORY_INPUT_SHADER_READ_BIT |
208 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
209 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600210 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600211
Tony Barbour8205d902015-04-16 15:59:00 -0600212 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600213
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600214 VkBufferViewAttachInfo m_bufferViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600215
216protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600217 VkDeviceObj *m_device;
218 vk_testing::BufferView m_bufferView;
219 int m_numVertices;
220 int m_stride;
221 VkCommandBufferObj *m_commandBuffer;
222 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600223};
224
Tony Barbour01999182015-04-09 12:58:51 -0600225class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600226{
227public:
Tony Barbour01999182015-04-09 12:58:51 -0600228 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600229 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600230 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600231 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600232
233protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600234 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600235};
236
Tony Barbour01999182015-04-09 12:58:51 -0600237class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600238{
239public:
Tony Barbour01999182015-04-09 12:58:51 -0600240 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600241 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600242
243public:
244 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600245 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600246 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
247 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600248
249 // void clear( CommandBuffer*, uint32_t[4] );
250
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600251 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600252 {
253 m_imageInfo.layout = layout;
254 }
255
Tony Barbour8205d902015-04-16 15:59:00 -0600256 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600257 {
Tony Barbour8205d902015-04-16 15:59:00 -0600258 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600259 return mems.empty() ? VK_NULL_HANDLE : mems[0];
260 }
261
Tony Barbour01999182015-04-09 12:58:51 -0600262 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600263 VkImageAspect aspect,
264 VkFlags output_mask,
265 VkFlags input_mask,
266 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600267
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600268 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600269
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600270 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600271 {
272 return obj();
273 }
274
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600275 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600276 {
277 if (!m_targetView.initialized())
278 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600279 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600280 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
281 VK_NULL_HANDLE,
282 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600283 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600284 0,
285 0,
286 1
287 };
288 m_targetView.init(*m_device, createView);
289 }
290 return m_targetView.obj();
291 }
292
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600293 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
294 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600295
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600296 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600297 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600298 return ( VkImageLayout )m_imageInfo.layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600299 }
300 uint32_t width() const
301 {
302 return extent().width;
303 }
304 uint32_t height() const
305 {
306 return extent().height;
307 }
Tony Barbour01999182015-04-09 12:58:51 -0600308 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600309 {
310 return m_device;
311 }
312
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600313 VkResult MapMemory(void** ptr);
314 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600315
316protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600317 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600318
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600319 vk_testing::ColorAttachmentView m_targetView;
320 VkImageViewAttachInfo m_imageInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600321};
322
Tony Barbour01999182015-04-09 12:58:51 -0600323class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600324{
325public:
Tony Barbour01999182015-04-09 12:58:51 -0600326 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600327 VkImageViewAttachInfo m_textureViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328
329
330protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600331 VkDeviceObj *m_device;
332 vk_testing::ImageView m_textureView;
333 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600334};
335
Tony Barbour01999182015-04-09 12:58:51 -0600336class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600337{
338public:
Tony Barbour01999182015-04-09 12:58:51 -0600339 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600340
341protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600342 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600343
344};
345
Tony Barbour01999182015-04-09 12:58:51 -0600346class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600347{
348public:
Tony Barbour01999182015-04-09 12:58:51 -0600349 VkDescriptorSetObj(VkDeviceObj *device);
350 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600351
352 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600353 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600354 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
355 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600356
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600357 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500358 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600359
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600360 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600361
362protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600363 VkDeviceObj *m_device;
364 vector<VkDescriptorTypeCount> m_type_counts;
365 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600366
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600367 vector<VkUpdateBuffers> m_updateBuffers;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600368
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600369 vector<VkSamplerImageViewInfo> m_samplerTextureInfo;
370 vector<VkUpdateSamplerTextures> m_updateSamplerTextures;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600371
372 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500373 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600374 vk_testing::DescriptorSet *m_set;
375};
376
377
Tony Barbour01999182015-04-09 12:58:51 -0600378class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600379{
380public:
Tony Barbour8205d902015-04-16 15:59:00 -0600381 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600382 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600383
384protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600385 VkPipelineShaderStageCreateInfo stage_info;
386 VkShaderStage m_stage;
387 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600388
389};
390
Tony Barbour01999182015-04-09 12:58:51 -0600391class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600392{
393public:
Tony Barbour01999182015-04-09 12:58:51 -0600394 VkPipelineObj(VkDeviceObj *device);
395 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600396 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
397 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600398 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600399 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
400 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Tony Barbour01999182015-04-09 12:58:51 -0600401 void CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600402
403protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600404 VkPipelineVertexInputCreateInfo m_vi_state;
405 VkPipelineIaStateCreateInfo m_ia_state;
406 VkPipelineRsStateCreateInfo m_rs_state;
407 VkPipelineCbStateCreateInfo m_cb_state;
408 VkPipelineDsStateCreateInfo m_ds_state;
409 VkPipelineMsStateCreateInfo m_ms_state;
410 VkDeviceObj *m_device;
411 vector<VkShaderObj*> m_shaderObjs;
412 vector<VkConstantBufferObj*> m_vertexBufferObjs;
413 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600414 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600415 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600416
417};
418
419#endif // VKRENDERFRAMEWORK_H