blob: 024bdba8f327dbff7facabbaafd8a2d463c6d71b [file] [log] [blame]
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06001/*
2 * Vulkan Tests
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 */
27
28#ifndef VKRENDERFRAMEWORK_H
29#define VKRENDERFRAMEWORK_H
30
31#include "vktestframework.h"
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060032#include "vk_debug_report_lunarg.h"
33#include "vk_debug_marker_lunarg.h"
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060034
35
Tony Barbour01999182015-04-09 12:58:51 -060036class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060037{
38public:
Tony Barbour8205d902015-04-16 15:59:00 -060039 VkDeviceObj(uint32_t id, VkPhysicalDevice obj);
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060040 VkDeviceObj(uint32_t id, VkPhysicalDevice obj, std::vector<VkExtensionProperties> extension_names);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060041
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060042 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060043 void get_device_queue();
44
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060045 uint32_t id;
46 VkPhysicalDeviceProperties props;
Tony Barbour8205d902015-04-16 15:59:00 -060047 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060048
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060049 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050};
51
Tony Barbour01999182015-04-09 12:58:51 -060052class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060053{
54public:
55 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -060056 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060057 void EmitAddMemoryRefs(VkQueue queue);
58 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbour8205d902015-04-16 15:59:00 -060059 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060060
61protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060062 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060063
64};
65
Tony Barbour01999182015-04-09 12:58:51 -060066class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060067{
68public:
Tony Barbour01999182015-04-09 12:58:51 -060069 VkDepthStencilObj();
70 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060071 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060072 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060073
74protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060075 VkDeviceObj *m_device;
76 bool m_initialized;
77 vk_testing::DepthStencilView m_depthStencilView;
78 VkFormat m_depth_stencil_fmt;
79 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060080};
81
Tony Barbour01999182015-04-09 12:58:51 -060082class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060083{
84public:
Tony Barbour01999182015-04-09 12:58:51 -060085 VkRenderFramework();
86 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060087
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060088 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060089 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060090 VkRenderPass renderPass() {return m_renderPass;}
91 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060092 void InitViewport(float width, float height);
93 void InitViewport();
94 void InitRenderTarget();
95 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060096 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
97 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060098 void InitFramework();
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060099 void InitFramework(std::vector<const char *> instance_extension_names,
100 std::vector<const char *> device_extension_names,
101 PFN_vkDbgMsgCallback=NULL,
102 void *userData=NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600103 void ShutdownFramework();
104 void InitState();
105
106
107protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600108 VkApplicationInfo app_info;
109 VkInstance inst;
110 VkPhysicalDevice objs[16];
111 uint32_t gpu_count;
112 VkDeviceObj *m_device;
113 VkCmdBuffer m_cmdBuffer;
114 VkRenderPass m_renderPass;
115 VkFramebuffer m_framebuffer;
116 VkDynamicRsState m_stateRaster;
117 VkDynamicCbState m_colorBlend;
118 VkDynamicVpState m_stateViewport;
119 VkDynamicDsState m_stateDepthStencil;
120 vector<VkImageObj*> m_renderTargets;
121 float m_width, m_height;
122 VkFormat m_render_target_fmt;
123 VkFormat m_depth_stencil_fmt;
124 VkColorAttachmentBindInfo m_colorBindings[8];
125 VkClearColor m_clear_color;
Chris Forbes23e6db62015-06-15 09:32:35 +1200126 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600127 float m_depth_clear_color;
128 uint32_t m_stencil_clear_color;
129 VkDepthStencilObj *m_depthStencil;
130 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600131 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
132 VkDbgMsgCallback m_msgCallback;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600133
134 /*
135 * SetUp and TearDown are called by the Google Test framework
136 * to initialize a test framework based on this class.
137 */
138 virtual void SetUp() {
139 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
140 this->app_info.pNext = NULL;
141 this->app_info.pAppName = "base";
142 this->app_info.appVersion = 1;
143 this->app_info.pEngineName = "unittest";
144 this->app_info.engineVersion = 1;
145 this->app_info.apiVersion = VK_API_VERSION;
146
147 InitFramework();
148 }
149
150 virtual void TearDown() {
151 ShutdownFramework();
152 }
153};
154
Tony Barbour01999182015-04-09 12:58:51 -0600155class VkDescriptorSetObj;
156class VkIndexBufferObj;
157class VkConstantBufferObj;
158class VkPipelineObj;
159class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600160
Tony Barbour01999182015-04-09 12:58:51 -0600161class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600162{
163public:
Tony Barbour01999182015-04-09 12:58:51 -0600164 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600165 VkCmdBuffer GetBufferHandle();
166 VkResult BeginCommandBuffer();
167 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
168 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
169 VkResult EndCommandBuffer();
Tony Barbour8205d902015-04-16 15:59:00 -0600170 void PipelineBarrier(VkWaitEvent waitEvent, uint32_t pipeEventCount, const VkPipeEvent* pPipeEvents, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600171 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600172 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600173 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600174 void PrepareAttachments();
175 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600176 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600177 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600178 void BindPipeline(VkPipelineObj &pipeline);
179 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600180 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600181 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600182 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
183 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
184 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600185 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
186 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
187 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600188 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600189
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600190 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600191
192protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600193 VkDeviceObj *m_device;
194 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600195};
196
Tony Barbour01999182015-04-09 12:58:51 -0600197class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600198{
199public:
Tony Barbour01999182015-04-09 12:58:51 -0600200 VkConstantBufferObj(VkDeviceObj *device);
201 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
202 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600203 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600204 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600205 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600206 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
207 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
208 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600209 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600210 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600211 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600212 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
213 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
214 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
215 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
216 VK_MEMORY_INPUT_SHADER_READ_BIT |
217 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
218 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600219 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600220
Tony Barbour8205d902015-04-16 15:59:00 -0600221 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600222
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800223 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600224
225protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600226 VkDeviceObj *m_device;
227 vk_testing::BufferView m_bufferView;
228 int m_numVertices;
229 int m_stride;
230 VkCommandBufferObj *m_commandBuffer;
231 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600232};
233
Tony Barbour01999182015-04-09 12:58:51 -0600234class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600235{
236public:
Tony Barbour01999182015-04-09 12:58:51 -0600237 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600238 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600239 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600240 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600241
242protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600243 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600244};
245
Tony Barbour01999182015-04-09 12:58:51 -0600246class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600247{
248public:
Tony Barbour01999182015-04-09 12:58:51 -0600249 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600250 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600251
252public:
253 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600254 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600255 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
256 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600257
258 // void clear( CommandBuffer*, uint32_t[4] );
259
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600260 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600261 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800262 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600263 }
264
Tony Barbour8205d902015-04-16 15:59:00 -0600265 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600266 {
Tony Barbour8205d902015-04-16 15:59:00 -0600267 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600268 return mems.empty() ? VK_NULL_HANDLE : mems[0];
269 }
270
Tony Barbour01999182015-04-09 12:58:51 -0600271 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600272 VkImageAspect aspect,
273 VkFlags output_mask,
274 VkFlags input_mask,
275 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600276
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600277 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600278
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600279 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600280 {
281 return obj();
282 }
283
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600284 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600285 {
286 if (!m_targetView.initialized())
287 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600288 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600289 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
290 VK_NULL_HANDLE,
291 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600292 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600293 0,
294 0,
295 1
296 };
297 m_targetView.init(*m_device, createView);
298 }
299 return m_targetView.obj();
300 }
301
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600302 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
303 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600304
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600305 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600306 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800307 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600308 }
309 uint32_t width() const
310 {
311 return extent().width;
312 }
313 uint32_t height() const
314 {
315 return extent().height;
316 }
Tony Barbour01999182015-04-09 12:58:51 -0600317 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600318 {
319 return m_device;
320 }
321
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600322 VkResult MapMemory(void** ptr);
323 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600324
325protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600326 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600327
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600328 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800329 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600330};
331
Tony Barbour01999182015-04-09 12:58:51 -0600332class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600333{
334public:
Tony Barbour01999182015-04-09 12:58:51 -0600335 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600336
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800337 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600338
339protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600340 VkDeviceObj *m_device;
341 vk_testing::ImageView m_textureView;
342 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600343};
344
Tony Barbour01999182015-04-09 12:58:51 -0600345class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600346{
347public:
Tony Barbour01999182015-04-09 12:58:51 -0600348 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600349
350protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600351 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600352
353};
354
Tony Barbour01999182015-04-09 12:58:51 -0600355class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600356{
357public:
Tony Barbour01999182015-04-09 12:58:51 -0600358 VkDescriptorSetObj(VkDeviceObj *device);
359 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600360
361 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600362 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600363 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
364 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600365
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600366 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500367 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600368
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600369 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370
371protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600372 VkDeviceObj *m_device;
373 vector<VkDescriptorTypeCount> m_type_counts;
374 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600375
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800376 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
377 vector<VkWriteDescriptorSet> m_writes;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600378
379 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500380 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600381 vk_testing::DescriptorSet *m_set;
382};
383
384
Tony Barbour01999182015-04-09 12:58:51 -0600385class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600386{
387public:
Tony Barbour8205d902015-04-16 15:59:00 -0600388 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600389 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600390
391protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600392 VkPipelineShaderStageCreateInfo stage_info;
393 VkShaderStage m_stage;
394 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600395
396};
397
Tony Barbour01999182015-04-09 12:58:51 -0600398class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600399{
400public:
Tony Barbour01999182015-04-09 12:58:51 -0600401 VkPipelineObj(VkDeviceObj *device);
402 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600403 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
404 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600405 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600406 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
407 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Chris Forbesdc2188c2015-05-25 11:13:26 +1200408 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600409
410protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600411 VkPipelineVertexInputCreateInfo m_vi_state;
412 VkPipelineIaStateCreateInfo m_ia_state;
413 VkPipelineRsStateCreateInfo m_rs_state;
414 VkPipelineCbStateCreateInfo m_cb_state;
415 VkPipelineDsStateCreateInfo m_ds_state;
Tony Barbour5e245132015-05-15 09:37:57 -0600416 VkPipelineVpStateCreateInfo m_vp_state;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600417 VkPipelineMsStateCreateInfo m_ms_state;
418 VkDeviceObj *m_device;
419 vector<VkShaderObj*> m_shaderObjs;
420 vector<VkConstantBufferObj*> m_vertexBufferObjs;
421 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600422 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600423 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600424
425};
426
427#endif // VKRENDERFRAMEWORK_H