blob: 285cd8057d91577fe53ab413e4b0f4c894394b4b [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"
Tony Barbour0c1bdc62015-04-29 17:34:29 -060032#include <vkDbg.h>
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060033
34
Tony Barbour01999182015-04-09 12:58:51 -060035class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060036{
37public:
Tony Barbour8205d902015-04-16 15:59:00 -060038 VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060039
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060040 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060041 void get_device_queue();
42
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060043 uint32_t id;
44 VkPhysicalDeviceProperties props;
Tony Barbour8205d902015-04-16 15:59:00 -060045 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060046
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060047 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060048};
49
Tony Barbour01999182015-04-09 12:58:51 -060050class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060051{
52public:
53 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -060054 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060055 void EmitAddMemoryRefs(VkQueue queue);
56 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbour8205d902015-04-16 15:59:00 -060057 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060058
59protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060060 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060061
62};
63
Tony Barbour01999182015-04-09 12:58:51 -060064class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060065{
66public:
Tony Barbour01999182015-04-09 12:58:51 -060067 VkDepthStencilObj();
68 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060069 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060070 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060071
72protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060073 VkDeviceObj *m_device;
74 bool m_initialized;
75 vk_testing::DepthStencilView m_depthStencilView;
76 VkFormat m_depth_stencil_fmt;
77 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060078};
79
Tony Barbour01999182015-04-09 12:58:51 -060080class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060081{
82public:
Tony Barbour01999182015-04-09 12:58:51 -060083 VkRenderFramework();
84 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060085
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060086 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060087 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060088 VkRenderPass renderPass() {return m_renderPass;}
89 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060090 void InitViewport(float width, float height);
91 void InitViewport();
92 void InitRenderTarget();
93 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060094 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
95 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060096 void InitFramework();
Tony Barbour0c1bdc62015-04-29 17:34:29 -060097 void InitFramework(const std::vector<const char *> &layers, VK_DBG_MSG_CALLBACK_FUNCTION=NULL, void *userData=NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060098 void ShutdownFramework();
99 void InitState();
100
101
102protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600103 VkApplicationInfo app_info;
104 VkInstance inst;
105 VkPhysicalDevice objs[16];
106 uint32_t gpu_count;
107 VkDeviceObj *m_device;
108 VkCmdBuffer m_cmdBuffer;
109 VkRenderPass m_renderPass;
110 VkFramebuffer m_framebuffer;
111 VkDynamicRsState m_stateRaster;
112 VkDynamicCbState m_colorBlend;
113 VkDynamicVpState m_stateViewport;
114 VkDynamicDsState m_stateDepthStencil;
115 vector<VkImageObj*> m_renderTargets;
116 float m_width, m_height;
117 VkFormat m_render_target_fmt;
118 VkFormat m_depth_stencil_fmt;
119 VkColorAttachmentBindInfo m_colorBindings[8];
120 VkClearColor m_clear_color;
Chris Forbes23e6db62015-06-15 09:32:35 +1200121 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600122 float m_depth_clear_color;
123 uint32_t m_stencil_clear_color;
124 VkDepthStencilObj *m_depthStencil;
125 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600126
127 /*
128 * SetUp and TearDown are called by the Google Test framework
129 * to initialize a test framework based on this class.
130 */
131 virtual void SetUp() {
132 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
133 this->app_info.pNext = NULL;
134 this->app_info.pAppName = "base";
135 this->app_info.appVersion = 1;
136 this->app_info.pEngineName = "unittest";
137 this->app_info.engineVersion = 1;
138 this->app_info.apiVersion = VK_API_VERSION;
139
140 InitFramework();
141 }
142
143 virtual void TearDown() {
144 ShutdownFramework();
145 }
146};
147
Tony Barbour01999182015-04-09 12:58:51 -0600148class VkDescriptorSetObj;
149class VkIndexBufferObj;
150class VkConstantBufferObj;
151class VkPipelineObj;
152class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600153
Tony Barbour01999182015-04-09 12:58:51 -0600154class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600155{
156public:
Tony Barbour01999182015-04-09 12:58:51 -0600157 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600158 VkCmdBuffer GetBufferHandle();
159 VkResult BeginCommandBuffer();
160 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
161 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
162 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600163 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600164 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600165 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600166 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600167 void PrepareAttachments();
168 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600169 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600170 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600171 void BindPipeline(VkPipelineObj &pipeline);
172 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600173 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600174 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600175 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
176 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
177 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600178 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
179 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
180 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600181 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600182
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600183 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600184
185protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600186 VkDeviceObj *m_device;
187 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600188};
189
Tony Barbour01999182015-04-09 12:58:51 -0600190class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600191{
192public:
Tony Barbour01999182015-04-09 12:58:51 -0600193 VkConstantBufferObj(VkDeviceObj *device);
194 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
195 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600196 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600197 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600198 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600199 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
200 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
201 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600202 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600203 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600204 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600205 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
206 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
207 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
208 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
209 VK_MEMORY_INPUT_SHADER_READ_BIT |
210 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
211 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600212 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600213
Tony Barbour8205d902015-04-16 15:59:00 -0600214 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600215
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800216 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600217
218protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600219 VkDeviceObj *m_device;
220 vk_testing::BufferView m_bufferView;
221 int m_numVertices;
222 int m_stride;
223 VkCommandBufferObj *m_commandBuffer;
224 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600225};
226
Tony Barbour01999182015-04-09 12:58:51 -0600227class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600228{
229public:
Tony Barbour01999182015-04-09 12:58:51 -0600230 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600231 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600232 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600233 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600234
235protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600236 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600237};
238
Tony Barbour01999182015-04-09 12:58:51 -0600239class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600240{
241public:
Tony Barbour01999182015-04-09 12:58:51 -0600242 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600243 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600244
245public:
246 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600247 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600248 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
249 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600250
251 // void clear( CommandBuffer*, uint32_t[4] );
252
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600253 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600254 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800255 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600256 }
257
Tony Barbour8205d902015-04-16 15:59:00 -0600258 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600259 {
Tony Barbour8205d902015-04-16 15:59:00 -0600260 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600261 return mems.empty() ? VK_NULL_HANDLE : mems[0];
262 }
263
Tony Barbour01999182015-04-09 12:58:51 -0600264 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600265 VkImageAspect aspect,
266 VkFlags output_mask,
267 VkFlags input_mask,
268 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600269
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600270 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600271
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600272 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600273 {
274 return obj();
275 }
276
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600277 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600278 {
279 if (!m_targetView.initialized())
280 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600281 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600282 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
283 VK_NULL_HANDLE,
284 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600285 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600286 0,
287 0,
288 1
289 };
290 m_targetView.init(*m_device, createView);
291 }
292 return m_targetView.obj();
293 }
294
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600295 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
296 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600297
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600298 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600299 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800300 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600301 }
302 uint32_t width() const
303 {
304 return extent().width;
305 }
306 uint32_t height() const
307 {
308 return extent().height;
309 }
Tony Barbour01999182015-04-09 12:58:51 -0600310 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600311 {
312 return m_device;
313 }
314
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600315 VkResult MapMemory(void** ptr);
316 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600317
318protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600319 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600320
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600321 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800322 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600323};
324
Tony Barbour01999182015-04-09 12:58:51 -0600325class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600326{
327public:
Tony Barbour01999182015-04-09 12:58:51 -0600328 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600329
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800330 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331
332protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600333 VkDeviceObj *m_device;
334 vk_testing::ImageView m_textureView;
335 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600336};
337
Tony Barbour01999182015-04-09 12:58:51 -0600338class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600339{
340public:
Tony Barbour01999182015-04-09 12:58:51 -0600341 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600342
343protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600344 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600345
346};
347
Tony Barbour01999182015-04-09 12:58:51 -0600348class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600349{
350public:
Tony Barbour01999182015-04-09 12:58:51 -0600351 VkDescriptorSetObj(VkDeviceObj *device);
352 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600353
354 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600355 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600356 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
357 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600358
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600359 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500360 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600361
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600362 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600363
364protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600365 VkDeviceObj *m_device;
366 vector<VkDescriptorTypeCount> m_type_counts;
367 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600368
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800369 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
370 vector<VkWriteDescriptorSet> m_writes;
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 *);
Chris Forbesdc2188c2015-05-25 11:13:26 +1200401 VkResult 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;
Tony Barbour5e245132015-05-15 09:37:57 -0600409 VkPipelineVpStateCreateInfo m_vp_state;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600410 VkPipelineMsStateCreateInfo m_ms_state;
411 VkDeviceObj *m_device;
412 vector<VkShaderObj*> m_shaderObjs;
413 vector<VkConstantBufferObj*> m_vertexBufferObjs;
414 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600415 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600416 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600417
418};
419
420#endif // VKRENDERFRAMEWORK_H