blob: ffc1891344d5163c600a7296b449b7c861c1050c [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 Goeltzenleuchter61414de2015-07-07 11:47:33 -060040 VkDeviceObj(uint32_t id, VkPhysicalDevice obj,
41 std::vector<const char *> &layers,
42 std::vector<const char *> &extension_names);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060043
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060044 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060045 void get_device_queue();
46
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060047 uint32_t id;
48 VkPhysicalDeviceProperties props;
Tony Barbour8205d902015-04-16 15:59:00 -060049 const VkPhysicalDeviceQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060051 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060052};
53
Tony Barbour01999182015-04-09 12:58:51 -060054class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060055{
56public:
57 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -060058 void AddMemoryRefs(vector<VkDeviceMemory> mem);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060059 void EmitAddMemoryRefs(VkQueue queue);
60 void EmitRemoveMemoryRefs(VkQueue queue);
Tony Barbour8205d902015-04-16 15:59:00 -060061 vector<VkDeviceMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060062
63protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060064 vector<VkDeviceMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060065
66};
67
Tony Barbour01999182015-04-09 12:58:51 -060068class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060069{
70public:
Tony Barbour01999182015-04-09 12:58:51 -060071 VkDepthStencilObj();
72 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060073 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060074 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060075
76protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060077 VkDeviceObj *m_device;
78 bool m_initialized;
79 vk_testing::DepthStencilView m_depthStencilView;
80 VkFormat m_depth_stencil_fmt;
81 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060082};
83
Tony Barbour01999182015-04-09 12:58:51 -060084class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060085{
86public:
Tony Barbour01999182015-04-09 12:58:51 -060087 VkRenderFramework();
88 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060089
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060090 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060091 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060092 VkRenderPass renderPass() {return m_renderPass;}
93 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060094 void InitViewport(float width, float height);
95 void InitViewport();
96 void InitRenderTarget();
97 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060098 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
99 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600100 void InitFramework();
Courtney Goeltzenleuchterf5c61952015-07-06 09:10:47 -0600101 void InitFramework(
102 std::vector<const char *> instance_layer_names,
103 std::vector<const char *> device_layer_names,
104 std::vector<const char *> instance_extension_names,
105 std::vector<const char *> device_extension_names,
106 PFN_vkDbgMsgCallback=NULL,
107 void *userData=NULL);
108
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600109 void ShutdownFramework();
110 void InitState();
111
112
113protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600114 VkApplicationInfo app_info;
115 VkInstance inst;
116 VkPhysicalDevice objs[16];
117 uint32_t gpu_count;
118 VkDeviceObj *m_device;
119 VkCmdBuffer m_cmdBuffer;
120 VkRenderPass m_renderPass;
121 VkFramebuffer m_framebuffer;
122 VkDynamicRsState m_stateRaster;
123 VkDynamicCbState m_colorBlend;
124 VkDynamicVpState m_stateViewport;
125 VkDynamicDsState m_stateDepthStencil;
126 vector<VkImageObj*> m_renderTargets;
127 float m_width, m_height;
128 VkFormat m_render_target_fmt;
129 VkFormat m_depth_stencil_fmt;
130 VkColorAttachmentBindInfo m_colorBindings[8];
Chris Forbese3105972015-06-24 14:34:53 +1200131 VkClearColorValue m_clear_color;
Chris Forbes23e6db62015-06-15 09:32:35 +1200132 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600133 float m_depth_clear_color;
134 uint32_t m_stencil_clear_color;
135 VkDepthStencilObj *m_depthStencil;
136 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600137 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
Courtney Goeltzenleuchter18e8a492015-06-08 15:16:04 -0600138 PFN_vkDbgDestroyMsgCallback m_dbgDestroyMsgCallback;
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600139 VkDbgMsgCallback m_globalMsgCallback;
140 VkDbgMsgCallback m_devMsgCallback;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600141
142 /*
143 * SetUp and TearDown are called by the Google Test framework
144 * to initialize a test framework based on this class.
145 */
146 virtual void SetUp() {
147 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
148 this->app_info.pNext = NULL;
149 this->app_info.pAppName = "base";
150 this->app_info.appVersion = 1;
151 this->app_info.pEngineName = "unittest";
152 this->app_info.engineVersion = 1;
153 this->app_info.apiVersion = VK_API_VERSION;
154
155 InitFramework();
156 }
157
158 virtual void TearDown() {
159 ShutdownFramework();
160 }
161};
162
Tony Barbour01999182015-04-09 12:58:51 -0600163class VkDescriptorSetObj;
164class VkIndexBufferObj;
165class VkConstantBufferObj;
166class VkPipelineObj;
167class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600168
Tony Barbour01999182015-04-09 12:58:51 -0600169class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600170{
171public:
Tony Barbour01999182015-04-09 12:58:51 -0600172 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600173 VkCmdBuffer GetBufferHandle();
174 VkResult BeginCommandBuffer();
175 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600176 VkResult EndCommandBuffer();
Courtney Goeltzenleuchter1f41f542015-07-09 11:44:38 -0600177 void PipelineBarrier(VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages, VkBool32 byRegion, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600178 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600179 void AddDepthStencil();
Chris Forbese3105972015-06-24 14:34:53 +1200180 void ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181 void PrepareAttachments();
182 void AddMemoryRefs(vk_testing::Object &vkObject);
Tony Barbour8205d902015-04-16 15:59:00 -0600183 void AddMemoryRefs(uint32_t ref_count, const VkDeviceMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600184 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600185 void BindPipeline(VkPipelineObj &pipeline);
186 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600187 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600188 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600189 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
190 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
Chia-I Wu88eaa3b2015-06-26 15:34:39 +0800191 void EndRenderPass();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600192 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
193 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
194 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600195 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600196
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600197 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600198
199protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600200 VkDeviceObj *m_device;
201 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600202};
203
Tony Barbour01999182015-04-09 12:58:51 -0600204class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600205{
206public:
Tony Barbour01999182015-04-09 12:58:51 -0600207 VkConstantBufferObj(VkDeviceObj *device);
208 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
209 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600210 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600211 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600212 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600213 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
214 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
215 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600216 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600217 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600218 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600219 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
220 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
221 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
222 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
223 VK_MEMORY_INPUT_SHADER_READ_BIT |
224 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
225 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600226 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600227
Tony Barbour8205d902015-04-16 15:59:00 -0600228 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600229
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800230 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600231
232protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600233 VkDeviceObj *m_device;
234 vk_testing::BufferView m_bufferView;
235 int m_numVertices;
236 int m_stride;
237 VkCommandBufferObj *m_commandBuffer;
238 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600239};
240
Tony Barbour01999182015-04-09 12:58:51 -0600241class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600242{
243public:
Tony Barbour01999182015-04-09 12:58:51 -0600244 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600245 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600246 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600247 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600248
249protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600250 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600251};
252
Tony Barbour01999182015-04-09 12:58:51 -0600253class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600254{
255public:
Tony Barbour01999182015-04-09 12:58:51 -0600256 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600257 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600258
259public:
260 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600261 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600262 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
263 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600264
265 // void clear( CommandBuffer*, uint32_t[4] );
266
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600267 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600268 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800269 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600270 }
271
Tony Barbour8205d902015-04-16 15:59:00 -0600272 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600273 {
Tony Barbour8205d902015-04-16 15:59:00 -0600274 const std::vector<VkDeviceMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600275 return mems.empty() ? VK_NULL_HANDLE : mems[0];
276 }
277
Tony Barbour01999182015-04-09 12:58:51 -0600278 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600279 VkImageAspect aspect,
280 VkFlags output_mask,
281 VkFlags input_mask,
282 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600283
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600284 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600285
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600286 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600287 {
288 return obj();
289 }
290
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600291 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600292 {
293 if (!m_targetView.initialized())
294 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600295 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600296 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
297 VK_NULL_HANDLE,
298 obj(),
Tony Barbour8205d902015-04-16 15:59:00 -0600299 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600300 0,
301 0,
302 1
303 };
304 m_targetView.init(*m_device, createView);
305 }
306 return m_targetView.obj();
307 }
308
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600309 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
310 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600311
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600312 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600313 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800314 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600315 }
316 uint32_t width() const
317 {
318 return extent().width;
319 }
320 uint32_t height() const
321 {
322 return extent().height;
323 }
Tony Barbour01999182015-04-09 12:58:51 -0600324 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600325 {
326 return m_device;
327 }
328
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600329 VkResult MapMemory(void** ptr);
330 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331
332protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600333 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600334
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600335 vk_testing::ColorAttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800336 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600337};
338
Tony Barbour01999182015-04-09 12:58:51 -0600339class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600340{
341public:
Tony Barbour01999182015-04-09 12:58:51 -0600342 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600343
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800344 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600345
346protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600347 VkDeviceObj *m_device;
348 vk_testing::ImageView m_textureView;
349 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600350};
351
Tony Barbour01999182015-04-09 12:58:51 -0600352class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600353{
354public:
Tony Barbour01999182015-04-09 12:58:51 -0600355 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600356
357protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600358 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600359
360};
361
Tony Barbour01999182015-04-09 12:58:51 -0600362class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600363{
364public:
Tony Barbour01999182015-04-09 12:58:51 -0600365 VkDescriptorSetObj(VkDeviceObj *device);
366 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367
368 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600369 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600370 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
371 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600372
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600373 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500374 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600375
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600376 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600377
378protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600379 VkDeviceObj *m_device;
380 vector<VkDescriptorTypeCount> m_type_counts;
381 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600382
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800383 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
384 vector<VkWriteDescriptorSet> m_writes;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600385
386 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500387 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600388 vk_testing::DescriptorSet *m_set;
389};
390
391
Tony Barbour01999182015-04-09 12:58:51 -0600392class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600393{
394public:
Tony Barbour8205d902015-04-16 15:59:00 -0600395 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600396 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600397
398protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600399 VkPipelineShaderStageCreateInfo stage_info;
400 VkShaderStage m_stage;
401 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600402
403};
404
Tony Barbour01999182015-04-09 12:58:51 -0600405class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600406{
407public:
Tony Barbour01999182015-04-09 12:58:51 -0600408 VkPipelineObj(VkDeviceObj *device);
409 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600410 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
411 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600412 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600413 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
414 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Chris Forbesdc2188c2015-05-25 11:13:26 +1200415 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600416
417protected:
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -0600418 VkPipelineVertexInputStateCreateInfo m_vi_state;
419 VkPipelineIaStateCreateInfo m_ia_state;
420 VkPipelineRsStateCreateInfo m_rs_state;
421 VkPipelineCbStateCreateInfo m_cb_state;
422 VkPipelineDsStateCreateInfo m_ds_state;
423 VkPipelineVpStateCreateInfo m_vp_state;
424 VkPipelineMsStateCreateInfo m_ms_state;
425 VkDeviceObj *m_device;
426 vector<VkShaderObj*> m_shaderObjs;
427 vector<VkConstantBufferObj*> m_vertexBufferObjs;
428 vector<int> m_vertexBufferBindings;
429 vector<VkPipelineCbAttachmentState> m_colorAttachments;
430 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600431};
432
433#endif // VKRENDERFRAMEWORK_H