Courtney Goeltzenleuchter | 5744b97 | 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 | 234a0ae | 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 | 5744b97 | 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 | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 55 | XGL_DEVICE device() {return m_device->device();} |
Tobin Ehlis | 3c26a54 | 2014-11-18 11:28:33 -0700 | [diff] [blame] | 56 | XGL_PHYSICAL_GPU gpu() {return objs[0];} |
Jon Ashburn | 85b3cb3 | 2015-01-02 18:27:14 -0700 | [diff] [blame] | 57 | XGL_RENDER_PASS renderPass() {return m_renderPass;} |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 58 | void InitViewport(float width, float height); |
Courtney Goeltzenleuchter | e540934 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 59 | void InitViewport(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 60 | void InitRenderTarget(); |
| 61 | void InitFramework(); |
Courtney Goeltzenleuchter | cb5a89c | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 62 | void ShutdownFramework(); |
| 63 | void InitState(); |
Tony Barbour | f43b698 | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 64 | |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 65 | |
| 66 | protected: |
Tony Barbour | fa6cac7 | 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 | 5744b97 | 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 | 5744b97 | 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 | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 92 | this->app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 93 | this->app_info.appVersion = 1; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 94 | this->app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | 5744b97 | 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 | 48580a8 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 98 | InitFramework(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | virtual void TearDown() { |
Chia-I Wu | 48580a8 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 102 | ShutdownFramework(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 103 | } |
| 104 | }; |
| 105 | |
Tony Barbour | 1d7a55d | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 106 | class XglIndexBufferObj; |
| 107 | class XglConstantBufferObj; |
| 108 | |
Chia-I Wu | ae0564f | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 109 | class XglCommandBufferObj : xgl_testing::CmdBuffer |
Tony Barbour | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 110 | { |
| 111 | public: |
| 112 | XglCommandBufferObj(XglDevice *device); |
Tony Barbour | e8f1416 | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 113 | XGL_CMD_BUFFER GetBufferHandle(); |
Jon Ashburn | 744b8cf | 2014-12-31 17:10:47 -0700 | [diff] [blame] | 114 | XGL_RESULT BeginCommandBuffer(XGL_CMD_BUFFER_BEGIN_INFO *pInfo); |
Jeremy Hayes | e0c3b22 | 2015-01-14 16:17:08 -0700 | [diff] [blame] | 115 | XGL_RESULT BeginCommandBuffer(XGL_RENDER_PASS renderpass_obj); |
| 116 | XGL_RESULT BeginCommandBuffer(); |
Tony Barbour | e8f1416 | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 117 | XGL_RESULT EndCommandBuffer(); |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 118 | void PipelineBarrier(XGL_PIPELINE_BARRIER *barrierPtr); |
Tony Barbour | 1d7a55d | 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 | 85b3cb3 | 2015-01-02 18:27:14 -0700 | [diff] [blame] | 123 | void PrepareAttachments(); |
Tony Barbour | 1d7a55d | 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 | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 128 | void BindStateObject(XGL_STATE_BIND_POINT stateBindPoint, XGL_DYNAMIC_STATE_OBJECT stateObject); |
Tony Barbour | 1d7a55d | 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 | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 132 | |
| 133 | protected: |
| 134 | XglDevice *m_device; |
Tony Barbour | 1d7a55d | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 135 | vector<XglImage*> m_renderTargets; |
| 136 | XGL_UINT m_renderTargetCount; |
Tony Barbour | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 137 | |
| 138 | }; |
| 139 | |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 140 | class XglConstantBufferObj : public xgl_testing::Buffer |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 141 | { |
| 142 | public: |
Courtney Goeltzenleuchter | ea2db0d | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 143 | XglConstantBufferObj(XglDevice *device); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 144 | XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data); |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 145 | void BufferMemoryBarrier( |
| 146 | XGL_FLAGS outputMask = |
| 147 | XGL_MEMORY_OUTPUT_CPU_WRITE_BIT | |
| 148 | XGL_MEMORY_OUTPUT_SHADER_WRITE_BIT | |
| 149 | XGL_MEMORY_OUTPUT_COLOR_ATTACHMENT_BIT | |
| 150 | XGL_MEMORY_OUTPUT_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 151 | XGL_MEMORY_OUTPUT_COPY_BIT, |
| 152 | XGL_FLAGS inputMask = |
| 153 | XGL_MEMORY_INPUT_CPU_READ_BIT | |
| 154 | XGL_MEMORY_INPUT_INDIRECT_COMMAND_BIT | |
| 155 | XGL_MEMORY_INPUT_INDEX_FETCH_BIT | |
| 156 | XGL_MEMORY_INPUT_VERTEX_ATTRIBUTE_FETCH_BIT | |
| 157 | XGL_MEMORY_INPUT_UNIFORM_READ_BIT | |
| 158 | XGL_MEMORY_INPUT_SHADER_READ_BIT | |
| 159 | XGL_MEMORY_INPUT_COLOR_ATTACHMENT_BIT | |
| 160 | XGL_MEMORY_INPUT_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 161 | XGL_MEMORY_INPUT_COPY_BIT); |
| 162 | |
Courtney Goeltzenleuchter | 7715bc4 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 163 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset, XGL_UINT binding); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 164 | |
| 165 | XGL_BUFFER_VIEW_ATTACH_INFO m_bufferViewInfo; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 166 | |
| 167 | protected: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 168 | XglDevice *m_device; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 169 | xgl_testing::BufferView m_bufferView; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 170 | int m_numVertices; |
| 171 | int m_stride; |
Tony Barbour | 9f47dc7 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 172 | XglCommandBufferObj *m_commandBuffer; |
Chia-I Wu | 67ee00f | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 173 | xgl_testing::Fence m_fence; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 174 | }; |
Courtney Goeltzenleuchter | fa834c9 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 175 | |
| 176 | class XglIndexBufferObj : public XglConstantBufferObj |
| 177 | { |
| 178 | public: |
| 179 | XglIndexBufferObj(XglDevice *device); |
| 180 | void CreateAndInitBuffer(int numIndexes, XGL_INDEX_TYPE dataFormat, const void* data); |
| 181 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset); |
Tony Barbour | 140a59f | 2014-12-17 10:57:58 -0700 | [diff] [blame] | 182 | XGL_INDEX_TYPE GetIndexType(); |
Courtney Goeltzenleuchter | fa834c9 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 183 | |
| 184 | protected: |
| 185 | XGL_INDEX_TYPE m_indexType; |
| 186 | }; |
| 187 | |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 188 | class XglImage : public xgl_testing::Image |
| 189 | { |
| 190 | public: |
| 191 | XglImage(XglDevice *dev); |
| 192 | |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 193 | public: |
| 194 | void init( XGL_UINT32 w, XGL_UINT32 h, |
| 195 | XGL_FORMAT fmt, XGL_FLAGS usage, |
| 196 | XGL_IMAGE_TILING tiling=XGL_LINEAR_TILING); |
| 197 | |
| 198 | // void clear( CommandBuffer*, XGL_UINT[4] ); |
| 199 | // void prepare( CommandBuffer*, XGL_IMAGE_STATE ); |
| 200 | |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 201 | void layout( XGL_IMAGE_LAYOUT layout ) |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 202 | { |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 203 | m_imageInfo.layout = layout; |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 204 | } |
| 205 | XGL_GPU_MEMORY memory() const |
| 206 | { |
| 207 | const std::vector<XGL_GPU_MEMORY> mems = memories(); |
| 208 | return mems.empty() ? XGL_NULL_HANDLE : mems[0]; |
| 209 | } |
| 210 | |
| 211 | |
| 212 | XGL_IMAGE image() const |
| 213 | { |
| 214 | return obj(); |
| 215 | } |
| 216 | XGL_COLOR_ATTACHMENT_VIEW targetView()const |
| 217 | { |
| 218 | return m_targetView.obj(); |
| 219 | } |
| 220 | |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 221 | XGL_IMAGE_LAYOUT layout() const |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 222 | { |
Mike Stroyan | 55658c2 | 2014-12-04 11:08:39 +0000 | [diff] [blame^] | 223 | return ( XGL_IMAGE_LAYOUT )m_imageInfo.layout; |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 224 | } |
| 225 | XGL_UINT32 width() const |
| 226 | { |
| 227 | return extent().width; |
| 228 | } |
| 229 | XGL_UINT32 height() const |
| 230 | { |
| 231 | return extent().height; |
| 232 | } |
| 233 | |
| 234 | XGL_RESULT MapMemory(XGL_VOID** ptr); |
| 235 | XGL_RESULT UnmapMemory(); |
| 236 | |
| 237 | protected: |
| 238 | XglDevice *m_device; |
| 239 | |
| 240 | xgl_testing::ColorAttachmentView m_targetView; |
| 241 | XGL_IMAGE_VIEW_ATTACH_INFO m_imageInfo; |
| 242 | }; |
| 243 | |
Chia-I Wu | dbec122 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 244 | class XglTextureObj : public xgl_testing::Image |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 245 | { |
| 246 | public: |
| 247 | XglTextureObj(XglDevice *device); |
Tony Barbour | 84d3d02 | 2014-11-21 17:17:49 -0700 | [diff] [blame] | 248 | void ChangeColors(uint32_t color1, uint32_t color2); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 249 | XGL_IMAGE_VIEW_ATTACH_INFO m_textureViewInfo; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 250 | |
| 251 | protected: |
| 252 | XglDevice *m_device; |
Chia-I Wu | dbec122 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 253 | xgl_testing::ImageView m_textureView; |
| 254 | XGL_GPU_SIZE m_rowPitch; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 255 | }; |
| 256 | |
Chia-I Wu | a64266a | 2014-12-28 16:32:24 +0800 | [diff] [blame] | 257 | class XglSamplerObj : public xgl_testing::Sampler |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 258 | { |
| 259 | public: |
| 260 | XglSamplerObj(XglDevice *device); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 261 | |
| 262 | protected: |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 263 | XglDevice *m_device; |
| 264 | |
| 265 | }; |
| 266 | |
Chia-I Wu | 6ae4cfb | 2014-12-28 22:32:36 +0800 | [diff] [blame] | 267 | class XglDescriptorSetObj : public xgl_testing::DescriptorSet |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 268 | { |
| 269 | public: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 270 | XglDescriptorSetObj(XglDevice *device); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 271 | void AttachBufferView(XglConstantBufferObj* constantBuffer); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 272 | void AttachSampler( XglSamplerObj* sampler); |
| 273 | void AttachImageView( XglTextureObj* texture); |
| 274 | void BindCommandBuffer(XGL_CMD_BUFFER commandBuffer); |
Tony Barbour | 3edb6ac | 2014-12-17 10:54:03 -0700 | [diff] [blame] | 275 | void CreateXGLDescriptorSet(); |
| 276 | XGL_DESCRIPTOR_SET GetDescriptorSetHandle(); |
Tony Barbour | a571298 | 2014-12-18 17:06:21 -0700 | [diff] [blame] | 277 | int GetTotalSlots(); |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 278 | XGL_DESCRIPTOR_SLOT_INFO * GetSlotInfo(vector<int>slots, vector<XGL_DESCRIPTOR_SET_SLOT_TYPE>types, vector<void*>objs ); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 279 | |
| 280 | protected: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 281 | XglDevice *m_device; |
| 282 | XGL_DESCRIPTOR_SLOT_INFO *m_slotInfo; |
| 283 | int m_nextSlot; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 284 | vector<int> m_bufferSlots; |
| 285 | vector<XGL_BUFFER_VIEW_ATTACH_INFO*> m_bufferViews; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 286 | vector<int> m_samplerSlots; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 287 | vector<XglSamplerObj*> m_samplers; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 288 | vector<int> m_imageSlots; |
| 289 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageViews; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 290 | }; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 291 | |
| 292 | |
Chia-I Wu | c2c3108 | 2014-12-29 14:14:03 +0800 | [diff] [blame] | 293 | class XglShaderObj : public xgl_testing::Shader |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 294 | { |
| 295 | public: |
Tony Barbour | f43b698 | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 296 | XglShaderObj(XglDevice *device, const char * shaderText, XGL_PIPELINE_SHADER_STAGE stage, XglRenderFramework *framework); |
Tony Barbour | bf67847 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 297 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* GetStageCreateInfo(XglDescriptorSetObj *descriptorSet); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 298 | void BindShaderEntitySlotToBuffer(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 299 | void BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture); |
| 300 | void BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 301 | |
| 302 | protected: |
| 303 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO stage_info; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 304 | XGL_PIPELINE_SHADER_STAGE m_stage; |
| 305 | XglDevice *m_device; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 306 | vector<int> m_bufferSlots; |
| 307 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_bufferTypes; |
| 308 | vector<XGL_BUFFER_VIEW_ATTACH_INFO*> m_bufferObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 309 | vector<int> m_samplerSlots; |
| 310 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_samplerTypes; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 311 | vector<XglSamplerObj*> m_samplerObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 312 | vector<int> m_imageSlots; |
| 313 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_imageTypes; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 314 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 315 | |
| 316 | }; |
| 317 | |
Chia-I Wu | f5d8187 | 2014-12-29 14:24:14 +0800 | [diff] [blame] | 318 | class XglPipelineObj : public xgl_testing::Pipeline |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 319 | { |
| 320 | public: |
| 321 | XglPipelineObj(XglDevice *device); |
Tony Barbour | bf67847 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 322 | void BindPipelineCommandBuffer(XGL_CMD_BUFFER m_cmdBuffer, XglDescriptorSetObj *descriptorSet); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 323 | void AddShader(XglShaderObj* shaderObj); |
| 324 | void AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count); |
| 325 | void AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count); |
| 326 | void AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding); |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 327 | void AddColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att); |
| 328 | void SetDepthStencil(XGL_PIPELINE_DS_STATE_CREATE_INFO *); |
Tony Barbour | e7f2c7c | 2014-12-17 11:57:31 -0700 | [diff] [blame] | 329 | void CreateXGLPipeline(XglDescriptorSetObj *descriptorSet); |
| 330 | XGL_PIPELINE GetPipelineHandle(); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 331 | |
| 332 | protected: |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 333 | XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO m_vi_state; |
| 334 | XGL_PIPELINE_IA_STATE_CREATE_INFO m_ia_state; |
| 335 | XGL_PIPELINE_RS_STATE_CREATE_INFO m_rs_state; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 336 | XGL_PIPELINE_CB_STATE_CREATE_INFO m_cb_state; |
| 337 | XGL_PIPELINE_DS_STATE_CREATE_INFO m_ds_state; |
| 338 | XGL_PIPELINE_MS_STATE_CREATE_INFO m_ms_state; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 339 | XglDevice *m_device; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 340 | vector<XglShaderObj*> m_shaderObjs; |
| 341 | vector<XglConstantBufferObj*> m_vertexBufferObjs; |
| 342 | vector<int> m_vertexBufferBindings; |
Tony Barbour | fa6cac7 | 2015-01-16 14:27:35 -0700 | [diff] [blame] | 343 | vector<XGL_PIPELINE_CB_ATTACHMENT_STATE> m_colorAttachments; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 344 | int m_vertexBufferCount; |
| 345 | |
| 346 | }; |
| 347 | class XglMemoryRefManager{ |
| 348 | public: |
| 349 | XglMemoryRefManager(); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 350 | void AddMemoryRef(XglConstantBufferObj* constantBuffer); |
| 351 | void AddMemoryRef(XglTextureObj *texture); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 352 | XGL_MEMORY_REF* GetMemoryRefList(); |
| 353 | int GetNumRefs(); |
| 354 | |
| 355 | protected: |
| 356 | int m_numRefs; |
Chia-I Wu | 5b30813 | 2014-12-28 15:43:42 +0800 | [diff] [blame] | 357 | vector<XGL_GPU_MEMORY> m_bufferObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 358 | |
| 359 | }; |
| 360 | |
| 361 | |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 362 | #endif // XGLRENDERFRAMEWORK_H |