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