blob: 7cabc34becb629759f56aa85c4c170e49f2e6246 [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;
Cody Northropf02f9f82015-07-09 18:08:05 -0600106 VkCmdPool m_cmdPool;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600107 VkCmdBuffer m_cmdBuffer;
108 VkRenderPass m_renderPass;
109 VkFramebuffer m_framebuffer;
Chia-I Wuc278df82015-07-07 11:50:03 +0800110 std::vector<VkClearValue> m_renderPassClearValues;
111 VkRenderPassBeginInfo m_renderPassBeginInfo;
Tony Barbourde4124d2015-07-03 10:33:54 -0600112 VkDynamicRasterState m_stateRaster;
113 VkDynamicColorBlendState m_colorBlend;
114 VkDynamicViewportState m_stateViewport;
115 VkDynamicDepthStencilState m_stateDepthStencil;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600116 vector<VkImageObj*> m_renderTargets;
117 float m_width, m_height;
118 VkFormat m_render_target_fmt;
119 VkFormat m_depth_stencil_fmt;
Chris Forbese3105972015-06-24 14:34:53 +1200120 VkClearColorValue m_clear_color;
Chris Forbes23e6db62015-06-15 09:32:35 +1200121 bool m_clear_via_load_op;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600122 float m_depth_clear_color;
123 uint32_t m_stencil_clear_color;
124 VkDepthStencilObj *m_depthStencil;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600125 PFN_vkDbgCreateMsgCallback m_dbgCreateMsgCallback;
Courtney Goeltzenleuchter18e8a492015-06-08 15:16:04 -0600126 PFN_vkDbgDestroyMsgCallback m_dbgDestroyMsgCallback;
Courtney Goeltzenleuchter23b5f8d2015-06-17 20:51:59 -0600127 VkDbgMsgCallback m_globalMsgCallback;
128 VkDbgMsgCallback m_devMsgCallback;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600129
130 /*
131 * SetUp and TearDown are called by the Google Test framework
132 * to initialize a test framework based on this class.
133 */
134 virtual void SetUp() {
135 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
136 this->app_info.pNext = NULL;
137 this->app_info.pAppName = "base";
138 this->app_info.appVersion = 1;
139 this->app_info.pEngineName = "unittest";
140 this->app_info.engineVersion = 1;
141 this->app_info.apiVersion = VK_API_VERSION;
142
143 InitFramework();
144 }
145
146 virtual void TearDown() {
147 ShutdownFramework();
148 }
149};
150
Tony Barbour01999182015-04-09 12:58:51 -0600151class VkDescriptorSetObj;
152class VkIndexBufferObj;
153class VkConstantBufferObj;
154class VkPipelineObj;
155class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600156
Tony Barbour01999182015-04-09 12:58:51 -0600157class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600158{
159public:
Tony Barbour01999182015-04-09 12:58:51 -0600160 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600161 VkCmdBuffer GetBufferHandle();
162 VkResult BeginCommandBuffer();
163 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600164 VkResult EndCommandBuffer();
Courtney Goeltzenleuchter82b348f2015-07-12 13:07:46 -0600165 void PipelineBarrier(VkPipelineStageFlags src_stages, VkPipelineStageFlags dest_stages, VkBool32 byRegion, uint32_t memBarrierCount, const void* const* ppMemBarriers);
Tony Barbour01999182015-04-09 12:58:51 -0600166 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600167 void AddDepthStencil();
Chris Forbese3105972015-06-24 14:34:53 +1200168 void ClearAllBuffers(VkClearColorValue clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600169 void PrepareAttachments();
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);
Chia-I Wuc278df82015-07-07 11:50:03 +0800174 void BeginRenderPass(const VkRenderPassBeginInfo &info);
Tony Barboure84a8d62015-07-10 14:10:27 -0600175 void BindDynamicViewportState(VkDynamicViewportState viewportState);
176 void BindDynamicRasterState(VkDynamicRasterState rasterState);
177 void BindDynamicColorBlendState(VkDynamicColorBlendState colorBlendState);
178 void BindDynamicDepthStencilState(VkDynamicDepthStencilState depthStencilState);
Chia-I Wu88eaa3b2015-06-26 15:34:39 +0800179 void EndRenderPass();
Tony Barboure389b882015-07-20 13:00:10 -0600180 void FillBuffer(VkBuffer buffer, VkDeviceSize offset, VkDeviceSize fill_size, uint32_t data);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
182 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
183 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600184 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600185
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600186protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600187 VkDeviceObj *m_device;
Courtney Goeltzenleuchterec561272015-07-13 12:57:11 -0600188 vk_testing::CmdPool m_cmdPool;
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600189 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600190};
191
Tony Barbour01999182015-04-09 12:58:51 -0600192class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600193{
194public:
Tony Barbour01999182015-04-09 12:58:51 -0600195 VkConstantBufferObj(VkDeviceObj *device);
196 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
197 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600198 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600199 VkFlags outputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600200 VK_MEMORY_OUTPUT_HOST_WRITE_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600201 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
202 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
203 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600204 VK_MEMORY_OUTPUT_TRANSFER_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600205 VkFlags inputMask =
Courtney Goeltzenleuchtera569a502015-04-29 17:16:21 -0600206 VK_MEMORY_INPUT_HOST_READ_BIT |
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600207 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
208 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
209 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
210 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
211 VK_MEMORY_INPUT_SHADER_READ_BIT |
212 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
213 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
Courtney Goeltzenleuchterad870812015-04-15 15:29:59 -0600214 VK_MEMORY_INPUT_TRANSFER_BIT);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600215
Tony Barbour8205d902015-04-16 15:59:00 -0600216 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600217
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800218 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600219
220protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600221 VkDeviceObj *m_device;
222 vk_testing::BufferView m_bufferView;
223 int m_numVertices;
224 int m_stride;
225 VkCommandBufferObj *m_commandBuffer;
226 vk_testing::Fence m_fence;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600227};
228
Tony Barbour01999182015-04-09 12:58:51 -0600229class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600230{
231public:
Tony Barbour01999182015-04-09 12:58:51 -0600232 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600233 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
Tony Barbour8205d902015-04-16 15:59:00 -0600234 void Bind(VkCmdBuffer cmdBuffer, VkDeviceSize offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600235 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600236
237protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600238 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600239};
240
Tony Barbour01999182015-04-09 12:58:51 -0600241class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600242{
243public:
Tony Barbour01999182015-04-09 12:58:51 -0600244 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600245 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600246
247public:
248 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600249 VkFormat fmt, VkFlags usage,
Tony Barbour94310562015-04-22 15:10:33 -0600250 VkImageTiling tiling=VK_IMAGE_TILING_LINEAR,
251 VkMemoryPropertyFlags reqs=0);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600252
253 // void clear( CommandBuffer*, uint32_t[4] );
254
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600255 void layout( VkImageLayout layout )
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600256 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800257 m_descriptorInfo.imageLayout = layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600258 }
259
Tony Barbour8205d902015-04-16 15:59:00 -0600260 VkDeviceMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600261 {
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800262 return Image::memory().handle();
263 }
264
265 void *MapMemory()
266 {
267 return Image::memory().map();
268 }
269
270 void UnmapMemory()
271 {
272 Image::memory().unmap();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600273 }
274
Tony Barbour01999182015-04-09 12:58:51 -0600275 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600276 VkImageAspect aspect,
277 VkFlags output_mask,
278 VkFlags input_mask,
279 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600280
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600281 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600282
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600283 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600284 {
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800285 return handle();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600286 }
287
Chia-I Wuc278df82015-07-07 11:50:03 +0800288 VkAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600289 {
290 if (!m_targetView.initialized())
291 {
Chia-I Wuc278df82015-07-07 11:50:03 +0800292 VkAttachmentViewCreateInfo createView = {
293 VK_STRUCTURE_TYPE_ATTACHMENT_VIEW_CREATE_INFO,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600294 VK_NULL_HANDLE,
Chia-I Wuf4aed6c2015-07-03 13:44:34 +0800295 handle(),
Tony Barbour8205d902015-04-16 15:59:00 -0600296 VK_FORMAT_B8G8R8A8_UNORM,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600297 0,
298 0,
299 1
300 };
301 m_targetView.init(*m_device, createView);
302 }
Chia-I Wu76ab1ff2015-07-03 11:49:42 +0800303 return m_targetView.handle();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600304 }
305
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600306 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
307 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600308
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600309 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600310 {
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800311 return m_descriptorInfo.imageLayout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600312 }
313 uint32_t width() const
314 {
315 return extent().width;
316 }
317 uint32_t height() const
318 {
319 return extent().height;
320 }
Tony Barbour01999182015-04-09 12:58:51 -0600321 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600322 {
323 return m_device;
324 }
325
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600326protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600327 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600328
Chia-I Wuc278df82015-07-07 11:50:03 +0800329 vk_testing::AttachmentView m_targetView;
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800330 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600331};
332
Tony Barbour01999182015-04-09 12:58:51 -0600333class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600334{
335public:
Tony Barbour01999182015-04-09 12:58:51 -0600336 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600337
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800338 VkDescriptorInfo m_descriptorInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600339
340protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600341 VkDeviceObj *m_device;
342 vk_testing::ImageView m_textureView;
343 VkDeviceSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600344};
345
Tony Barbour01999182015-04-09 12:58:51 -0600346class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600347{
348public:
Tony Barbour01999182015-04-09 12:58:51 -0600349 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600350
351protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600352 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600353
354};
355
Tony Barbour01999182015-04-09 12:58:51 -0600356class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600357{
358public:
Tony Barbour01999182015-04-09 12:58:51 -0600359 VkDescriptorSetObj(VkDeviceObj *device);
360 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600361
362 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600363 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600364 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
365 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600366
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600367 VkDescriptorSet GetDescriptorSetHandle() const;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500368 VkPipelineLayout GetPipelineLayout() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600369
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600370protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600371 VkDeviceObj *m_device;
372 vector<VkDescriptorTypeCount> m_type_counts;
373 int m_nextSlot;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600374
Chia-I Wu8cd8ecd2015-05-25 16:27:55 +0800375 vector<VkDescriptorInfo> m_imageSamplerDescriptors;
376 vector<VkWriteDescriptorSet> m_writes;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600377
378 vk_testing::DescriptorSetLayout m_layout;
Mark Lobodzinski556f7212015-04-17 14:11:39 -0500379 vk_testing::PipelineLayout m_pipeline_layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600380 vk_testing::DescriptorSet *m_set;
381};
382
383
Tony Barbour01999182015-04-09 12:58:51 -0600384class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600385{
386public:
Tony Barbour8205d902015-04-16 15:59:00 -0600387 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkShaderStage stage, VkRenderFramework *framework);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600388 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600389
390protected:
Courtney Goeltzenleuchterec69b9c2015-04-22 10:09:35 -0600391 VkPipelineShaderStageCreateInfo stage_info;
392 VkShaderStage m_stage;
393 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600394
395};
396
Tony Barbour01999182015-04-09 12:58:51 -0600397class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600398{
399public:
Tony Barbour01999182015-04-09 12:58:51 -0600400 VkPipelineObj(VkDeviceObj *device);
401 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600402 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
403 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600404 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Tony Barboure307f582015-07-10 15:29:03 -0600405 void AddColorAttachment(uint32_t binding, const VkPipelineColorBlendAttachmentState *att);
Chia-I Wuc278df82015-07-07 11:50:03 +0800406
407 void AddColorAttachment()
408 {
Tony Barboure307f582015-07-10 15:29:03 -0600409 VkPipelineColorBlendAttachmentState att = {};
Chia-I Wuc278df82015-07-07 11:50:03 +0800410 att.blendEnable = VK_FALSE;
411 att.channelWriteMask = 0xf;
412 AddColorAttachment(0, &att);
413 }
414
Tony Barboure307f582015-07-10 15:29:03 -0600415 void SetDepthStencil(VkPipelineDepthStencilStateCreateInfo *);
Chia-I Wuc278df82015-07-07 11:50:03 +0800416 VkResult CreateVKPipeline(VkDescriptorSetObj &descriptorSet, VkRenderPass render_pass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600417
418protected:
Tony Barboure307f582015-07-10 15:29:03 -0600419 VkPipelineVertexInputStateCreateInfo m_vi_state;
420 VkPipelineInputAssemblyStateCreateInfo m_ia_state;
421 VkPipelineRasterStateCreateInfo m_rs_state;
422 VkPipelineColorBlendStateCreateInfo m_cb_state;
423 VkPipelineDepthStencilStateCreateInfo m_ds_state;
424 VkPipelineViewportStateCreateInfo m_vp_state;
425 VkPipelineMultisampleStateCreateInfo m_ms_state;
426 VkDeviceObj *m_device;
427 vector<VkShaderObj*> m_shaderObjs;
428 vector<VkConstantBufferObj*> m_vertexBufferObjs;
429 vector<int> m_vertexBufferBindings;
430 vector<VkPipelineColorBlendAttachmentState> m_colorAttachments;
431 int m_vertexBufferCount;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600432};
433
434#endif // VKRENDERFRAMEWORK_H