blob: a692cda593f144fe820b006b58323560c9a5aeb6 [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
Chia-I Wua2636292015-07-03 10:41:20 +080044 VkDevice device() { return handle(); }
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 VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060055{
56public:
Tony Barbour01999182015-04-09 12:58:51 -060057 VkDepthStencilObj();
Chia-I Wuc278df82015-07-07 11:50:03 +080058 void Init(VkDeviceObj *device, int32_t width, int32_t height, VkFormat format);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060059 bool Initialized();
Chia-I Wuc278df82015-07-07 11:50:03 +080060 VkAttachmentBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060061
62protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060063 VkDeviceObj *m_device;
64 bool m_initialized;
Chia-I Wuc278df82015-07-07 11:50:03 +080065 vk_testing::AttachmentView m_attachmentView;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -060066 VkFormat m_depth_stencil_fmt;
Chia-I Wuc278df82015-07-07 11:50:03 +080067 VkAttachmentBindInfo m_attachmentBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060068};
69
Tony Barbour01999182015-04-09 12:58:51 -060070class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060071{
72public:
Tony Barbour01999182015-04-09 12:58:51 -060073 VkRenderFramework();
74 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060075
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060076 VkDevice device() {return m_device->device();}
Tony Barbour8205d902015-04-16 15:59:00 -060077 VkPhysicalDevice gpu() {return objs[0];}
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060078 VkRenderPass renderPass() {return m_renderPass;}
79 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060080 void InitViewport(float width, float height);
81 void InitViewport();
82 void InitRenderTarget();
83 void InitRenderTarget(uint32_t targets);
Chia-I Wuc278df82015-07-07 11:50:03 +080084 void InitRenderTarget(VkAttachmentBindInfo *dsBinding);
85 void InitRenderTarget(uint32_t targets, VkAttachmentBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060086 void InitFramework();
Courtney Goeltzenleuchterf5c61952015-07-06 09:10:47 -060087 void InitFramework(
88 std::vector<const char *> instance_layer_names,
89 std::vector<const char *> device_layer_names,
90 std::vector<const char *> instance_extension_names,
91 std::vector<const char *> device_extension_names,
92 PFN_vkDbgMsgCallback=NULL,
93 void *userData=NULL);
94
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060095 void ShutdownFramework();
96 void InitState();
97
Chia-I Wuc278df82015-07-07 11:50:03 +080098 const VkRenderPassBeginInfo &renderPassBeginInfo() const { return m_renderPassBeginInfo; }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060099
100protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600101 VkApplicationInfo app_info;
102 VkInstance inst;
103 VkPhysicalDevice objs[16];
104 uint32_t gpu_count;
105 VkDeviceObj *m_device;
106 VkCmdBuffer m_cmdBuffer;
107 VkRenderPass m_renderPass;
108 VkFramebuffer m_framebuffer;
Chia-I Wuc278df82015-07-07 11:50:03 +0800109 std::vector<VkClearValue> m_renderPassClearValues;
110 VkRenderPassBeginInfo m_renderPassBeginInfo;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600111 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;
Chris Forbese3105972015-06-24 14:34:53 +1200119 VkClearColorValue m_clear_color;
Chris Forbes23e6db62015-06-15 09:32:35 +1200120 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600121 float m_depth_clear_color;
122 uint32_t m_stencil_clear_color;
123 VkDepthStencilObj *m_depthStencil;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600124 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
Courtney Goeltzenleuchter18e8a492015-06-08 15:16:04 -0600125 PFN_vkDbgDestroyMsgCallback m_dbgDestroyMsgCallback;
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600126 VkDbgMsgCallback m_globalMsgCallback;
127 VkDbgMsgCallback m_devMsgCallback;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600128
129 /*
130 * SetUp and TearDown are called by the Google Test framework
131 * to initialize a test framework based on this class.
132 */
133 virtual void SetUp() {
134 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
135 this->app_info.pNext = NULL;
136 this->app_info.pAppName = "base";
137 this->app_info.appVersion = 1;
138 this->app_info.pEngineName = "unittest";
139 this->app_info.engineVersion = 1;
140 this->app_info.apiVersion = VK_API_VERSION;
141
142 InitFramework();
143 }
144
145 virtual void TearDown() {
146 ShutdownFramework();
147 }
148};
149
Tony Barbour01999182015-04-09 12:58:51 -0600150class VkDescriptorSetObj;
151class VkIndexBufferObj;
152class VkConstantBufferObj;
153class VkPipelineObj;
154class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600155
Tony Barbour01999182015-04-09 12:58:51 -0600156class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600157{
158public:
Tony Barbour01999182015-04-09 12:58:51 -0600159 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600160 VkCmdBuffer GetBufferHandle();
161 VkResult BeginCommandBuffer();
162 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600163 VkResult EndCommandBuffer();
Courtney Goeltzenleuchter1f41f542015-07-09 11:44:38 -0600164 void PipelineBarrier(VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages, VkBool32 byRegion, uint32_t memBarrierCount, const void** ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600165 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600166 void AddDepthStencil();
Chris Forbese3105972015-06-24 14:34:53 +1200167 void ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600168 void PrepareAttachments();
Tony Barbour01999182015-04-09 12:58:51 -0600169 void BindPipeline(VkPipelineObj &pipeline);
170 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
Tony Barbour8205d902015-04-16 15:59:00 -0600171 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, VkDeviceSize offset, uint32_t binding);
Tony Barbour01999182015-04-09 12:58:51 -0600172 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600173 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
Chia-I Wuc278df82015-07-07 11:50:03 +0800174 void BeginRenderPass(const VkRenderPassBeginInfo &info);
Chia-I Wu88eaa3b2015-06-26 15:34:39 +0800175 void EndRenderPass();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600176 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
177 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
178 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600179 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600180
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600182 VkDeviceObj *m_device;
183 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600184};
185
Tony Barbour01999182015-04-09 12:58:51 -0600186class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600187{
188public:
Tony Barbour01999182015-04-09 12:58:51 -0600189 VkConstantBufferObj(VkDeviceObj *device);
190 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
191 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600192 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600193 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600194 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600195 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
196 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
197 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600198 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600199 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600200 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600201 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
202 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
203 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
204 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
205 VK_MEMORY_INPUT_SHADER_READ_BIT |
206 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
207 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600208 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600209
Tony Barbour8205d902015-04-16 15:59:00 -0600210 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600211
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800212 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600213
214protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600215 VkDeviceObj *m_device;
216 vk_testing::BufferView m_bufferView;
217 int m_numVertices;
218 int m_stride;
219 VkCommandBufferObj *m_commandBuffer;
220 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600221};
222
Tony Barbour01999182015-04-09 12:58:51 -0600223class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600224{
225public:
Tony Barbour01999182015-04-09 12:58:51 -0600226 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600227 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600228 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600229 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600230
231protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600232 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600233};
234
Tony Barbour01999182015-04-09 12:58:51 -0600235class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600236{
237public:
Tony Barbour01999182015-04-09 12:58:51 -0600238 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600239 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600240
241public:
242 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600243 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600244 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
245 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600246
247 // void clear( CommandBuffer*, uint32_t[4] );
248
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600249 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600250 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800251 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600252 }
253
Tony Barbour8205d902015-04-16 15:59:00 -0600254 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600255 {
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800256 return Image::memory().handle();
257 }
258
259 void *MapMemory()
260 {
261 return Image::memory().map();
262 }
263
264 void UnmapMemory()
265 {
266 Image::memory().unmap();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600267 }
268
Tony Barbour01999182015-04-09 12:58:51 -0600269 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600270 VkImageAspect aspect,
271 VkFlags output_mask,
272 VkFlags input_mask,
273 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600274
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600275 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600276
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600277 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600278 {
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800279 return handle();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600280 }
281
Chia-I Wuc278df82015-07-07 11:50:03 +0800282 VkAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600283 {
284 if (!m_targetView.initialized())
285 {
Chia-I Wuc278df82015-07-07 11:50:03 +0800286 VkAttachmentViewCreateInfo createView = {
287 VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600288 VK_NULL_HANDLE,
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800289 handle(),
Tony Barbour8205d902015-04-16 15:59:00 -0600290 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600291 0,
292 0,
293 1
294 };
295 m_targetView.init(*m_device, createView);
296 }
Chia-I Wu76ab1ff2015-07-03 11:49:42 +0800297 return m_targetView.handle();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600298 }
299
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600300 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
301 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600302
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600303 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600304 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800305 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600306 }
307 uint32_t width() const
308 {
309 return extent().width;
310 }
311 uint32_t height() const
312 {
313 return extent().height;
314 }
Tony Barbour01999182015-04-09 12:58:51 -0600315 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600316 {
317 return m_device;
318 }
319
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600320protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600321 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600322
Chia-I Wuc278df82015-07-07 11:50:03 +0800323 vk_testing::AttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800324 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600325};
326
Tony Barbour01999182015-04-09 12:58:51 -0600327class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328{
329public:
Tony Barbour01999182015-04-09 12:58:51 -0600330 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800332 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600333
334protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600335 VkDeviceObj *m_device;
336 vk_testing::ImageView m_textureView;
337 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600338};
339
Tony Barbour01999182015-04-09 12:58:51 -0600340class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600341{
342public:
Tony Barbour01999182015-04-09 12:58:51 -0600343 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600344
345protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600346 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600347
348};
349
Tony Barbour01999182015-04-09 12:58:51 -0600350class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600351{
352public:
Tony Barbour01999182015-04-09 12:58:51 -0600353 VkDescriptorSetObj(VkDeviceObj *device);
354 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600355
356 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600357 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600358 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
359 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600360
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600361 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500362 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600363
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600364protected:
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);
Chia-I Wuc278df82015-07-07 11:50:03 +0800400
401 void AddColorAttachment()
402 {
403 VkPipelineCbAttachmentState att = {};
404 att.blendEnable = VK_FALSE;
405 att.channelWriteMask = 0xf;
406 AddColorAttachment(0, &att);
407 }
408
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600409 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Chia-I Wuc278df82015-07-07 11:50:03 +0800410 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet, VkRenderPass render_pass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600411
412protected:
Mark Lobodzinski0e0fb5c2015-06-23 15:11:57 -0600413 VkPipelineVertexInputStateCreateInfo m_vi_state;
414 VkPipelineIaStateCreateInfo m_ia_state;
415 VkPipelineRsStateCreateInfo m_rs_state;
416 VkPipelineCbStateCreateInfo m_cb_state;
417 VkPipelineDsStateCreateInfo m_ds_state;
418 VkPipelineVpStateCreateInfo m_vp_state;
419 VkPipelineMsStateCreateInfo m_ms_state;
420 VkDeviceObj *m_device;
421 vector<VkShaderObj*> m_shaderObjs;
422 vector<VkConstantBufferObj*> m_vertexBufferObjs;
423 vector<int> m_vertexBufferBindings;
424 vector<VkPipelineCbAttachmentState> m_colorAttachments;
425 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600426};
427
428#endif // VKRENDERFRAMEWORK_H