blob: e4774a54f6cabd59c2b7d3370bcb65bb75bbfd73 [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"
32
33
Tony Barbour01999182015-04-09 12:58:51 -060034class VkDeviceObj : public vk_testing::Device
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060035{
36public:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060037 VkDeviceObj(uint32_t id, VkPhysicalGpu obj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060038
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060039 VkDevice device() { return obj(); }
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060040 void get_device_queue();
41
42 uint32_t id;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060043 VkPhysicalGpuProperties props;
44 const VkPhysicalGpuQueueProperties *queue_props;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060045
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060046 VkQueue m_queue;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060047};
48
Tony Barbour01999182015-04-09 12:58:51 -060049class VkMemoryRefManager
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060050{
51public:
52 void AddMemoryRefs(vk_testing::Object &vkObject);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060053 void AddMemoryRefs(vector<VkGpuMemory> mem);
54 void EmitAddMemoryRefs(VkQueue queue);
55 void EmitRemoveMemoryRefs(VkQueue queue);
56 vector<VkGpuMemory> mem_refs() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060057
58protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060059 vector<VkGpuMemory> mem_refs_;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060060
61};
62
Tony Barbour01999182015-04-09 12:58:51 -060063class VkDepthStencilObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060064{
65public:
Tony Barbour01999182015-04-09 12:58:51 -060066 VkDepthStencilObj();
67 void Init(VkDeviceObj *device, int32_t width, int32_t height);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060068 bool Initialized();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060069 VkDepthStencilBindInfo* BindInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060070
71protected:
Tony Barbour01999182015-04-09 12:58:51 -060072 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060073 bool m_initialized;
74 vk_testing::DepthStencilView m_depthStencilView;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060075 VkFormat m_depth_stencil_fmt;
76 VkDepthStencilBindInfo m_depthStencilBindInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060077};
78
Tony Barbour01999182015-04-09 12:58:51 -060079class VkRenderFramework : public VkTestFramework
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060080{
81public:
Tony Barbour01999182015-04-09 12:58:51 -060082 VkRenderFramework();
83 ~VkRenderFramework();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060084
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060085 VkDevice device() {return m_device->device();}
86 VkPhysicalGpu gpu() {return objs[0];}
87 VkRenderPass renderPass() {return m_renderPass;}
88 VkFramebuffer framebuffer() {return m_framebuffer;}
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060089 void InitViewport(float width, float height);
90 void InitViewport();
91 void InitRenderTarget();
92 void InitRenderTarget(uint32_t targets);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060093 void InitRenderTarget(VkDepthStencilBindInfo *dsBinding);
94 void InitRenderTarget(uint32_t targets, VkDepthStencilBindInfo *dsBinding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060095 void InitFramework();
96 void ShutdownFramework();
97 void InitState();
98
99
100protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600101 VkApplicationInfo app_info;
102 VkInstance inst;
103 VkPhysicalGpu objs[VK_MAX_PHYSICAL_GPUS];
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600104 uint32_t gpu_count;
Tony Barbour01999182015-04-09 12:58:51 -0600105 VkDeviceObj *m_device;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600106 VkCmdBuffer m_cmdBuffer;
107 VkRenderPass m_renderPass;
108 VkFramebuffer m_framebuffer;
109 VkDynamicRsStateObject m_stateRaster;
110 VkDynamicCbStateObject m_colorBlend;
111 VkDynamicVpStateObject m_stateViewport;
112 VkDynamicDsStateObject m_stateDepthStencil;
Tony Barbour01999182015-04-09 12:58:51 -0600113 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600114 float m_width, m_height;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600115 VkFormat m_render_target_fmt;
116 VkFormat m_depth_stencil_fmt;
117 VkColorAttachmentBindInfo m_colorBindings[8];
118 VkClearColor m_clear_color;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600119 float m_depth_clear_color;
120 uint32_t m_stencil_clear_color;
Tony Barbour01999182015-04-09 12:58:51 -0600121 VkDepthStencilObj *m_depthStencil;
122 VkMemoryRefManager m_mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600123
124 /*
125 * SetUp and TearDown are called by the Google Test framework
126 * to initialize a test framework based on this class.
127 */
128 virtual void SetUp() {
129 this->app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
130 this->app_info.pNext = NULL;
131 this->app_info.pAppName = "base";
132 this->app_info.appVersion = 1;
133 this->app_info.pEngineName = "unittest";
134 this->app_info.engineVersion = 1;
135 this->app_info.apiVersion = VK_API_VERSION;
136
137 InitFramework();
138 }
139
140 virtual void TearDown() {
141 ShutdownFramework();
142 }
143};
144
Tony Barbour01999182015-04-09 12:58:51 -0600145class VkDescriptorSetObj;
146class VkIndexBufferObj;
147class VkConstantBufferObj;
148class VkPipelineObj;
149class VkDescriptorSetObj;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600150
Tony Barbour01999182015-04-09 12:58:51 -0600151class VkCommandBufferObj : public vk_testing::CmdBuffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600152{
153public:
Tony Barbour01999182015-04-09 12:58:51 -0600154 VkCommandBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600155 VkCmdBuffer GetBufferHandle();
156 VkResult BeginCommandBuffer();
157 VkResult BeginCommandBuffer(VkCmdBufferBeginInfo *pInfo);
158 VkResult BeginCommandBuffer(VkRenderPass renderpass_obj, VkFramebuffer framebuffer_obj);
159 VkResult EndCommandBuffer();
160 void PipelineBarrier(VkPipelineBarrier *barrierPtr);
Tony Barbour01999182015-04-09 12:58:51 -0600161 void AddRenderTarget(VkImageObj *renderTarget);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600162 void AddDepthStencil();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600163 void ClearAllBuffers(VkClearColor clear_color, float depth_clear_color, uint32_t stencil_clear_color, VkDepthStencilObj *depthStencilObj);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600164 void PrepareAttachments();
165 void AddMemoryRefs(vk_testing::Object &vkObject);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600166 void AddMemoryRefs(uint32_t ref_count, const VkGpuMemory *mem);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600167 void AddMemoryRefs(vector<vk_testing::Object *> images);
Tony Barbour01999182015-04-09 12:58:51 -0600168 void BindPipeline(VkPipelineObj &pipeline);
169 void BindDescriptorSet(VkDescriptorSetObj &descriptorSet);
170 void BindVertexBuffer(VkConstantBufferObj *vertexBuffer, uint32_t offset, uint32_t binding);
171 void BindIndexBuffer(VkIndexBufferObj *indexBuffer, uint32_t offset);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600172 void BindStateObject(VkStateBindPoint stateBindPoint, VkDynamicStateObject stateObject);
173 void BeginRenderPass(VkRenderPass renderpass, VkFramebuffer framebuffer);
174 void EndRenderPass(VkRenderPass renderpass);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600175 void Draw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
176 void DrawIndexed(uint32_t firstIndex, uint32_t indexCount, int32_t vertexOffset, uint32_t firstInstance, uint32_t instanceCount);
177 void QueueCommandBuffer();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600178 void QueueCommandBuffer(VkFence fence);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600179
Tony Barbour01999182015-04-09 12:58:51 -0600180 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600181
182protected:
Tony Barbour01999182015-04-09 12:58:51 -0600183 VkDeviceObj *m_device;
184 vector<VkImageObj*> m_renderTargets;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600185};
186
Tony Barbour01999182015-04-09 12:58:51 -0600187class VkConstantBufferObj : public vk_testing::Buffer
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600188{
189public:
Tony Barbour01999182015-04-09 12:58:51 -0600190 VkConstantBufferObj(VkDeviceObj *device);
191 VkConstantBufferObj(VkDeviceObj *device, int constantCount, int constantSize, const void* data);
192 ~VkConstantBufferObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600193 void BufferMemoryBarrier(
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600194 VkFlags outputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600195 VK_MEMORY_OUTPUT_CPU_WRITE_BIT |
196 VK_MEMORY_OUTPUT_SHADER_WRITE_BIT |
197 VK_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT |
198 VK_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
199 VK_MEMORY_OUTPUT_COPY_BIT,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600200 VkFlags inputMask =
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600201 VK_MEMORY_INPUT_CPU_READ_BIT |
202 VK_MEMORY_INPUT_INDIRECT_COMMAND_BIT |
203 VK_MEMORY_INPUT_INDEX_FETCH_BIT |
204 VK_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT |
205 VK_MEMORY_INPUT_UNIFORM_READ_BIT |
206 VK_MEMORY_INPUT_SHADER_READ_BIT |
207 VK_MEMORY_INPUT_COLOR_ATTACHMENT_BIT |
208 VK_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT |
209 VK_MEMORY_INPUT_COPY_BIT);
210
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600211 void Bind(VkCmdBuffer cmdBuffer, VkGpuSize offset, uint32_t binding);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600212
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600213 VkBufferViewAttachInfo m_bufferViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600214
215protected:
Tony Barbour01999182015-04-09 12:58:51 -0600216 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600217 vk_testing::BufferView m_bufferView;
218 int m_numVertices;
219 int m_stride;
Tony Barbour01999182015-04-09 12:58:51 -0600220 VkCommandBufferObj *m_commandBuffer;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600221 vk_testing::Fence m_fence;
222};
223
Tony Barbour01999182015-04-09 12:58:51 -0600224class VkIndexBufferObj : public VkConstantBufferObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600225{
226public:
Tony Barbour01999182015-04-09 12:58:51 -0600227 VkIndexBufferObj(VkDeviceObj *device);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600228 void CreateAndInitBuffer(int numIndexes, VkIndexType dataFormat, const void* data);
229 void Bind(VkCmdBuffer cmdBuffer, VkGpuSize offset);
230 VkIndexType GetIndexType();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600231
232protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600233 VkIndexType m_indexType;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600234};
235
Tony Barbour01999182015-04-09 12:58:51 -0600236class VkImageObj : public vk_testing::Image
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600237{
238public:
Tony Barbour01999182015-04-09 12:58:51 -0600239 VkImageObj(VkDeviceObj *dev);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600240 bool IsCompatible(VkFlags usage, VkFlags features);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600241
242public:
243 void init(uint32_t w, uint32_t h,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600244 VkFormat fmt, VkFlags usage,
245 VkImageTiling tiling=VK_LINEAR_TILING);
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 {
251 m_imageInfo.layout = layout;
252 }
253
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600254 VkGpuMemory memory() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600255 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600256 const std::vector<VkGpuMemory> mems = memories();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600257 return mems.empty() ? VK_NULL_HANDLE : mems[0];
258 }
259
Tony Barbour01999182015-04-09 12:58:51 -0600260 void ImageMemoryBarrier(VkCommandBufferObj *cmd,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600261 VkImageAspect aspect,
262 VkFlags output_mask,
263 VkFlags input_mask,
264 VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600265
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600266 VkResult CopyImage(VkImageObj &src_image);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600267
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600268 VkImage image() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600269 {
270 return obj();
271 }
272
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600273 VkColorAttachmentView targetView()
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600274 {
275 if (!m_targetView.initialized())
276 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600277 VkColorAttachmentViewCreateInfo createView = {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600278 VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
279 VK_NULL_HANDLE,
280 obj(),
281 VK_FMT_B8G8R8A8_UNORM,
282 0,
283 0,
284 1
285 };
286 m_targetView.init(*m_device, createView);
287 }
288 return m_targetView.obj();
289 }
290
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600291 void SetLayout(VkCommandBufferObj *cmd_buf, VkImageAspect aspect, VkImageLayout image_layout);
292 void SetLayout(VkImageAspect aspect, VkImageLayout image_layout);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600293
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600294 VkImageLayout layout() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600295 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600296 return ( VkImageLayout )m_imageInfo.layout;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600297 }
298 uint32_t width() const
299 {
300 return extent().width;
301 }
302 uint32_t height() const
303 {
304 return extent().height;
305 }
Tony Barbour01999182015-04-09 12:58:51 -0600306 VkDeviceObj* device() const
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600307 {
308 return m_device;
309 }
310
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600311 VkResult MapMemory(void** ptr);
312 VkResult UnmapMemory();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600313
314protected:
Tony Barbour01999182015-04-09 12:58:51 -0600315 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600316
317 vk_testing::ColorAttachmentView m_targetView;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600318 VkImageViewAttachInfo m_imageInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600319};
320
Tony Barbour01999182015-04-09 12:58:51 -0600321class VkTextureObj : public VkImageObj
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600322{
323public:
Tony Barbour01999182015-04-09 12:58:51 -0600324 VkTextureObj(VkDeviceObj *device, uint32_t *colors = NULL);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600325 VkImageViewAttachInfo m_textureViewInfo;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600326
327
328protected:
Tony Barbour01999182015-04-09 12:58:51 -0600329 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600330 vk_testing::ImageView m_textureView;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600331 VkGpuSize m_rowPitch;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600332};
333
Tony Barbour01999182015-04-09 12:58:51 -0600334class VkSamplerObj : public vk_testing::Sampler
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600335{
336public:
Tony Barbour01999182015-04-09 12:58:51 -0600337 VkSamplerObj(VkDeviceObj *device);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600338
339protected:
Tony Barbour01999182015-04-09 12:58:51 -0600340 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600341
342};
343
Tony Barbour01999182015-04-09 12:58:51 -0600344class VkDescriptorSetObj : public vk_testing::DescriptorPool
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600345{
346public:
Tony Barbour01999182015-04-09 12:58:51 -0600347 VkDescriptorSetObj(VkDeviceObj *device);
348 ~VkDescriptorSetObj();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600349
350 int AppendDummy();
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600351 int AppendBuffer(VkDescriptorType type, VkConstantBufferObj &constantBuffer);
Tony Barbour01999182015-04-09 12:58:51 -0600352 int AppendSamplerTexture(VkSamplerObj* sampler, VkTextureObj* texture);
353 void CreateVKDescriptorSet(VkCommandBufferObj *cmdBuffer);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600354
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600355 VkDescriptorSet GetDescriptorSetHandle() const;
356 VkDescriptorSetLayoutChain GetLayoutChain() const;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600357
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600358 VkMemoryRefManager mem_ref_mgr;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600359
360protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600361 VkDeviceObj *m_device;
362 vector<VkDescriptorTypeCount> m_type_counts;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600363 int m_nextSlot;
364
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600365 vector<VkUpdateBuffers> m_updateBuffers;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600366
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600367 vector<VkSamplerImageViewInfo> m_samplerTextureInfo;
368 vector<VkUpdateSamplerTextures> m_updateSamplerTextures;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600369
370 vk_testing::DescriptorSetLayout m_layout;
371 vk_testing::DescriptorSetLayoutChain m_layout_chain;
372 vk_testing::DescriptorSet *m_set;
373};
374
375
Tony Barbour01999182015-04-09 12:58:51 -0600376class VkShaderObj : public vk_testing::Shader
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600377{
378public:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600379 VkShaderObj(VkDeviceObj *device, const char * shaderText, VkPipelineShaderStage stage, VkRenderFramework *framework);
380 VkPipelineShaderStageCreateInfo* GetStageCreateInfo();
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600381
382protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600383 VkPipelineShaderStageCreateInfo stage_info;
384 VkPipelineShaderStage m_stage;
Tony Barbour01999182015-04-09 12:58:51 -0600385 VkDeviceObj *m_device;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600386
387};
388
Tony Barbour01999182015-04-09 12:58:51 -0600389class VkPipelineObj : public vk_testing::Pipeline
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600390{
391public:
Tony Barbour01999182015-04-09 12:58:51 -0600392 VkPipelineObj(VkDeviceObj *device);
393 void AddShader(VkShaderObj* shaderObj);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600394 void AddVertexInputAttribs(VkVertexInputAttributeDescription* vi_attrib, int count);
395 void AddVertexInputBindings(VkVertexInputBindingDescription* vi_binding, int count);
Tony Barbour01999182015-04-09 12:58:51 -0600396 void AddVertexDataBuffer(VkConstantBufferObj* vertexDataBuffer, int binding);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600397 void AddColorAttachment(uint32_t binding, const VkPipelineCbAttachmentState *att);
398 void SetDepthStencil(VkPipelineDsStateCreateInfo *);
Tony Barbour01999182015-04-09 12:58:51 -0600399 void CreateVKPipeline(VkDescriptorSetObj &descriptorSet);
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600400
401protected:
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600402 VkPipelineVertexInputCreateInfo m_vi_state;
403 VkPipelineIaStateCreateInfo m_ia_state;
404 VkPipelineRsStateCreateInfo m_rs_state;
405 VkPipelineCbStateCreateInfo m_cb_state;
406 VkPipelineDsStateCreateInfo m_ds_state;
407 VkPipelineMsStateCreateInfo m_ms_state;
Tony Barbour01999182015-04-09 12:58:51 -0600408 VkDeviceObj *m_device;
409 vector<VkShaderObj*> m_shaderObjs;
410 vector<VkConstantBufferObj*> m_vertexBufferObjs;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600411 vector<int> m_vertexBufferBindings;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600412 vector<VkPipelineCbAttachmentState> m_colorAttachments;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600413 int m_vertexBufferCount;
414
415};
416
417#endif // VKRENDERFRAMEWORK_H