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];} |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 57 | void InitViewport(float width, float height); |
Courtney Goeltzenleuchter | e540934 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 58 | void InitViewport(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 59 | void InitRenderTarget(); |
| 60 | void InitFramework(); |
Courtney Goeltzenleuchter | cb5a89c | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 61 | void ShutdownFramework(); |
| 62 | void InitState(); |
Courtney Goeltzenleuchter | e540934 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 63 | void GenerateClearAndPrepareBufferCmds(); |
| 64 | void GenerateBindRenderTargetCmd(); |
Tony Barbour | f43b698 | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 65 | void GenerateBindStateAndPipelineCmds(); |
| 66 | |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 67 | |
| 68 | protected: |
| 69 | XGL_APPLICATION_INFO app_info; |
Chia-I Wu | 9c877b2 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 70 | XGL_PHYSICAL_GPU objs[XGL_MAX_PHYSICAL_GPUS]; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 71 | XGL_UINT gpu_count; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 72 | XglDevice *m_device; |
| 73 | XGL_CMD_BUFFER m_cmdBuffer; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 74 | XGL_MEMORY_REF m_memRefs[5]; |
| 75 | XGL_RASTER_STATE_OBJECT m_stateRaster; |
| 76 | XGL_COLOR_BLEND_STATE_OBJECT m_colorBlend; |
| 77 | XGL_VIEWPORT_STATE_OBJECT m_stateViewport; |
| 78 | XGL_DEPTH_STENCIL_STATE_OBJECT m_stateDepthStencil; |
| 79 | XGL_MSAA_STATE_OBJECT m_stateMsaa; |
Chia-I Wu | e774880 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 80 | XglImage *m_renderTargets[XGL_MAX_COLOR_ATTACHMENTS]; |
| 81 | XGL_UINT m_renderTargetCount; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 82 | XGL_FLOAT m_width, m_height; |
| 83 | XGL_FORMAT m_render_target_fmt; |
Chia-I Wu | e774880 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 84 | XGL_COLOR_ATTACHMENT_BIND_INFO m_colorBindings[XGL_MAX_COLOR_ATTACHMENTS]; |
Courtney Goeltzenleuchter | b66e7de | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 85 | XGL_DEPTH_STENCIL_BIND_INFO m_depthStencilBinding; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * SetUp and TearDown are called by the Google Test framework |
| 89 | * to initialize a test framework based on this class. |
| 90 | */ |
| 91 | virtual void SetUp() { |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 92 | this->app_info.sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO; |
| 93 | this->app_info.pNext = NULL; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 94 | this->app_info.pAppName = "base"; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 95 | this->app_info.appVersion = 1; |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 96 | this->app_info.pEngineName = "unittest"; |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 97 | this->app_info.engineVersion = 1; |
| 98 | this->app_info.apiVersion = XGL_MAKE_VERSION(0, 22, 0); |
| 99 | |
Chia-I Wu | 48580a8 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 100 | InitFramework(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | virtual void TearDown() { |
Chia-I Wu | 48580a8 | 2014-12-29 15:18:43 +0800 | [diff] [blame] | 104 | ShutdownFramework(); |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 105 | } |
| 106 | }; |
| 107 | |
Tony Barbour | 1d7a55d | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 108 | class XglIndexBufferObj; |
| 109 | class XglConstantBufferObj; |
| 110 | |
Chia-I Wu | ae0564f | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 111 | class XglCommandBufferObj : xgl_testing::CmdBuffer |
Tony Barbour | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 112 | { |
| 113 | public: |
| 114 | XglCommandBufferObj(XglDevice *device); |
Tony Barbour | e8f1416 | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 115 | XGL_CMD_BUFFER GetBufferHandle(); |
| 116 | XGL_RESULT BeginCommandBuffer(XGL_FLAGS flags); |
| 117 | XGL_RESULT EndCommandBuffer(); |
| 118 | void PrepareMemoryRegions(int transitionCount, XGL_MEMORY_STATE_TRANSITION *transitionPtr); |
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); |
| 123 | void BindAttachments(XGL_DEPTH_STENCIL_BIND_INFO *depthStencilBinding); |
| 124 | void BindAttachments(); |
| 125 | void BindPipeline(XGL_PIPELINE pipeline); |
| 126 | void BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet); |
| 127 | void BindVertexBuffer(XglConstantBufferObj *vertexBuffer, XGL_UINT offset, XGL_UINT binding); |
| 128 | void BindIndexBuffer(XglIndexBufferObj *indexBuffer, XGL_UINT offset); |
| 129 | void BindState(XGL_RASTER_STATE_OBJECT stateRaster, XGL_VIEWPORT_STATE_OBJECT stateViewport, |
| 130 | XGL_COLOR_BLEND_STATE_OBJECT colorBlend, XGL_DEPTH_STENCIL_STATE_OBJECT stateDepthStencil, |
| 131 | XGL_MSAA_STATE_OBJECT stateMsaa); |
| 132 | void Draw(XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount); |
| 133 | void DrawIndexed(XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount); |
| 134 | void QueueCommandBuffer(XGL_MEMORY_REF *memRefs, XGL_UINT32 numMemRefs); |
Tony Barbour | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 135 | |
| 136 | protected: |
| 137 | XglDevice *m_device; |
Tony Barbour | 1d7a55d | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 138 | vector<XglImage*> m_renderTargets; |
| 139 | XGL_UINT m_renderTargetCount; |
Tony Barbour | 4f3e5a6 | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 140 | |
| 141 | }; |
| 142 | |
Chia-I Wu | 67ee00f | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 143 | class XglConstantBufferObj : public xgl_testing::GpuMemory |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 144 | { |
| 145 | public: |
Courtney Goeltzenleuchter | ea2db0d | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 146 | XglConstantBufferObj(XglDevice *device); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 147 | XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data); |
Tony Barbour | e615204 | 2014-12-10 17:40:15 -0700 | [diff] [blame] | 148 | void SetMemoryState(XGL_MEMORY_STATE newState); |
Courtney Goeltzenleuchter | 7715bc4 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 149 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset, XGL_UINT binding); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 150 | XGL_MEMORY_VIEW_ATTACH_INFO m_constantBufferView; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 151 | |
| 152 | protected: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 153 | XglDevice *m_device; |
| 154 | int m_numVertices; |
| 155 | int m_stride; |
Tony Barbour | 9f47dc7 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 156 | XglCommandBufferObj *m_commandBuffer; |
Chia-I Wu | 67ee00f | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 157 | xgl_testing::Fence m_fence; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 158 | }; |
Courtney Goeltzenleuchter | fa834c9 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 159 | |
| 160 | class XglIndexBufferObj : public XglConstantBufferObj |
| 161 | { |
| 162 | public: |
| 163 | XglIndexBufferObj(XglDevice *device); |
| 164 | void CreateAndInitBuffer(int numIndexes, XGL_INDEX_TYPE dataFormat, const void* data); |
| 165 | void Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset); |
Tony Barbour | 140a59f | 2014-12-17 10:57:58 -0700 | [diff] [blame] | 166 | XGL_INDEX_TYPE GetIndexType(); |
Courtney Goeltzenleuchter | fa834c9 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 167 | |
| 168 | protected: |
| 169 | XGL_INDEX_TYPE m_indexType; |
| 170 | }; |
| 171 | |
Chia-I Wu | 13ecdcd | 2014-12-29 14:38:28 +0800 | [diff] [blame] | 172 | class XglImage : public xgl_testing::Image |
| 173 | { |
| 174 | public: |
| 175 | XglImage(XglDevice *dev); |
| 176 | |
| 177 | // Image usage flags |
| 178 | // typedef enum _XGL_IMAGE_USAGE_FLAGS |
| 179 | // { |
| 180 | // XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT = 0x00000001, |
| 181 | // XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT = 0x00000002, |
| 182 | // XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000004, |
| 183 | // XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT = 0x00000008, |
| 184 | // } XGL_IMAGE_USAGE_FLAGS; |
| 185 | public: |
| 186 | void init( XGL_UINT32 w, XGL_UINT32 h, |
| 187 | XGL_FORMAT fmt, XGL_FLAGS usage, |
| 188 | XGL_IMAGE_TILING tiling=XGL_LINEAR_TILING); |
| 189 | |
| 190 | // void clear( CommandBuffer*, XGL_UINT[4] ); |
| 191 | // void prepare( CommandBuffer*, XGL_IMAGE_STATE ); |
| 192 | |
| 193 | void state( XGL_IMAGE_STATE state ) |
| 194 | { |
| 195 | m_imageInfo.state = state; |
| 196 | } |
| 197 | XGL_GPU_MEMORY memory() const |
| 198 | { |
| 199 | const std::vector<XGL_GPU_MEMORY> mems = memories(); |
| 200 | return mems.empty() ? XGL_NULL_HANDLE : mems[0]; |
| 201 | } |
| 202 | |
| 203 | |
| 204 | XGL_IMAGE image() const |
| 205 | { |
| 206 | return obj(); |
| 207 | } |
| 208 | XGL_COLOR_ATTACHMENT_VIEW targetView()const |
| 209 | { |
| 210 | return m_targetView.obj(); |
| 211 | } |
| 212 | |
| 213 | XGL_IMAGE_STATE state() const |
| 214 | { |
| 215 | return ( XGL_IMAGE_STATE )m_imageInfo.state; |
| 216 | } |
| 217 | XGL_UINT32 width() const |
| 218 | { |
| 219 | return extent().width; |
| 220 | } |
| 221 | XGL_UINT32 height() const |
| 222 | { |
| 223 | return extent().height; |
| 224 | } |
| 225 | |
| 226 | XGL_RESULT MapMemory(XGL_VOID** ptr); |
| 227 | XGL_RESULT UnmapMemory(); |
| 228 | |
| 229 | protected: |
| 230 | XglDevice *m_device; |
| 231 | |
| 232 | xgl_testing::ColorAttachmentView m_targetView; |
| 233 | XGL_IMAGE_VIEW_ATTACH_INFO m_imageInfo; |
| 234 | }; |
| 235 | |
Chia-I Wu | dbec122 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 236 | class XglTextureObj : public xgl_testing::Image |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 237 | { |
| 238 | public: |
| 239 | XglTextureObj(XglDevice *device); |
Tony Barbour | 84d3d02 | 2014-11-21 17:17:49 -0700 | [diff] [blame] | 240 | void ChangeColors(uint32_t color1, uint32_t color2); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 241 | XGL_IMAGE_VIEW_ATTACH_INFO m_textureViewInfo; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 242 | |
| 243 | protected: |
| 244 | XglDevice *m_device; |
Chia-I Wu | dbec122 | 2014-12-28 15:55:09 +0800 | [diff] [blame] | 245 | xgl_testing::ImageView m_textureView; |
| 246 | XGL_GPU_SIZE m_rowPitch; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 247 | }; |
| 248 | |
Chia-I Wu | a64266a | 2014-12-28 16:32:24 +0800 | [diff] [blame] | 249 | class XglSamplerObj : public xgl_testing::Sampler |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 250 | { |
| 251 | public: |
| 252 | XglSamplerObj(XglDevice *device); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 253 | |
| 254 | protected: |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 255 | XglDevice *m_device; |
| 256 | |
| 257 | }; |
| 258 | |
Chia-I Wu | 6ae4cfb | 2014-12-28 22:32:36 +0800 | [diff] [blame] | 259 | class XglDescriptorSetObj : public xgl_testing::DescriptorSet |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 260 | { |
| 261 | public: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 262 | XglDescriptorSetObj(XglDevice *device); |
| 263 | void AttachMemoryView(XglConstantBufferObj* constantBuffer); |
| 264 | void AttachSampler( XglSamplerObj* sampler); |
| 265 | void AttachImageView( XglTextureObj* texture); |
| 266 | void BindCommandBuffer(XGL_CMD_BUFFER commandBuffer); |
Tony Barbour | 3edb6ac | 2014-12-17 10:54:03 -0700 | [diff] [blame] | 267 | void CreateXGLDescriptorSet(); |
| 268 | XGL_DESCRIPTOR_SET GetDescriptorSetHandle(); |
Tony Barbour | a571298 | 2014-12-18 17:06:21 -0700 | [diff] [blame] | 269 | int GetTotalSlots(); |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 270 | 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] | 271 | |
| 272 | protected: |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 273 | XglDevice *m_device; |
| 274 | XGL_DESCRIPTOR_SLOT_INFO *m_slotInfo; |
| 275 | int m_nextSlot; |
| 276 | vector<int> m_memorySlots; |
| 277 | vector<XGL_MEMORY_VIEW_ATTACH_INFO*> m_memoryViews; |
| 278 | vector<int> m_samplerSlots; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 279 | vector<XglSamplerObj*> m_samplers; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 280 | vector<int> m_imageSlots; |
| 281 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageViews; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 282 | }; |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 283 | |
| 284 | |
Chia-I Wu | c2c3108 | 2014-12-29 14:14:03 +0800 | [diff] [blame] | 285 | class XglShaderObj : public xgl_testing::Shader |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 286 | { |
| 287 | public: |
Tony Barbour | f43b698 | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 288 | 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] | 289 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* GetStageCreateInfo(XglDescriptorSetObj *descriptorSet); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 290 | void BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer); |
| 291 | void BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture); |
| 292 | void BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 293 | |
| 294 | protected: |
| 295 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO stage_info; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 296 | XGL_PIPELINE_SHADER_STAGE m_stage; |
| 297 | XglDevice *m_device; |
| 298 | vector<int> m_memSlots; |
| 299 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_memTypes; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 300 | vector<XGL_MEMORY_VIEW_ATTACH_INFO*> m_memObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 301 | vector<int> m_samplerSlots; |
| 302 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_samplerTypes; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 303 | vector<XglSamplerObj*> m_samplerObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 304 | vector<int> m_imageSlots; |
| 305 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> m_imageTypes; |
Chia-I Wu | 5c590de | 2014-12-28 16:07:01 +0800 | [diff] [blame] | 306 | vector<XGL_IMAGE_VIEW_ATTACH_INFO*> m_imageObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 307 | |
| 308 | }; |
| 309 | |
Chia-I Wu | f5d8187 | 2014-12-29 14:24:14 +0800 | [diff] [blame] | 310 | class XglPipelineObj : public xgl_testing::Pipeline |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 311 | { |
| 312 | public: |
| 313 | XglPipelineObj(XglDevice *device); |
Tony Barbour | bf67847 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 314 | void BindPipelineCommandBuffer(XGL_CMD_BUFFER m_cmdBuffer, XglDescriptorSetObj *descriptorSet); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 315 | void AddShader(XglShaderObj* shaderObj); |
| 316 | void AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count); |
| 317 | void AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count); |
| 318 | void AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding); |
Chia-I Wu | e774880 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 319 | void SetColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att); |
Tony Barbour | e7f2c7c | 2014-12-17 11:57:31 -0700 | [diff] [blame] | 320 | void CreateXGLPipeline(XglDescriptorSetObj *descriptorSet); |
| 321 | XGL_PIPELINE GetPipelineHandle(); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 322 | |
| 323 | protected: |
Tony Barbour | f12bfb9 | 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; |
| 327 | XGL_PIPELINE_CB_STATE m_cb_state; |
| 328 | XGL_PIPELINE_DB_STATE_CREATE_INFO m_db_state; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 329 | XglDevice *m_device; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 330 | vector<XglShaderObj*> m_shaderObjs; |
| 331 | vector<XglConstantBufferObj*> m_vertexBufferObjs; |
| 332 | vector<int> m_vertexBufferBindings; |
| 333 | int m_vertexBufferCount; |
| 334 | |
| 335 | }; |
| 336 | class XglMemoryRefManager{ |
| 337 | public: |
| 338 | XglMemoryRefManager(); |
Tony Barbour | 685f433 | 2014-11-20 15:06:56 -0700 | [diff] [blame] | 339 | void AddMemoryRef(XglConstantBufferObj* constantBuffer); |
| 340 | void AddMemoryRef(XglTextureObj *texture); |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 341 | XGL_MEMORY_REF* GetMemoryRefList(); |
| 342 | int GetNumRefs(); |
| 343 | |
| 344 | protected: |
| 345 | int m_numRefs; |
Chia-I Wu | 5b30813 | 2014-12-28 15:43:42 +0800 | [diff] [blame] | 346 | vector<XGL_GPU_MEMORY> m_bufferObjs; |
Tony Barbour | f12bfb9 | 2014-11-19 16:33:11 -0700 | [diff] [blame] | 347 | |
| 348 | }; |
| 349 | |
| 350 | |
Courtney Goeltzenleuchter | 5744b97 | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 351 | #endif // XGLRENDERFRAMEWORK_H |