Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 1 | /* |
| 2 | * XGL 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 XGLRENDERFRAMEWORK_H |
| 29 | #define XGLRENDERFRAMEWORK_H |
| 30 | |
| 31 | #include "xgltestframework.h" |
Chia-I Wu | fb1459b | 2014-12-29 15:23:20 +0800 | [diff] [blame] | 32 | |
| 33 | class XglDevice : public xgl_testing::Device |
| 34 | { |
| 35 | public: |
| 36 | XglDevice(XGL_UINT id, XGL_PHYSICAL_GPU obj); |
| 37 | |
| 38 | XGL_DEVICE device() { return obj(); } |
| 39 | void get_device_queue(); |
| 40 | |
| 41 | XGL_UINT id; |
| 42 | XGL_PHYSICAL_GPU_PROPERTIES props; |
| 43 | const XGL_PHYSICAL_GPU_QUEUE_PROPERTIES *queue_props; |
| 44 | |
| 45 | XGL_QUEUE m_queue; |
| 46 | }; |
| 47 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 48 | |
| 49 | class XglRenderFramework : public XglTestFramework |
| 50 | { |
| 51 | public: |
| 52 | XglRenderFramework(); |
| 53 | ~XglRenderFramework(); |
| 54 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 55 | XGL_DEVICE device() {return m_device->device();} |
Tobin Ehlis | ca91587 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 56 | XGL_PHYSICAL_GPU gpu() {return objs[0];} |
Jon Ashburn | cdc40be | 2015-01-02 18:27:14 -0700 | [diff] [blame] | 57 | XGL_RENDER_PASS renderPass() {return m_renderPass;} |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 58 | void InitViewport(float width, float height); |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 59 | void InitViewport(); |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 60 | void InitRenderTarget(); |
| 61 | void InitFramework(); |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 62 | void ShutdownFramework(); |
| 63 | void InitState(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 64 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 65 | |
| 66 | protected: |
Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame^] | 67 | XGL_APPLICATION_INFO app_info; |
| 68 | XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS]; |
| 69 | XGL_UINT gpu_count; |
| 70 | XglDevice *m_device; |
| 71 | XGL_CMD_BUFFER m_cmdBuffer; |
| 72 | XGL_RENDER_PASS m_renderPass; |
| 73 | XGL_MEMORY_REF m_memRefs[5]; |
| 74 | XGL_DYNAMIC_RS_STATE_OBJECT m_stateRaster; |
| 75 | XGL_DYNAMIC_CB_STATE_OBJECT m_colorBlend; |
| 76 | XGL_DYNAMIC_VP_STATE_OBJECT m_stateViewport; |
| 77 | XGL_DYNAMIC_DS_STATE_OBJECT m_stateDepthStencil; |
| 78 | vector<XglImage*> m_renderTargets; |
| 79 | XGL_UINT m_renderTargetCount; |
| 80 | XGL_FLOAT m_width, m_height; |
| 81 | XGL_FORMAT m_render_target_fmt; |
| 82 | XGL_COLOR_ATTACHMENT_BIND_INFO m_colorBindings[8]; |
| 83 | XGL_DEPTH_STENCIL_BIND_INFO m_depthStencilBinding; |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * SetUp and TearDown are called by the Google Test framework |
| 87 | * to initialize a test framework based on this class. |
| 88 | */ |
| 89 | virtual void SetUp() { |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 90 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 91 | this->app_info.pNext = NULL; |
Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 92 | this->app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 93 | this->app_info.appVersion = 1; |
Chia-I Wu | f1a5a74 | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 94 | this->app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 95 | this->app_info.engineVersion = 1; |
| 96 | this->app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0); |
| 97 | |
Chia-I Wu | 8089cc1 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 98 | InitFramework(); |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | virtual void TearDown() { |
Chia-I Wu | 8089cc1 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 102 | ShutdownFramework(); |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 103 | } |
| 104 | }; |
| 105 | |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 106 | class XglIndexBufferObj; |
| 107 | class XglConstantBufferObj; |
| 108 | |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 109 | class XglCommandBufferObj : xgl_testing::CmdBuffer |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 110 | { |
| 111 | public: |
| 112 | XglCommandBufferObj(XglDevice *device); |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 113 | XGL_CMD_BUFFER GetBufferHandle(); |
Jon Ashburn | c4164b1 | 2014-12-31 17:10:47 -0700 | [diff] [blame] | 114 | XGL_RESULT BeginCommandBuffer(XGL_CMD_BUFFER_BEGIN_INFO *pInfo); |
Jeremy Hayes | d65ae08 | 2015-01-14 16:17:08 -0700 | [diff] [blame] | 115 | XGL_RESULT BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj); |
| 116 | XGL_RESULT BeginCommandBuffer(); |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 117 | XGL_RESULT EndCommandBuffer(); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 118 | void PrepareBufferRegions(int transitionCount, XGL_BUFFER_STATE_TRANSITION *transitionPtr); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 119 | void AddRenderTarget(XglImage *renderTarget); |
| 120 | void AddDepthStencil(); |
| 121 | void ClearAllBuffers(); |
| 122 | void ClearAllBuffers(XGL_DEPTH_STENCIL_BIND_INFO *depthStencilBinding, XGL_IMAGE depthStencilImage); |
Jon Ashburn | cdc40be | 2015-01-02 18:27:14 -0700 | [diff] [blame] | 123 | void PrepareAttachments(); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 124 | void BindPipeline(XGL_PIPELINE pipeline); |
| 125 | void BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet); |
| 126 | void BindVertexBuffer(XglConstantBufferObj *vertexBuffer, XGL_UINT offset, XGL_UINT binding); |
| 127 | void BindIndexBuffer(XglIndexBufferObj *indexBuffer, XGL_UINT offset); |
Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame^] | 128 | void BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 129 | void Draw(XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount); |
| 130 | void DrawIndexed(XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount); |
| 131 | void QueueCommandBuffer(XGL_MEMORY_REF *memRefs, XGL_UINT32 numMemRefs); |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 132 | |
| 133 | protected: |
| 134 | XglDevice *m_device; |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 135 | vector<XglImage*> m_renderTargets; |
| 136 | XGL_UINT m_renderTargetCount; |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 137 | |
| 138 | }; |
| 139 | |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 140 | class XglConstantBufferObj : public xgl_testing::Buffer |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 141 | { |
| 142 | public: |
Courtney Goeltzenleuchter | 3b0a815 | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 143 | XglConstantBufferObj(XglDevice *device); |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 144 | XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 145 | void SetBufferState(XGL_BUFFER_STATE newState); |
Courtney Goeltzenleuchter | 3764030 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 146 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset, XGL_UINT binding); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 147 | |
| 148 | XGL_BUFFER_VIEW_ATTACH_INFO m_bufferViewInfo; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 149 | |
| 150 | protected: |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 151 | XglDevice *m_device; |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 152 | xgl_testing::BufferView m_bufferView; |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 153 | int m_numVertices; |
| 154 | int m_stride; |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 155 | XglCommandBufferObj *m_commandBuffer; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 156 | xgl_testing::Fence m_fence; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 157 | }; |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 158 | |
| 159 | class XglIndexBufferObj : public XglConstantBufferObj |
| 160 | { |
| 161 | public: |
| 162 | XglIndexBufferObj(XglDevice *device); |
| 163 | void CreateAndInitBuffer(int numIndexes, XGL_INDEX_TYPE dataFormat, const void* data); |
| 164 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset); |
Tony Barbour | af1f919 | 2014-12-17 10:57:58 -0700 | [diff] [blame] | 165 | XGL_INDEX_TYPE GetIndexType(); |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 166 | |
| 167 | protected: |
| 168 | XGL_INDEX_TYPE m_indexType; |
| 169 | }; |
| 170 | |
Chia-I Wu | a6bc0ce | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 171 | class XglImage : public xgl_testing::Image |
| 172 | { |
| 173 | public: |
| 174 | XglImage(XglDevice *dev); |
| 175 | |
| 176 | // Image usage flags |
| 177 | // typedef enum _XGL_IMAGE_USAGE_FLAGS |
| 178 | // { |
| 179 | // XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001, |
| 180 | // XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002, |
| 181 | // XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004, |
| 182 | // XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008, |
| 183 | // } XGL_IMAGE_USAGE_FLAGS; |
| 184 | public: |
| 185 | void init( XGL_UINT32 w, XGL_UINT32 h, |
| 186 | XGL_FORMAT fmt, XGL_FLAGS usage, |
| 187 | XGL_IMAGE_TILING tiling=XGL_LINEAR_TILING); |
| 188 | |
| 189 | // void clear( CommandBuffer*, XGL_UINT[4] ); |
| 190 | // void prepare( CommandBuffer*, XGL_IMAGE_STATE ); |
| 191 | |
| 192 | void state( XGL_IMAGE_STATE state ) |
| 193 | { |
| 194 | m_imageInfo.state = state; |
| 195 | } |
| 196 | XGL_GPU_MEMORY memory() const |
| 197 | { |
| 198 | const std::vector<XGL_GPU_MEMORY> mems = memories(); |
| 199 | return mems.empty() ? XGL_NULL_HANDLE : mems[0]; |
| 200 | } |
| 201 | |
| 202 | |
| 203 | XGL_IMAGE image() const |
| 204 | { |
| 205 | return obj(); |
| 206 | } |
| 207 | XGL_COLOR_ATTACHMENT_VIEW targetView()const |
| 208 | { |
| 209 | return m_targetView.obj(); |
| 210 | } |
| 211 | |
| 212 | XGL_IMAGE_STATE state() const |
| 213 | { |
| 214 | return ( XGL_IMAGE_STATE )m_imageInfo.state; |
| 215 | } |
| 216 | XGL_UINT32 width() const |
| 217 | { |
| 218 | return extent().width; |
| 219 | } |
| 220 | XGL_UINT32 height() const |
| 221 | { |
| 222 | return extent().height; |
| 223 | } |
| 224 | |
| 225 | XGL_RESULT MapMemory(XGL_VOID** ptr); |
| 226 | XGL_RESULT UnmapMemory(); |
| 227 | |
| 228 | protected: |
| 229 | XglDevice *m_device; |
| 230 | |
| 231 | xgl_testing::ColorAttachmentView m_targetView; |
| 232 | XGL_IMAGE_VIEW_ATTACH_INFO m_imageInfo; |
| 233 | }; |
| 234 | |
Chia-I Wu | 13a3aa8 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 235 | class XglTextureObj : public xgl_testing::Image |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 236 | { |
| 237 | public: |
| 238 | XglTextureObj(XglDevice *device); |
Tony Barbour | d1b1bd1 | 2014-11-21 17:17:49 -0700 | [diff] [blame] | 239 | void ChangeColors(uint32_t color1, uint32_t color2); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 240 | XGL_IMAGE_VIEW_ATTACH_INFO m_textureViewInfo; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 241 | |
| 242 | protected: |
| 243 | XglDevice *m_device; |
Chia-I Wu | 13a3aa8 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 244 | xgl_testing::ImageView m_textureView; |
| 245 | XGL_GPU_SIZE m_rowPitch; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 246 | }; |
| 247 | |
Chia-I Wu | e9864b5 | 2014-12-28 16:32:24 +0800 | [diff] [blame] | 248 | class XglSamplerObj : public xgl_testing::Sampler |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 249 | { |
| 250 | public: |
| 251 | XglSamplerObj(XglDevice *device); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 252 | |
| 253 | protected: |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 254 | XglDevice *m_device; |
| 255 | |
| 256 | }; |
| 257 | |
Chia-I Wu | ac0f1e7 | 2014-12-28 22:32:36 +0800 | [diff] [blame] | 258 | class XglDescriptorSetObj : public xgl_testing::DescriptorSet |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 259 | { |
| 260 | public: |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 261 | XglDescriptorSetObj(XglDevice *device); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 262 | void AttachBufferView(XglConstantBufferObj* constantBuffer); |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 263 | void AttachSampler( XglSamplerObj* sampler); |
| 264 | void AttachImageView( XglTextureObj* texture); |
| 265 | void BindCommandBuffer(XGL_CMD_BUFFER commandBuffer); |
Tony Barbour | b5f4d08 | 2014-12-17 10:54:03 -0700 | [diff] [blame] | 266 | void CreateXGLDescriptorSet(); |
| 267 | XGL_DESCRIPTOR_SET GetDescriptorSetHandle(); |
Tony Barbour | 824b771 | 2014-12-18 17:06:21 -0700 | [diff] [blame] | 268 | int GetTotalSlots(); |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 269 | XGL_DESCRIPTOR_SLOT_INFO * GetSlotInfo(vector<int>slots, vector<XGL_DESCRIPTOR_SET_SLOT_TYPE>types, vector<void*>objs ); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 270 | |
| 271 | protected: |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 272 | XglDevice *m_device; |
| 273 | XGL_DESCRIPTOR_SLOT_INFO *m_slotInfo; |
| 274 | int m_nextSlot; |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 275 | vector<int> m_bufferSlots; |
| 276 | vector<XGL_BUFFER_VIEW_ATTACH_INFO*> m_bufferViews; |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 277 | vector<int> m_samplerSlots; |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 278 | vector<XglSamplerObj*> m_samplers; |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 279 | vector<int> m_imageSlots; |
| 280 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageViews; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 281 | }; |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 282 | |
| 283 | |
Chia-I Wu | babc0fd | 2014-12-29 14:14:03 +0800 | [diff] [blame] | 284 | class XglShaderObj : public xgl_testing::Shader |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 285 | { |
| 286 | public: |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 287 | XglShaderObj(XglDevice *device, const char * shaderText, XGL_PIPELINE_SHADER_STAGE stage, XglRenderFramework *framework); |
Tony Barbour | 5420af0 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 288 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* GetStageCreateInfo(XglDescriptorSetObj *descriptorSet); |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 289 | void BindShaderEntitySlotToBuffer(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer); |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 290 | void BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture); |
| 291 | void BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 292 | |
| 293 | protected: |
| 294 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO stage_info; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 295 | XGL_PIPELINE_SHADER_STAGE m_stage; |
| 296 | XglDevice *m_device; |
Chia-I Wu | 1a28fe0 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 297 | vector<int> m_bufferSlots; |
| 298 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_bufferTypes; |
| 299 | vector<XGL_BUFFER_VIEW_ATTACH_INFO*> m_bufferObjs; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 300 | vector<int> m_samplerSlots; |
| 301 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_samplerTypes; |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 302 | vector<XglSamplerObj*> m_samplerObjs; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 303 | vector<int> m_imageSlots; |
| 304 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_imageTypes; |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 305 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageObjs; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 306 | |
| 307 | }; |
| 308 | |
Chia-I Wu | 2648d09 | 2014-12-29 14:24:14 +0800 | [diff] [blame] | 309 | class XglPipelineObj : public xgl_testing::Pipeline |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 310 | { |
| 311 | public: |
| 312 | XglPipelineObj(XglDevice *device); |
Tony Barbour | 5420af0 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 313 | void BindPipelineCommandBuffer(XGL_CMD_BUFFER m_cmdBuffer, XglDescriptorSetObj *descriptorSet); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 314 | void AddShader(XglShaderObj* shaderObj); |
| 315 | void AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count); |
| 316 | void AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count); |
| 317 | void AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding); |
Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame^] | 318 | void AddColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att); |
| 319 | void SetDepthStencil(XGL_PIPELINE_DS_STATE_CREATE_INFO *); |
Tony Barbour | 976e1cf | 2014-12-17 11:57:31 -0700 | [diff] [blame] | 320 | void CreateXGLPipeline(XglDescriptorSetObj *descriptorSet); |
| 321 | XGL_PIPELINE GetPipelineHandle(); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 322 | |
| 323 | protected: |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 324 | XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO m_vi_state; |
| 325 | XGL_PIPELINE_IA_STATE_CREATE_INFO m_ia_state; |
| 326 | XGL_PIPELINE_RS_STATE_CREATE_INFO m_rs_state; |
Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame^] | 327 | XGL_PIPELINE_CB_STATE_CREATE_INFO m_cb_state; |
| 328 | XGL_PIPELINE_DS_STATE_CREATE_INFO m_ds_state; |
| 329 | XGL_PIPELINE_MS_STATE_CREATE_INFO m_ms_state; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 330 | XglDevice *m_device; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 331 | vector<XglShaderObj*> m_shaderObjs; |
| 332 | vector<XglConstantBufferObj*> m_vertexBufferObjs; |
| 333 | vector<int> m_vertexBufferBindings; |
Tony Barbour | f52346d | 2015-01-16 14:27:35 -0700 | [diff] [blame^] | 334 | vector<XGL_PIPELINE_CB_ATTACHMENT_STATE> m_colorAttachments; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 335 | int m_vertexBufferCount; |
| 336 | |
| 337 | }; |
| 338 | class XglMemoryRefManager{ |
| 339 | public: |
| 340 | XglMemoryRefManager(); |
Tony Barbour | ac3692c | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 341 | void AddMemoryRef(XglConstantBufferObj* constantBuffer); |
| 342 | void AddMemoryRef(XglTextureObj *texture); |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 343 | XGL_MEMORY_REF* GetMemoryRefList(); |
| 344 | int GetNumRefs(); |
| 345 | |
| 346 | protected: |
| 347 | int m_numRefs; |
Chia-I Wu | 283d7a6 | 2014-12-28 15:43:42 +0800 | [diff] [blame] | 348 | vector<XGL_GPU_MEMORY> m_bufferObjs; |
Tony Barbour | 9d951a0 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 349 | |
| 350 | }; |
| 351 | |
| 352 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 353 | #endif // XGLRENDERFRAMEWORK_H |