blob: a265bc706244669bd06d637d584ab609c66ad45b [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;
121 float m_depth_clear_color;
122 uint32_t m_stencil_clear_color;
123 VkDepthStencilObj *m_depthStencil;
124 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600125
126 /*
127 * SetUp and TearDown are called by the Google Test framework
128 * to initialize a test framework based on this class.
129 */
130 virtual void SetUp() {
131 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
132 this->app_info.pNext = NULL;
133 this->app_info.pAppName = "base";
134 this->app_info.appVersion = 1;
135 this->app_info.pEngineName = "unittest";
136 this->app_info.engineVersion = 1;
137 this->app_info.apiVersion = VK_API_VERSION;
138
139 InitFramework();
140 }
141
142 virtual void TearDown() {
143 ShutdownFramework();
144 }
145};
146
Tony Barbour01999182015-04-09 12:58:51 -0600147class VkDescriptorSetObj;
148class VkIndexBufferObj;
149class VkConstantBufferObj;
150class VkPipelineObj;
151class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600152
Tony Barbour01999182015-04-09 12:58:51 -0600153class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600154{
155public:
Tony Barbour01999182015-04-09 12:58:51 -0600156 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600157 VkCmdBuffer GetBufferHandle();
158 VkResult BeginCommandBuffer();
159 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
160 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
161 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600162 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600163 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600164 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600165 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600166 void PrepareAttachments();
167 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600168 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600169 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600170 void BindPipeline(VkPipelineObj &pipeline);
171 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600172 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600173 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600174 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
175 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
176 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600177 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
178 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
179 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600180 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600182 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600183
184protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600185 VkDeviceObj *m_device;
186 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600187};
188
Tony Barbour01999182015-04-09 12:58:51 -0600189class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600190{
191public:
Tony Barbour01999182015-04-09 12:58:51 -0600192 VkConstantBufferObj(VkDeviceObj *device);
193 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
194 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600195 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600196 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600197 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600198 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
199 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
200 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600201 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600202 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600203 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600204 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
205 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
206 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
207 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
208 VK_MEMORY_INPUT_SHADER_READ_BIT |
209 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
210 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600211 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600212
Tony Barbour8205d902015-04-16 15:59:00 -0600213 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600214
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800215 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600216
217protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600218 VkDeviceObj *m_device;
219 vk_testing::BufferView m_bufferView;
220 int m_numVertices;
221 int m_stride;
222 VkCommandBufferObj *m_commandBuffer;
223 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600224};
225
Tony Barbour01999182015-04-09 12:58:51 -0600226class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600227{
228public:
Tony Barbour01999182015-04-09 12:58:51 -0600229 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600230 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600231 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600232 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600233
234protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600235 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600236};
237
Tony Barbour01999182015-04-09 12:58:51 -0600238class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600239{
240public:
Tony Barbour01999182015-04-09 12:58:51 -0600241 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600242 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600243
244public:
245 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600246 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600247 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
248 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600249
250 // void clear( CommandBuffer*, uint32_t[4] );
251
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600252 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600253 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800254 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600255 }
256
Tony Barbour8205d902015-04-16 15:59:00 -0600257 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600258 {
Tony Barbour8205d902015-04-16 15:59:00 -0600259 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600260 return mems.empty() ? VK_NULL_HANDLE : mems[0];
261 }
262
Tony Barbour01999182015-04-09 12:58:51 -0600263 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600264 VkImageAspect aspect,
265 VkFlags output_mask,
266 VkFlags input_mask,
267 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600268
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600269 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600270
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600271 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600272 {
273 return obj();
274 }
275
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600276 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600277 {
278 if (!m_targetView.initialized())
279 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600280 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600281 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
282 VK_NULL_HANDLE,
283 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600284 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600285 0,
286 0,
287 1
288 };
289 m_targetView.init(*m_device, createView);
290 }
291 return m_targetView.obj();
292 }
293
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600294 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
295 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600296
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600297 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600298 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800299 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600300 }
301 uint32_t width() const
302 {
303 return extent().width;
304 }
305 uint32_t height() const
306 {
307 return extent().height;
308 }
Tony Barbour01999182015-04-09 12:58:51 -0600309 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600310 {
311 return m_device;
312 }
313
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600314 VkResult MapMemory(void** ptr);
315 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600316
317protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600318 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600319
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600320 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800321 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600322};
323
Tony Barbour01999182015-04-09 12:58:51 -0600324class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600325{
326public:
Tony Barbour01999182015-04-09 12:58:51 -0600327 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800329 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600330
331protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600332 VkDeviceObj *m_device;
333 vk_testing::ImageView m_textureView;
334 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600335};
336
Tony Barbour01999182015-04-09 12:58:51 -0600337class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600338{
339public:
Tony Barbour01999182015-04-09 12:58:51 -0600340 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600341
342protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600343 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600344
345};
346
Tony Barbour01999182015-04-09 12:58:51 -0600347class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600348{
349public:
Tony Barbour01999182015-04-09 12:58:51 -0600350 VkDescriptorSetObj(VkDeviceObj *device);
351 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600352
353 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600354 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600355 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
356 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600357
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600358 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500359 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600360
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600361 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600362
363protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600364 VkDeviceObj *m_device;
365 vector<VkDescriptorTypeCount> m_type_counts;
366 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800368 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
369 vector<VkWriteDescriptorSet> m_writes;
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