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 | #include "xglrenderframework.h" |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 29 | |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 30 | XglRenderFramework::XglRenderFramework() : |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 31 | m_cmdBuffer( XGL_NULL_HANDLE ), |
Chia-I Wu | 837f995 | 2014-12-15 23:29:34 +0800 | [diff] [blame] | 32 | m_stateRaster( XGL_NULL_HANDLE ), |
| 33 | m_colorBlend( XGL_NULL_HANDLE ), |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 34 | m_stateViewport( XGL_NULL_HANDLE ), |
Chia-I Wu | 837f995 | 2014-12-15 23:29:34 +0800 | [diff] [blame] | 35 | m_stateDepthStencil( XGL_NULL_HANDLE ), |
| 36 | m_stateMsaa( XGL_NULL_HANDLE ), |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 37 | m_width( 256.0 ), // default window width |
| 38 | m_height( 256.0 ) // default window height |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 39 | { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 40 | m_renderTargetCount = 1; |
| 41 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 42 | m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8; |
| 43 | m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM; |
Courtney Goeltzenleuchter | 32e486c | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 44 | |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 45 | m_colorBindings[0].view = XGL_NULL_HANDLE; |
Courtney Goeltzenleuchter | 32e486c | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 46 | m_depthStencilBinding.view = XGL_NULL_HANDLE; |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | XglRenderFramework::~XglRenderFramework() |
| 50 | { |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 51 | |
| 52 | } |
| 53 | |
| 54 | void XglRenderFramework::InitFramework() |
| 55 | { |
| 56 | XGL_RESULT err; |
| 57 | |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 58 | err = xglInitAndEnumerateGpus(&app_info, NULL, |
Chia-I Wu | af11d92 | 2014-12-28 14:37:25 +0800 | [diff] [blame] | 59 | XGL_MAX_PHYSICAL_GPUS, &this->gpu_count, objs); |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 60 | ASSERT_XGL_SUCCESS(err); |
Jon Ashburn | bf843b2 | 2014-11-26 11:06:49 -0700 | [diff] [blame] | 61 | ASSERT_GE(this->gpu_count, 1) << "No GPU available"; |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 62 | |
| 63 | m_device = new XglDevice(0, objs[0]); |
| 64 | m_device->get_device_queue(); |
| 65 | } |
| 66 | |
| 67 | void XglRenderFramework::ShutdownFramework() |
| 68 | { |
| 69 | if (m_colorBlend) xglDestroyObject(m_colorBlend); |
| 70 | if (m_stateMsaa) xglDestroyObject(m_stateMsaa); |
| 71 | if (m_stateDepthStencil) xglDestroyObject(m_stateDepthStencil); |
| 72 | if (m_stateRaster) xglDestroyObject(m_stateRaster); |
| 73 | if (m_cmdBuffer) xglDestroyObject(m_cmdBuffer); |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 74 | |
| 75 | if (m_stateViewport) { |
| 76 | xglDestroyObject(m_stateViewport); |
| 77 | } |
| 78 | |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 79 | for (XGL_UINT i = 0; i < m_renderTargetCount; i++) { |
| 80 | if (m_renderTargets[i]) { |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 81 | // TODO: XglImage should be able to destroy itself |
| 82 | // m_renderTarget-> |
| 83 | // xglDestroyObject(*m_renderTarget); |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 84 | } |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 85 | } |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 86 | |
| 87 | // reset the driver |
Chia-I Wu | b76e0fa | 2014-12-28 14:27:28 +0800 | [diff] [blame] | 88 | delete m_device; |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 89 | xglInitAndEnumerateGpus(&this->app_info, XGL_NULL_HANDLE, 0, &gpu_count, XGL_NULL_HANDLE); |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 90 | } |
| 91 | |
Courtney Goeltzenleuchter | 53d8d89 | 2014-10-08 12:20:26 -0600 | [diff] [blame] | 92 | void XglRenderFramework::InitState() |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 93 | { |
| 94 | XGL_RESULT err; |
| 95 | |
| 96 | m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8; |
| 97 | m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM; |
| 98 | |
| 99 | // create a raster state (solid, back-face culling) |
| 100 | XGL_RASTER_STATE_CREATE_INFO raster = {}; |
| 101 | raster.sType = XGL_STRUCTURE_TYPE_RASTER_STATE_CREATE_INFO; |
| 102 | raster.fillMode = XGL_FILL_SOLID; |
| 103 | raster.cullMode = XGL_CULL_NONE; |
| 104 | raster.frontFace = XGL_FRONT_FACE_CCW; |
| 105 | err = xglCreateRasterState( device(), &raster, &m_stateRaster ); |
| 106 | ASSERT_XGL_SUCCESS(err); |
| 107 | |
| 108 | XGL_COLOR_BLEND_STATE_CREATE_INFO blend = {}; |
| 109 | blend.sType = XGL_STRUCTURE_TYPE_COLOR_BLEND_STATE_CREATE_INFO; |
| 110 | err = xglCreateColorBlendState(device(), &blend, &m_colorBlend); |
| 111 | ASSERT_XGL_SUCCESS( err ); |
| 112 | |
| 113 | XGL_DEPTH_STENCIL_STATE_CREATE_INFO depthStencil = {}; |
| 114 | depthStencil.sType = XGL_STRUCTURE_TYPE_DEPTH_STENCIL_STATE_CREATE_INFO; |
| 115 | depthStencil.depthTestEnable = XGL_FALSE; |
| 116 | depthStencil.depthWriteEnable = XGL_FALSE; |
| 117 | depthStencil.depthFunc = XGL_COMPARE_LESS_EQUAL; |
| 118 | depthStencil.depthBoundsEnable = XGL_FALSE; |
| 119 | depthStencil.minDepth = 0.f; |
| 120 | depthStencil.maxDepth = 1.f; |
| 121 | depthStencil.back.stencilDepthFailOp = XGL_STENCIL_OP_KEEP; |
| 122 | depthStencil.back.stencilFailOp = XGL_STENCIL_OP_KEEP; |
| 123 | depthStencil.back.stencilPassOp = XGL_STENCIL_OP_KEEP; |
| 124 | depthStencil.back.stencilRef = 0x00; |
| 125 | depthStencil.back.stencilFunc = XGL_COMPARE_ALWAYS; |
| 126 | depthStencil.front = depthStencil.back; |
| 127 | |
| 128 | err = xglCreateDepthStencilState( device(), &depthStencil, &m_stateDepthStencil ); |
| 129 | ASSERT_XGL_SUCCESS( err ); |
| 130 | |
| 131 | XGL_MSAA_STATE_CREATE_INFO msaa = {}; |
| 132 | msaa.sType = XGL_STRUCTURE_TYPE_MSAA_STATE_CREATE_INFO; |
| 133 | msaa.sampleMask = 1; |
| 134 | msaa.samples = 1; |
| 135 | |
| 136 | err = xglCreateMsaaState( device(), &msaa, &m_stateMsaa ); |
| 137 | ASSERT_XGL_SUCCESS( err ); |
| 138 | |
| 139 | XGL_CMD_BUFFER_CREATE_INFO cmdInfo = {}; |
| 140 | |
| 141 | cmdInfo.sType = XGL_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO; |
| 142 | cmdInfo.queueType = XGL_QUEUE_TYPE_GRAPHICS; |
| 143 | err = xglCreateCommandBuffer(device(), &cmdInfo, &m_cmdBuffer); |
| 144 | ASSERT_XGL_SUCCESS(err) << "xglCreateCommandBuffer failed"; |
| 145 | } |
| 146 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 147 | void XglRenderFramework::InitViewport(float width, float height) |
| 148 | { |
| 149 | XGL_RESULT err; |
| 150 | |
| 151 | XGL_VIEWPORT_STATE_CREATE_INFO viewport = {}; |
| 152 | viewport.viewportCount = 1; |
| 153 | viewport.scissorEnable = XGL_FALSE; |
| 154 | viewport.viewports[0].originX = 0; |
| 155 | viewport.viewports[0].originY = 0; |
| 156 | viewport.viewports[0].width = 1.f * width; |
| 157 | viewport.viewports[0].height = 1.f * height; |
| 158 | viewport.viewports[0].minDepth = 0.f; |
| 159 | viewport.viewports[0].maxDepth = 1.f; |
| 160 | |
| 161 | err = xglCreateViewportState( device(), &viewport, &m_stateViewport ); |
| 162 | ASSERT_XGL_SUCCESS( err ); |
| 163 | m_width = width; |
| 164 | m_height = height; |
| 165 | } |
| 166 | |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 167 | void XglRenderFramework::InitViewport() |
| 168 | { |
| 169 | InitViewport(m_width, m_height); |
| 170 | } |
| 171 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 172 | void XglRenderFramework::InitRenderTarget() |
| 173 | { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 174 | XGL_UINT i; |
| 175 | |
| 176 | for (i = 0; i < m_renderTargetCount; i++) { |
| 177 | m_device->CreateImage(m_width, m_height, m_render_target_fmt, |
| 178 | XGL_IMAGE_USAGE_SHADER_ACCESS_WRITE_BIT | |
| 179 | XGL_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, |
| 180 | &m_renderTargets[i]); |
| 181 | } |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 182 | } |
| 183 | |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 184 | void XglRenderFramework::GenerateBindRenderTargetCmd() |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 185 | { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 186 | XGL_UINT i; |
| 187 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 188 | // bind render target |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 189 | for (i = 0; i < m_renderTargetCount; i++) { |
| 190 | m_colorBindings[i].view = m_renderTargets[i]->targetView(); |
| 191 | m_colorBindings[i].colorAttachmentState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL; |
| 192 | } |
Courtney Goeltzenleuchter | 32e486c | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 193 | if (m_depthStencilBinding.view) { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 194 | xglCmdBindAttachments(m_cmdBuffer, m_renderTargetCount, m_colorBindings, &m_depthStencilBinding ); |
Courtney Goeltzenleuchter | 32e486c | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 195 | } else { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 196 | xglCmdBindAttachments(m_cmdBuffer, m_renderTargetCount, m_colorBindings, XGL_NULL_HANDLE ); |
Courtney Goeltzenleuchter | 32e486c | 2014-10-22 14:12:38 -0600 | [diff] [blame] | 197 | } |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 198 | } |
| 199 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 200 | void XglRenderFramework::GenerateBindStateAndPipelineCmds() |
| 201 | { |
| 202 | // set all states |
| 203 | xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_RASTER, m_stateRaster ); |
| 204 | xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_VIEWPORT, m_stateViewport ); |
| 205 | xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_COLOR_BLEND, m_colorBlend); |
| 206 | xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_DEPTH_STENCIL, m_stateDepthStencil ); |
| 207 | xglCmdBindStateObject( m_cmdBuffer, XGL_STATE_BIND_MSAA, m_stateMsaa ); |
| 208 | } |
| 209 | |
Courtney Goeltzenleuchter | 02d33c1 | 2014-10-08 14:26:40 -0600 | [diff] [blame] | 210 | void XglRenderFramework::GenerateClearAndPrepareBufferCmds() |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 211 | { |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 212 | XGL_UINT i; |
| 213 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 214 | // whatever we want to do, we do it to the whole buffer |
| 215 | XGL_IMAGE_SUBRESOURCE_RANGE srRange = {}; |
| 216 | srRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 217 | srRange.baseMipLevel = 0; |
| 218 | srRange.mipLevels = XGL_LAST_MIP_OR_SLICE; |
| 219 | srRange.baseArraySlice = 0; |
| 220 | srRange.arraySize = XGL_LAST_MIP_OR_SLICE; |
| 221 | |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 222 | // clear the back buffer to dark grey |
| 223 | XGL_UINT clearColor[4] = {64, 64, 64, 0}; |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 224 | XGL_IMAGE_STATE_TRANSITION transitionToClear = {}; |
| 225 | for (i = 0; i < m_renderTargetCount; i++) { |
| 226 | transitionToClear.image = m_renderTargets[i]->image(); |
| 227 | transitionToClear.oldState = m_renderTargets[i]->state(); |
| 228 | transitionToClear.newState = XGL_IMAGE_STATE_CLEAR; |
| 229 | transitionToClear.subresourceRange = srRange; |
| 230 | xglCmdPrepareImages( m_cmdBuffer, 1, &transitionToClear ); |
| 231 | m_renderTargets[i]->state(( XGL_IMAGE_STATE ) transitionToClear.newState); |
| 232 | |
| 233 | xglCmdClearColorImageRaw( m_cmdBuffer, m_renderTargets[i]->image(), clearColor, 1, &srRange ); |
| 234 | } |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 235 | |
| 236 | // prepare back buffer for rendering |
| 237 | XGL_IMAGE_STATE_TRANSITION transitionToRender = {}; |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 238 | for (i = 0; i < m_renderTargetCount; i++) { |
| 239 | transitionToRender.image = m_renderTargets[i]->image(); |
| 240 | transitionToRender.oldState = m_renderTargets[i]->state(); |
| 241 | transitionToRender.newState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL; |
| 242 | transitionToRender.subresourceRange = srRange; |
| 243 | xglCmdPrepareImages( m_cmdBuffer, 1, &transitionToRender ); |
| 244 | m_renderTargets[i]->state(( XGL_IMAGE_STATE ) transitionToClear.newState); |
| 245 | } |
Courtney Goeltzenleuchter | a4b278b | 2014-10-08 08:50:49 -0600 | [diff] [blame] | 246 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 247 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 248 | XglDescriptorSetObj::XglDescriptorSetObj(XglDevice *device) |
| 249 | { |
| 250 | m_device = device; |
| 251 | m_nextSlot = 0; |
| 252 | |
| 253 | } |
| 254 | |
| 255 | void XglDescriptorSetObj::AttachMemoryView(XglConstantBufferObj *constantBuffer) |
| 256 | { |
| 257 | m_memoryViews.push_back(&constantBuffer->m_constantBufferView); |
| 258 | m_memorySlots.push_back(m_nextSlot); |
| 259 | m_nextSlot++; |
| 260 | |
| 261 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 262 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 263 | void XglDescriptorSetObj::AttachSampler(XglSamplerObj *sampler) |
| 264 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 265 | m_samplers.push_back(sampler); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 266 | m_samplerSlots.push_back(m_nextSlot); |
| 267 | m_nextSlot++; |
| 268 | |
| 269 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 270 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 271 | void XglDescriptorSetObj::AttachImageView(XglTextureObj *texture) |
| 272 | { |
| 273 | m_imageViews.push_back(&texture->m_textureViewInfo); |
| 274 | m_imageSlots.push_back(m_nextSlot); |
| 275 | m_nextSlot++; |
| 276 | |
| 277 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 278 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 279 | XGL_DESCRIPTOR_SLOT_INFO* XglDescriptorSetObj::GetSlotInfo(vector<int>slots, |
| 280 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE>types, |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 281 | vector<void *>objs ) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 282 | { |
| 283 | int nSlots = m_memorySlots.size() + m_imageSlots.size() + m_samplerSlots.size(); |
| 284 | m_slotInfo = (XGL_DESCRIPTOR_SLOT_INFO*) malloc( nSlots * sizeof(XGL_DESCRIPTOR_SLOT_INFO) ); |
| 285 | memset(m_slotInfo,0,nSlots*sizeof(XGL_DESCRIPTOR_SLOT_INFO)); |
| 286 | |
| 287 | for (int i=0; i<nSlots; i++) |
| 288 | { |
| 289 | m_slotInfo[i].slotObjectType = XGL_SLOT_UNUSED; |
| 290 | } |
| 291 | |
| 292 | for (int i=0; i<slots.size(); i++) |
| 293 | { |
| 294 | for (int j=0; j<m_memorySlots.size(); j++) |
| 295 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 296 | if ( m_memoryViews[j] == objs[i]) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 297 | { |
| 298 | m_slotInfo[m_memorySlots[j]].shaderEntityIndex = slots[i]; |
| 299 | m_slotInfo[m_memorySlots[j]].slotObjectType = types[i]; |
| 300 | } |
| 301 | } |
| 302 | for (int j=0; j<m_imageSlots.size(); j++) |
| 303 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 304 | if ( m_imageViews[j] == objs[i]) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 305 | { |
| 306 | m_slotInfo[m_imageSlots[j]].shaderEntityIndex = slots[i]; |
| 307 | m_slotInfo[m_imageSlots[j]].slotObjectType = types[i]; |
| 308 | } |
| 309 | } |
| 310 | for (int j=0; j<m_samplerSlots.size(); j++) |
| 311 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 312 | if ( m_samplers[j] == objs[i]) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 313 | { |
| 314 | m_slotInfo[m_samplerSlots[j]].shaderEntityIndex = slots[i]; |
| 315 | m_slotInfo[m_samplerSlots[j]].slotObjectType = types[i]; |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | // for (int i=0;i<nSlots;i++) |
| 321 | // { |
| 322 | // printf("SlotInfo[%d]: Index = %d, Type = %d\n",i,m_slotInfo[i].shaderEntityIndex, m_slotInfo[i].slotObjectType); |
| 323 | // fflush(stdout); |
| 324 | // } |
| 325 | |
| 326 | return(m_slotInfo); |
| 327 | |
| 328 | } |
Tony Barbour | b5f4d08 | 2014-12-17 10:54:03 -0700 | [diff] [blame] | 329 | void XglDescriptorSetObj::CreateXGLDescriptorSet() |
| 330 | { |
| 331 | XGL_RESULT err; |
| 332 | |
| 333 | // Create descriptor set for a uniform resource |
| 334 | memset(&m_descriptorInfo,0,sizeof(m_descriptorInfo)); |
| 335 | m_descriptorInfo.sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO; |
| 336 | m_descriptorInfo.slots = m_nextSlot; |
| 337 | |
| 338 | // Create a descriptor set with requested number of slots |
| 339 | err = xglCreateDescriptorSet( m_device->device(), &m_descriptorInfo, &m_rsrcDescSet ); |
| 340 | ASSERT_XGL_SUCCESS(err); |
| 341 | |
| 342 | // Bind memory to the descriptor set |
| 343 | err = m_device->AllocAndBindGpuMemory(m_rsrcDescSet, "DescriptorSet", &m_descriptor_set_mem); |
| 344 | ASSERT_XGL_SUCCESS(err); |
| 345 | |
| 346 | xglBeginDescriptorSetUpdate( m_rsrcDescSet ); |
| 347 | xglClearDescriptorSetSlots(m_rsrcDescSet, 0, m_nextSlot); |
| 348 | for (int i=0; i<m_memoryViews.size();i++) |
| 349 | { |
| 350 | xglAttachMemoryViewDescriptors( m_rsrcDescSet, m_memorySlots[i], 1, m_memoryViews[i] ); |
| 351 | } |
| 352 | for (int i=0; i<m_samplers.size();i++) |
| 353 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 354 | xglAttachSamplerDescriptors( m_rsrcDescSet, m_samplerSlots[i], 1, &m_samplers[i]->m_sampler ); |
Tony Barbour | b5f4d08 | 2014-12-17 10:54:03 -0700 | [diff] [blame] | 355 | } |
| 356 | for (int i=0; i<m_imageViews.size();i++) |
| 357 | { |
| 358 | xglAttachImageViewDescriptors( m_rsrcDescSet, m_imageSlots[i], 1, m_imageViews[i] ); |
| 359 | } |
| 360 | xglEndDescriptorSetUpdate( m_rsrcDescSet ); |
| 361 | } |
| 362 | |
| 363 | XGL_DESCRIPTOR_SET XglDescriptorSetObj::GetDescriptorSetHandle() |
| 364 | { |
| 365 | return m_rsrcDescSet; |
| 366 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 367 | |
Tony Barbour | 824b771 | 2014-12-18 17:06:21 -0700 | [diff] [blame] | 368 | int XglDescriptorSetObj::GetTotalSlots() |
| 369 | { |
| 370 | return m_nextSlot; |
| 371 | } |
| 372 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 373 | void XglDescriptorSetObj::BindCommandBuffer(XGL_CMD_BUFFER commandBuffer) |
| 374 | { |
| 375 | XGL_RESULT err; |
| 376 | |
| 377 | // Create descriptor set for a uniform resource |
| 378 | memset(&m_descriptorInfo,0,sizeof(m_descriptorInfo)); |
| 379 | m_descriptorInfo.sType = XGL_STRUCTURE_TYPE_DESCRIPTOR_SET_CREATE_INFO; |
| 380 | m_descriptorInfo.slots = m_nextSlot; |
| 381 | |
| 382 | // Create a descriptor set with requested number of slots |
| 383 | err = xglCreateDescriptorSet( m_device->device(), &m_descriptorInfo, &m_rsrcDescSet ); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 384 | ASSERT_XGL_SUCCESS(err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 385 | |
| 386 | // Bind memory to the descriptor set |
| 387 | err = m_device->AllocAndBindGpuMemory(m_rsrcDescSet, "DescriptorSet", &m_descriptor_set_mem); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 388 | ASSERT_XGL_SUCCESS(err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 389 | |
| 390 | xglBeginDescriptorSetUpdate( m_rsrcDescSet ); |
| 391 | xglClearDescriptorSetSlots(m_rsrcDescSet, 0, m_nextSlot); |
| 392 | for (int i=0; i<m_memoryViews.size();i++) |
| 393 | { |
| 394 | xglAttachMemoryViewDescriptors( m_rsrcDescSet, m_memorySlots[i], 1, m_memoryViews[i] ); |
| 395 | } |
| 396 | for (int i=0; i<m_samplers.size();i++) |
| 397 | { |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 398 | xglAttachSamplerDescriptors( m_rsrcDescSet, m_samplerSlots[i], 1, &m_samplers[i]->m_sampler ); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 399 | } |
| 400 | for (int i=0; i<m_imageViews.size();i++) |
| 401 | { |
| 402 | xglAttachImageViewDescriptors( m_rsrcDescSet, m_imageSlots[i], 1, m_imageViews[i] ); |
| 403 | } |
| 404 | xglEndDescriptorSetUpdate( m_rsrcDescSet ); |
| 405 | |
| 406 | // bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view) |
| 407 | xglCmdBindDescriptorSet(commandBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, m_rsrcDescSet, 0 ); |
| 408 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 409 | |
Tony Barbour | 25ef8a6 | 2014-12-03 13:59:18 -0700 | [diff] [blame] | 410 | XglDescriptorSetObj::~XglDescriptorSetObj() |
| 411 | { |
| 412 | if (m_rsrcDescSet != XGL_NULL_HANDLE) xglDestroyObject(m_rsrcDescSet); |
| 413 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 414 | |
| 415 | XglTextureObj::XglTextureObj(XglDevice *device): |
| 416 | m_texture(XGL_NULL_HANDLE), |
| 417 | m_textureMem(XGL_NULL_HANDLE), |
| 418 | m_textureView(XGL_NULL_HANDLE) |
| 419 | { |
| 420 | m_device = device; |
| 421 | const XGL_FORMAT tex_format = { XGL_CH_FMT_B8G8R8A8, XGL_NUM_FMT_UNORM }; |
| 422 | m_texWidth = 16; |
| 423 | m_texHeight = 16; |
| 424 | const uint32_t tex_colors[2] = { 0xffff0000, 0xff00ff00 }; |
| 425 | XGL_RESULT err; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 426 | |
| 427 | memset(&m_textureViewInfo,0,sizeof(m_textureViewInfo)); |
| 428 | |
| 429 | m_textureViewInfo.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_ATTACH_INFO; |
| 430 | |
| 431 | const XGL_IMAGE_CREATE_INFO image = { |
| 432 | .sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO, |
| 433 | .pNext = NULL, |
| 434 | .imageType = XGL_IMAGE_2D, |
| 435 | .format = tex_format, |
| 436 | .extent = { m_texWidth, m_texHeight, 1 }, |
| 437 | .mipLevels = 1, |
| 438 | .arraySize = 1, |
| 439 | .samples = 1, |
| 440 | .tiling = XGL_LINEAR_TILING, |
| 441 | .usage = XGL_IMAGE_USAGE_SHADER_ACCESS_READ_BIT, |
| 442 | .flags = 0, |
| 443 | }; |
| 444 | |
| 445 | XGL_MEMORY_ALLOC_INFO mem_alloc; |
| 446 | mem_alloc.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; |
| 447 | mem_alloc.pNext = NULL; |
| 448 | mem_alloc.allocationSize = 0; |
| 449 | mem_alloc.alignment = 0; |
| 450 | mem_alloc.flags = 0; |
| 451 | mem_alloc.heapCount = 0; |
| 452 | mem_alloc.memPriority = XGL_MEMORY_PRIORITY_NORMAL; |
| 453 | |
| 454 | XGL_IMAGE_VIEW_CREATE_INFO view; |
| 455 | view.sType = XGL_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; |
| 456 | view.pNext = NULL; |
| 457 | view.image = XGL_NULL_HANDLE; |
| 458 | view.viewType = XGL_IMAGE_VIEW_2D; |
| 459 | view.format = image.format; |
| 460 | view.channels.r = XGL_CHANNEL_SWIZZLE_R; |
| 461 | view.channels.g = XGL_CHANNEL_SWIZZLE_G; |
| 462 | view.channels.b = XGL_CHANNEL_SWIZZLE_B; |
| 463 | view.channels.a = XGL_CHANNEL_SWIZZLE_A; |
| 464 | view.subresourceRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 465 | view.subresourceRange.baseMipLevel = 0; |
| 466 | view.subresourceRange.mipLevels = 1; |
| 467 | view.subresourceRange.baseArraySlice = 0; |
| 468 | view.subresourceRange.arraySize = 1; |
| 469 | view.minLod = 0.0f; |
| 470 | |
| 471 | XGL_MEMORY_REQUIREMENTS mem_reqs; |
| 472 | XGL_SIZE mem_reqs_size=sizeof(XGL_MEMORY_REQUIREMENTS); |
| 473 | |
| 474 | /* create image */ |
| 475 | err = xglCreateImage(m_device->device(), &image, &m_texture); |
| 476 | assert(!err); |
| 477 | |
| 478 | err = xglGetObjectInfo(m_texture, |
| 479 | XGL_INFO_TYPE_MEMORY_REQUIREMENTS, |
| 480 | &mem_reqs_size, &mem_reqs); |
| 481 | assert(!err && mem_reqs_size == sizeof(mem_reqs)); |
| 482 | |
| 483 | mem_alloc.allocationSize = mem_reqs.size; |
| 484 | mem_alloc.alignment = mem_reqs.alignment; |
| 485 | mem_alloc.heapCount = mem_reqs.heapCount; |
| 486 | memcpy(mem_alloc.heaps, mem_reqs.heaps, |
| 487 | sizeof(mem_reqs.heaps[0]) * mem_reqs.heapCount); |
| 488 | |
| 489 | /* allocate memory */ |
| 490 | err = xglAllocMemory(m_device->device(), &mem_alloc, &m_textureMem); |
| 491 | assert(!err); |
| 492 | |
| 493 | /* bind memory */ |
| 494 | err = xglBindObjectMemory(m_texture, m_textureMem, 0); |
| 495 | assert(!err); |
| 496 | |
| 497 | /* create image view */ |
| 498 | view.image = m_texture; |
| 499 | err = xglCreateImageView(m_device->device(), &view, &m_textureView); |
| 500 | assert(!err); |
| 501 | |
| 502 | |
| 503 | const XGL_IMAGE_SUBRESOURCE subres = { |
| 504 | .aspect = XGL_IMAGE_ASPECT_COLOR, |
| 505 | .mipLevel = 0, |
| 506 | .arraySlice = 0, |
| 507 | }; |
| 508 | XGL_SUBRESOURCE_LAYOUT layout; |
| 509 | XGL_SIZE layout_size=sizeof(layout); |
| 510 | XGL_VOID *data; |
| 511 | XGL_INT x, y; |
| 512 | |
| 513 | err = xglGetImageSubresourceInfo(m_texture, &subres, |
| 514 | XGL_INFO_TYPE_SUBRESOURCE_LAYOUT, &layout_size, &layout); |
| 515 | assert(!err && layout_size == sizeof(layout)); |
| 516 | m_rowPitch = layout.rowPitch; |
| 517 | |
| 518 | err = xglMapMemory(m_textureMem, 0, &data); |
| 519 | assert(!err); |
| 520 | |
| 521 | for (y = 0; y < m_texHeight; y++) { |
| 522 | uint32_t *row = (uint32_t *) ((char *) data + layout.rowPitch * y); |
| 523 | for (x = 0; x < m_texWidth; x++) |
| 524 | row[x] = tex_colors[(x & 1) ^ (y & 1)]; |
| 525 | } |
| 526 | |
| 527 | err = xglUnmapMemory(m_textureMem); |
| 528 | assert(!err); |
| 529 | |
| 530 | m_textureViewInfo.view = m_textureView; |
| 531 | |
| 532 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 533 | |
Tony Barbour | f325bf1 | 2014-12-03 15:59:38 -0700 | [diff] [blame] | 534 | XglTextureObj::~XglTextureObj() |
| 535 | { |
| 536 | if (m_texture != XGL_NULL_HANDLE) xglDestroyObject(m_texture); |
| 537 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 538 | |
| 539 | void XglTextureObj::ChangeColors(uint32_t color1, uint32_t color2) |
| 540 | { |
| 541 | XGL_RESULT err; |
| 542 | const uint32_t tex_colors[2] = { color1, color2 }; |
| 543 | XGL_VOID *data; |
| 544 | |
| 545 | err = xglMapMemory(m_textureMem, 0, &data); |
| 546 | assert(!err); |
| 547 | |
| 548 | for (int y = 0; y < m_texHeight; y++) { |
| 549 | uint32_t *row = (uint32_t *) ((char *) data + m_rowPitch * y); |
| 550 | for (int x = 0; x < m_texWidth; x++) |
| 551 | row[x] = tex_colors[(x & 1) ^ (y & 1)]; |
| 552 | } |
| 553 | |
| 554 | err = xglUnmapMemory(m_textureMem); |
| 555 | assert(!err); |
| 556 | } |
| 557 | |
| 558 | XglSamplerObj::XglSamplerObj(XglDevice *device) |
| 559 | { |
| 560 | XGL_RESULT err = XGL_SUCCESS; |
| 561 | |
| 562 | m_device = device; |
| 563 | memset(&m_samplerCreateInfo,0,sizeof(m_samplerCreateInfo)); |
| 564 | m_samplerCreateInfo.sType = XGL_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; |
| 565 | m_samplerCreateInfo.magFilter = XGL_TEX_FILTER_NEAREST; |
| 566 | m_samplerCreateInfo.minFilter = XGL_TEX_FILTER_NEAREST; |
| 567 | m_samplerCreateInfo.mipMode = XGL_TEX_MIPMAP_BASE; |
| 568 | m_samplerCreateInfo.addressU = XGL_TEX_ADDRESS_WRAP; |
| 569 | m_samplerCreateInfo.addressV = XGL_TEX_ADDRESS_WRAP; |
| 570 | m_samplerCreateInfo.addressW = XGL_TEX_ADDRESS_WRAP; |
| 571 | m_samplerCreateInfo.mipLodBias = 0.0; |
| 572 | m_samplerCreateInfo.maxAnisotropy = 0.0; |
| 573 | m_samplerCreateInfo.compareFunc = XGL_COMPARE_NEVER; |
| 574 | m_samplerCreateInfo.minLod = 0.0; |
| 575 | m_samplerCreateInfo.maxLod = 0.0; |
| 576 | m_samplerCreateInfo.borderColorType = XGL_BORDER_COLOR_OPAQUE_WHITE; |
| 577 | |
| 578 | err = xglCreateSampler(m_device->device(),&m_samplerCreateInfo, &m_sampler); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 579 | assert(!err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 580 | |
| 581 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 582 | |
Tony Barbour | f325bf1 | 2014-12-03 15:59:38 -0700 | [diff] [blame] | 583 | XglSamplerObj::~XglSamplerObj() |
| 584 | { |
| 585 | if (m_sampler != XGL_NULL_HANDLE) xglDestroyObject(m_sampler); |
| 586 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 587 | |
Courtney Goeltzenleuchter | 3b0a815 | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 588 | /* |
| 589 | * Basic ConstantBuffer constructor. Then use create methods to fill in the details. |
| 590 | */ |
| 591 | XglConstantBufferObj::XglConstantBufferObj(XglDevice *device) |
| 592 | { |
| 593 | m_device = device; |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 594 | m_commandBuffer = 0; |
Courtney Goeltzenleuchter | 3b0a815 | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 595 | |
| 596 | memset(&m_constantBufferView,0,sizeof(m_constantBufferView)); |
Courtney Goeltzenleuchter | 3b0a815 | 2014-12-04 15:18:47 -0700 | [diff] [blame] | 597 | } |
| 598 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 599 | XglConstantBufferObj::XglConstantBufferObj(XglDevice *device, int constantCount, int constantSize, const void* data) |
| 600 | { |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 601 | m_device = device; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 602 | m_commandBuffer = 0; |
| 603 | |
| 604 | memset(&m_constantBufferView,0,sizeof(m_constantBufferView)); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 605 | m_numVertices = constantCount; |
| 606 | m_stride = constantSize; |
| 607 | |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 608 | const size_t allocationSize = constantCount * constantSize; |
| 609 | init(*m_device, allocationSize); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 610 | |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 611 | void *pData = map(); |
| 612 | memcpy(pData, data, allocationSize); |
| 613 | unmap(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 614 | |
| 615 | // set up the memory view for the constant buffer |
| 616 | this->m_constantBufferView.stride = 16; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 617 | this->m_constantBufferView.range = allocationSize; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 618 | this->m_constantBufferView.offset = 0; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 619 | this->m_constantBufferView.mem = obj(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 620 | this->m_constantBufferView.format.channelFormat = XGL_CH_FMT_R32G32B32A32; |
| 621 | this->m_constantBufferView.format.numericFormat = XGL_NUM_FMT_FLOAT; |
| 622 | this->m_constantBufferView.state = XGL_MEMORY_STATE_DATA_TRANSFER; |
| 623 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 624 | |
Courtney Goeltzenleuchter | 3764030 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 625 | void XglConstantBufferObj::Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset, XGL_UINT binding) |
| 626 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 627 | xglCmdBindVertexData(cmdBuffer, obj(), offset, binding); |
Courtney Goeltzenleuchter | 3764030 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | |
Tony Barbour | 099a9eb | 2014-12-10 17:40:15 -0700 | [diff] [blame] | 631 | void XglConstantBufferObj::SetMemoryState(XGL_MEMORY_STATE newState) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 632 | { |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 633 | XGL_RESULT err = XGL_SUCCESS; |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 634 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 635 | if (this->m_constantBufferView.state == newState) |
| 636 | return; |
| 637 | |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 638 | if (!m_commandBuffer) |
| 639 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 640 | m_fence.init(*m_device, xgl_testing::Fence::create_info(0)); |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 641 | |
| 642 | m_commandBuffer = new XglCommandBufferObj(m_device); |
| 643 | |
| 644 | } |
| 645 | else |
| 646 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 647 | m_device->wait(m_fence); |
Tony Barbour | 3842280 | 2014-12-10 14:36:31 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 650 | // open the command buffer |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 651 | err = m_commandBuffer->BeginCommandBuffer(0); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 652 | ASSERT_XGL_SUCCESS(err); |
| 653 | |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 654 | XGL_MEMORY_STATE_TRANSITION transition = |
| 655 | state_transition(XGL_MEMORY_STATE_DATA_TRANSFER, newState, 0, m_numVertices * m_stride); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 656 | |
| 657 | // write transition to the command buffer |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 658 | m_commandBuffer->PrepareMemoryRegions(1, &transition); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 659 | this->m_constantBufferView.state = newState; |
| 660 | |
| 661 | // finish recording the command buffer |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 662 | err = m_commandBuffer->EndCommandBuffer(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 663 | ASSERT_XGL_SUCCESS(err); |
| 664 | |
| 665 | XGL_UINT32 numMemRefs=1; |
| 666 | XGL_MEMORY_REF memRefs; |
| 667 | // this command buffer only uses the vertex buffer memory |
| 668 | memRefs.flags = 0; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 669 | memRefs.mem = obj(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 670 | |
| 671 | // submit the command buffer to the universal queue |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 672 | XGL_CMD_BUFFER bufferArray[1]; |
| 673 | bufferArray[0] = m_commandBuffer->GetBufferHandle(); |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 674 | err = xglQueueSubmit( m_device->m_queue, 1, bufferArray, numMemRefs, &memRefs, m_fence.obj() ); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 675 | ASSERT_XGL_SUCCESS(err); |
| 676 | } |
| 677 | |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 678 | XglIndexBufferObj::XglIndexBufferObj(XglDevice *device) |
| 679 | : XglConstantBufferObj(device) |
| 680 | { |
| 681 | |
| 682 | } |
| 683 | |
| 684 | void XglIndexBufferObj::CreateAndInitBuffer(int numIndexes, XGL_INDEX_TYPE indexType, const void* data) |
| 685 | { |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 686 | XGL_FORMAT viewFormat; |
| 687 | |
| 688 | m_numVertices = numIndexes; |
| 689 | m_indexType = indexType; |
| 690 | viewFormat.numericFormat = XGL_NUM_FMT_UINT; |
| 691 | switch (indexType) { |
| 692 | case XGL_INDEX_8: |
| 693 | m_stride = 1; |
| 694 | viewFormat.channelFormat = XGL_CH_FMT_R8; |
| 695 | break; |
| 696 | case XGL_INDEX_16: |
| 697 | m_stride = 2; |
| 698 | viewFormat.channelFormat = XGL_CH_FMT_R16; |
| 699 | break; |
| 700 | case XGL_INDEX_32: |
| 701 | m_stride = 4; |
| 702 | viewFormat.channelFormat = XGL_CH_FMT_R32; |
| 703 | break; |
Chia-I Wu | b4c2aa4 | 2014-12-15 23:50:11 +0800 | [diff] [blame] | 704 | default: |
| 705 | assert(!"unknown index type"); |
| 706 | break; |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 709 | const size_t allocationSize = numIndexes * m_stride; |
| 710 | init(*m_device, allocationSize); |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 711 | |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 712 | void *pData = map(); |
| 713 | memcpy(pData, data, allocationSize); |
| 714 | unmap(); |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 715 | |
| 716 | // set up the memory view for the constant buffer |
| 717 | this->m_constantBufferView.stride = m_stride; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 718 | this->m_constantBufferView.range = allocationSize; |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 719 | this->m_constantBufferView.offset = 0; |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 720 | this->m_constantBufferView.mem = obj(); |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 721 | this->m_constantBufferView.format.channelFormat = viewFormat.channelFormat; |
| 722 | this->m_constantBufferView.format.numericFormat = viewFormat.numericFormat; |
| 723 | this->m_constantBufferView.state = XGL_MEMORY_STATE_DATA_TRANSFER; |
| 724 | } |
| 725 | |
| 726 | void XglIndexBufferObj::Bind(XGL_CMD_BUFFER cmdBuffer, XGL_GPU_SIZE offset) |
| 727 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 728 | xglCmdBindIndexData(cmdBuffer, obj(), offset, m_indexType); |
Courtney Goeltzenleuchter | 8a78593 | 2014-12-04 15:24:05 -0700 | [diff] [blame] | 729 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 730 | |
Tony Barbour | af1f919 | 2014-12-17 10:57:58 -0700 | [diff] [blame] | 731 | XGL_INDEX_TYPE XglIndexBufferObj::GetIndexType() |
| 732 | { |
| 733 | return m_indexType; |
| 734 | } |
| 735 | |
Tony Barbour | 5420af0 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 736 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* XglShaderObj::GetStageCreateInfo(XglDescriptorSetObj *descriptorSet) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 737 | { |
| 738 | XGL_DESCRIPTOR_SLOT_INFO *slotInfo; |
| 739 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO *stageInfo = (XGL_PIPELINE_SHADER_STAGE_CREATE_INFO*) calloc( 1,sizeof(XGL_PIPELINE_SHADER_STAGE_CREATE_INFO) ); |
| 740 | stageInfo->sType = XGL_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; |
| 741 | stageInfo->shader.stage = m_stage; |
| 742 | stageInfo->shader.shader = m_shader; |
| 743 | stageInfo->shader.descriptorSetMapping[0].descriptorCount = 0; |
| 744 | stageInfo->shader.linkConstBufferCount = 0; |
| 745 | stageInfo->shader.pLinkConstBufferInfo = XGL_NULL_HANDLE; |
| 746 | stageInfo->shader.dynamicMemoryViewMapping.slotObjectType = XGL_SLOT_UNUSED; |
| 747 | stageInfo->shader.dynamicMemoryViewMapping.shaderEntityIndex = 0; |
| 748 | |
Tony Barbour | 824b771 | 2014-12-18 17:06:21 -0700 | [diff] [blame] | 749 | stageInfo->shader.descriptorSetMapping[0].descriptorCount = descriptorSet->GetTotalSlots(); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 750 | if (stageInfo->shader.descriptorSetMapping[0].descriptorCount) |
| 751 | { |
| 752 | vector<int> allSlots; |
| 753 | vector<XGL_DESCRIPTOR_SET_SLOT_TYPE> allTypes; |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 754 | vector<void *> allObjs; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 755 | |
| 756 | allSlots.reserve(m_memSlots.size() + m_imageSlots.size() + m_samplerSlots.size()); |
| 757 | allTypes.reserve(m_memTypes.size() + m_imageTypes.size() + m_samplerTypes.size()); |
| 758 | allObjs.reserve(m_memObjs.size() + m_imageObjs.size() + m_samplerObjs.size()); |
| 759 | |
| 760 | if (m_memSlots.size()) |
| 761 | { |
| 762 | allSlots.insert(allSlots.end(), m_memSlots.begin(), m_memSlots.end()); |
| 763 | allTypes.insert(allTypes.end(), m_memTypes.begin(), m_memTypes.end()); |
| 764 | allObjs.insert(allObjs.end(), m_memObjs.begin(), m_memObjs.end()); |
| 765 | } |
| 766 | if (m_imageSlots.size()) |
| 767 | { |
| 768 | allSlots.insert(allSlots.end(), m_imageSlots.begin(), m_imageSlots.end()); |
| 769 | allTypes.insert(allTypes.end(), m_imageTypes.begin(), m_imageTypes.end()); |
| 770 | allObjs.insert(allObjs.end(), m_imageObjs.begin(), m_imageObjs.end()); |
| 771 | } |
| 772 | if (m_samplerSlots.size()) |
| 773 | { |
| 774 | allSlots.insert(allSlots.end(), m_samplerSlots.begin(), m_samplerSlots.end()); |
| 775 | allTypes.insert(allTypes.end(), m_samplerTypes.begin(), m_samplerTypes.end()); |
| 776 | allObjs.insert(allObjs.end(), m_samplerObjs.begin(), m_samplerObjs.end()); |
| 777 | } |
| 778 | |
Tony Barbour | 5420af0 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 779 | slotInfo = descriptorSet->GetSlotInfo(allSlots, allTypes, allObjs); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 780 | stageInfo->shader.descriptorSetMapping[0].pDescriptorInfo = (const XGL_DESCRIPTOR_SLOT_INFO*) slotInfo; |
| 781 | } |
| 782 | return stageInfo; |
| 783 | } |
| 784 | |
| 785 | void XglShaderObj::BindShaderEntitySlotToMemory(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglConstantBufferObj *constantBuffer) |
| 786 | { |
| 787 | m_memSlots.push_back(slot); |
| 788 | m_memTypes.push_back(type); |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 789 | m_memObjs.push_back(&constantBuffer->m_constantBufferView); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 790 | |
| 791 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 792 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 793 | void XglShaderObj::BindShaderEntitySlotToImage(int slot, XGL_DESCRIPTOR_SET_SLOT_TYPE type, XglTextureObj *texture) |
| 794 | { |
| 795 | m_imageSlots.push_back(slot); |
| 796 | m_imageTypes.push_back(type); |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 797 | m_imageObjs.push_back(&texture->m_textureViewInfo); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 798 | |
| 799 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 800 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 801 | void XglShaderObj::BindShaderEntitySlotToSampler(int slot, XglSamplerObj *sampler) |
| 802 | { |
| 803 | m_samplerSlots.push_back(slot); |
| 804 | m_samplerTypes.push_back(XGL_SLOT_SHADER_SAMPLER); |
Chia-I Wu | c86b54c | 2014-12-28 16:07:01 +0800 | [diff] [blame^] | 805 | m_samplerObjs.push_back(sampler); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 806 | |
| 807 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 808 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 809 | XglShaderObj::XglShaderObj(XglDevice *device, const char * shader_code, XGL_PIPELINE_SHADER_STAGE stage, XglRenderFramework *framework) |
| 810 | { |
| 811 | XGL_RESULT err = XGL_SUCCESS; |
| 812 | std::vector<unsigned int> bil; |
| 813 | XGL_SHADER_CREATE_INFO createInfo; |
| 814 | size_t shader_len; |
| 815 | |
| 816 | m_stage = stage; |
| 817 | m_device = device; |
| 818 | |
| 819 | createInfo.sType = XGL_STRUCTURE_TYPE_SHADER_CREATE_INFO; |
| 820 | createInfo.pNext = NULL; |
| 821 | |
| 822 | if (!framework->m_use_bil) { |
| 823 | |
| 824 | shader_len = strlen(shader_code); |
| 825 | createInfo.codeSize = 3 * sizeof(uint32_t) + shader_len + 1; |
| 826 | createInfo.pCode = malloc(createInfo.codeSize); |
| 827 | createInfo.flags = 0; |
| 828 | |
| 829 | /* try version 0 first: XGL_PIPELINE_SHADER_STAGE followed by GLSL */ |
| 830 | ((uint32_t *) createInfo.pCode)[0] = ICD_BIL_MAGIC; |
| 831 | ((uint32_t *) createInfo.pCode)[1] = 0; |
| 832 | ((uint32_t *) createInfo.pCode)[2] = stage; |
| 833 | memcpy(((uint32_t *) createInfo.pCode + 3), shader_code, shader_len + 1); |
| 834 | |
| 835 | err = xglCreateShader(m_device->device(), &createInfo, &m_shader); |
| 836 | if (err) { |
| 837 | free((void *) createInfo.pCode); |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | if (framework->m_use_bil || err) { |
| 842 | std::vector<unsigned int> bil; |
| 843 | err = XGL_SUCCESS; |
| 844 | |
| 845 | // Use Reference GLSL to BIL compiler |
| 846 | framework->GLSLtoBIL(stage, shader_code, bil); |
| 847 | createInfo.pCode = bil.data(); |
| 848 | createInfo.codeSize = bil.size() * sizeof(unsigned int); |
| 849 | createInfo.flags = 0; |
| 850 | err = xglCreateShader(m_device->device(), &createInfo, &m_shader); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 851 | assert(!err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 852 | } |
| 853 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 854 | |
Tony Barbour | f325bf1 | 2014-12-03 15:59:38 -0700 | [diff] [blame] | 855 | XglShaderObj::~XglShaderObj() |
| 856 | { |
| 857 | if (m_shader != XGL_NULL_HANDLE) xglDestroyObject(m_shader); |
| 858 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 859 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 860 | XglPipelineObj::XglPipelineObj(XglDevice *device) |
| 861 | { |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 862 | m_device = device; |
| 863 | m_vi_state.attributeCount = m_vi_state.bindingCount = 0; |
| 864 | m_vertexBufferCount = 0; |
| 865 | |
| 866 | m_ia_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO; |
| 867 | m_ia_state.pNext = XGL_NULL_HANDLE; |
| 868 | m_ia_state.topology = XGL_TOPOLOGY_TRIANGLE_LIST; |
| 869 | m_ia_state.disableVertexReuse = XGL_FALSE; |
| 870 | m_ia_state.provokingVertex = XGL_PROVOKING_VERTEX_LAST; |
| 871 | m_ia_state.primitiveRestartEnable = XGL_FALSE; |
| 872 | m_ia_state.primitiveRestartIndex = 0; |
| 873 | |
| 874 | m_rs_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO; |
| 875 | m_rs_state.pNext = &m_ia_state; |
| 876 | m_rs_state.depthClipEnable = XGL_FALSE; |
| 877 | m_rs_state.rasterizerDiscardEnable = XGL_FALSE; |
| 878 | m_rs_state.pointSize = 1.0; |
| 879 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 880 | memset(&m_cb_state,0,sizeof(m_cb_state)); |
| 881 | m_cb_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO; |
| 882 | m_cb_state.pNext = &m_rs_state; |
| 883 | m_cb_state.alphaToCoverageEnable = XGL_FALSE; |
| 884 | m_cb_state.dualSourceBlendEnable = XGL_FALSE; |
| 885 | m_cb_state.logicOp = XGL_LOGIC_OP_COPY; |
| 886 | |
Chia-I Wu | 62bf1dc | 2014-12-05 11:12:13 +0800 | [diff] [blame] | 887 | m_cb_state.attachment[0].blendEnable = XGL_FALSE; |
| 888 | m_cb_state.attachment[0].format.channelFormat = XGL_CH_FMT_R8G8B8A8; |
| 889 | m_cb_state.attachment[0].format.numericFormat = XGL_NUM_FMT_UNORM; |
| 890 | m_cb_state.attachment[0].channelWriteMask = 0xF; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 891 | |
| 892 | m_db_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_DB_STATE_CREATE_INFO, |
| 893 | m_db_state.pNext = &m_cb_state, |
| 894 | m_db_state.format.channelFormat = XGL_CH_FMT_R32; |
| 895 | m_db_state.format.numericFormat = XGL_NUM_FMT_DS; |
| 896 | |
| 897 | |
| 898 | }; |
| 899 | |
| 900 | void XglPipelineObj::AddShader(XglShaderObj* shader) |
| 901 | { |
| 902 | m_shaderObjs.push_back(shader); |
| 903 | } |
| 904 | |
| 905 | void XglPipelineObj::AddVertexInputAttribs(XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* vi_attrib, int count) |
| 906 | { |
| 907 | m_vi_state.pVertexAttributeDescriptions = vi_attrib; |
| 908 | m_vi_state.attributeCount = count; |
| 909 | } |
| 910 | |
| 911 | void XglPipelineObj::AddVertexInputBindings(XGL_VERTEX_INPUT_BINDING_DESCRIPTION* vi_binding, int count) |
| 912 | { |
| 913 | m_vi_state.pVertexBindingDescriptions = vi_binding; |
| 914 | m_vi_state.bindingCount = count; |
| 915 | } |
| 916 | |
| 917 | void XglPipelineObj::AddVertexDataBuffer(XglConstantBufferObj* vertexDataBuffer, int binding) |
| 918 | { |
| 919 | m_vertexBufferObjs.push_back(vertexDataBuffer); |
| 920 | m_vertexBufferBindings.push_back(binding); |
| 921 | m_vertexBufferCount++; |
| 922 | } |
| 923 | |
Chia-I Wu | ecebf75 | 2014-12-05 10:45:15 +0800 | [diff] [blame] | 924 | void XglPipelineObj::SetColorAttachment(XGL_UINT binding, const XGL_PIPELINE_CB_ATTACHMENT_STATE *att) |
| 925 | { |
| 926 | m_cb_state.attachment[binding] = *att; |
| 927 | } |
| 928 | |
Tony Barbour | 976e1cf | 2014-12-17 11:57:31 -0700 | [diff] [blame] | 929 | void XglPipelineObj::CreateXGLPipeline(XglDescriptorSetObj *descriptorSet) |
| 930 | { |
| 931 | XGL_RESULT err; |
| 932 | XGL_VOID* head_ptr = &m_db_state; |
| 933 | XGL_GRAPHICS_PIPELINE_CREATE_INFO info = {}; |
| 934 | |
| 935 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* shaderCreateInfo; |
| 936 | |
| 937 | for (int i=0; i<m_shaderObjs.size(); i++) |
| 938 | { |
| 939 | shaderCreateInfo = m_shaderObjs[i]->GetStageCreateInfo(descriptorSet); |
| 940 | shaderCreateInfo->pNext = head_ptr; |
| 941 | head_ptr = shaderCreateInfo; |
| 942 | } |
| 943 | |
| 944 | if (m_vi_state.attributeCount && m_vi_state.bindingCount) |
| 945 | { |
| 946 | m_vi_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO; |
| 947 | m_vi_state.pNext = head_ptr; |
| 948 | head_ptr = &m_vi_state; |
| 949 | } |
| 950 | |
| 951 | info.sType = XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 952 | info.pNext = head_ptr; |
| 953 | info.flags = 0; |
| 954 | |
| 955 | err = xglCreateGraphicsPipeline(m_device->device(), &info, &m_pipeline); |
| 956 | assert(!err); |
| 957 | |
| 958 | err = m_device->AllocAndBindGpuMemory(m_pipeline, "Pipeline", &m_pipe_mem); |
| 959 | assert(!err); |
| 960 | } |
| 961 | XGL_PIPELINE XglPipelineObj::GetPipelineHandle() |
| 962 | { |
| 963 | return m_pipeline; |
| 964 | } |
| 965 | |
Tony Barbour | 5420af0 | 2014-12-03 13:58:15 -0700 | [diff] [blame] | 966 | void XglPipelineObj::BindPipelineCommandBuffer(XGL_CMD_BUFFER m_cmdBuffer, XglDescriptorSetObj *descriptorSet) |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 967 | { |
| 968 | XGL_RESULT err; |
| 969 | XGL_VOID* head_ptr = &m_db_state; |
| 970 | XGL_GRAPHICS_PIPELINE_CREATE_INFO info = {}; |
| 971 | |
| 972 | XGL_PIPELINE_SHADER_STAGE_CREATE_INFO* shaderCreateInfo; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 973 | |
| 974 | for (int i=0; i<m_shaderObjs.size(); i++) |
| 975 | { |
| 976 | shaderCreateInfo = m_shaderObjs[i]->GetStageCreateInfo(descriptorSet); |
| 977 | shaderCreateInfo->pNext = head_ptr; |
| 978 | head_ptr = shaderCreateInfo; |
| 979 | } |
| 980 | |
| 981 | if (m_vi_state.attributeCount && m_vi_state.bindingCount) |
| 982 | { |
| 983 | m_vi_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO; |
| 984 | m_vi_state.pNext = head_ptr; |
| 985 | head_ptr = &m_vi_state; |
| 986 | } |
| 987 | |
| 988 | info.sType = XGL_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; |
| 989 | info.pNext = head_ptr; |
| 990 | info.flags = 0; |
| 991 | |
| 992 | err = xglCreateGraphicsPipeline(m_device->device(), &info, &m_pipeline); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 993 | assert(!err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 994 | |
| 995 | err = m_device->AllocAndBindGpuMemory(m_pipeline, "Pipeline", &m_pipe_mem); |
Tony Barbour | ba2a106 | 2014-12-03 09:24:05 -0700 | [diff] [blame] | 996 | assert(!err); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 997 | |
| 998 | xglCmdBindPipeline( m_cmdBuffer, XGL_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline ); |
| 999 | |
| 1000 | |
| 1001 | for (int i=0; i < m_vertexBufferCount; i++) |
| 1002 | { |
Courtney Goeltzenleuchter | 3764030 | 2014-12-04 15:26:56 -0700 | [diff] [blame] | 1003 | m_vertexBufferObjs[i]->Bind(m_cmdBuffer, m_vertexBufferObjs[i]->m_constantBufferView.offset, m_vertexBufferBindings[i]); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1004 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1005 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 1006 | |
Tony Barbour | f325bf1 | 2014-12-03 15:59:38 -0700 | [diff] [blame] | 1007 | XglPipelineObj::~XglPipelineObj() |
| 1008 | { |
| 1009 | if (m_pipeline != XGL_NULL_HANDLE) xglDestroyObject(m_pipeline); |
| 1010 | } |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1011 | |
| 1012 | XglMemoryRefManager::XglMemoryRefManager() { |
| 1013 | |
| 1014 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 1015 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1016 | void XglMemoryRefManager::AddMemoryRef(XglConstantBufferObj *constantBuffer) { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 1017 | m_bufferObjs.push_back(constantBuffer->obj()); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1018 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 1019 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1020 | void XglMemoryRefManager::AddMemoryRef(XglTextureObj *texture) { |
Chia-I Wu | 283d7a6 | 2014-12-28 15:43:42 +0800 | [diff] [blame] | 1021 | m_bufferObjs.push_back(texture->m_textureMem); |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1022 | } |
Tony Barbour | 82c3952 | 2014-12-04 14:33:33 -0700 | [diff] [blame] | 1023 | |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1024 | XGL_MEMORY_REF* XglMemoryRefManager::GetMemoryRefList() { |
| 1025 | |
| 1026 | XGL_MEMORY_REF *localRefs; |
| 1027 | XGL_UINT32 numRefs=m_bufferObjs.size(); |
| 1028 | |
| 1029 | if (numRefs <= 0) |
| 1030 | return NULL; |
| 1031 | |
| 1032 | localRefs = (XGL_MEMORY_REF*) malloc( numRefs * sizeof(XGL_MEMORY_REF) ); |
| 1033 | for (int i=0; i<numRefs; i++) |
| 1034 | { |
| 1035 | localRefs[i].flags = 0; |
Chia-I Wu | 283d7a6 | 2014-12-28 15:43:42 +0800 | [diff] [blame] | 1036 | localRefs[i].mem = m_bufferObjs[i]; |
Tony Barbour | e2c58df | 2014-11-25 13:18:32 -0700 | [diff] [blame] | 1037 | } |
| 1038 | return localRefs; |
| 1039 | } |
| 1040 | int XglMemoryRefManager::GetNumRefs() { |
| 1041 | return m_bufferObjs.size(); |
| 1042 | } |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1043 | |
| 1044 | XglCommandBufferObj::XglCommandBufferObj(XglDevice *device) |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1045 | : xgl_testing::CmdBuffer(*device, xgl_testing::CmdBuffer::create_info(XGL_QUEUE_TYPE_GRAPHICS)) |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1046 | { |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1047 | m_device = device; |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1048 | m_renderTargetCount = 0; |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1049 | } |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 1050 | |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1051 | XGL_CMD_BUFFER XglCommandBufferObj::GetBufferHandle() |
| 1052 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1053 | return obj(); |
Tony Barbour | 6d047bf | 2014-12-10 14:34:45 -0700 | [diff] [blame] | 1054 | } |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 1055 | |
| 1056 | XGL_RESULT XglCommandBufferObj::BeginCommandBuffer(XGL_FLAGS flags) |
| 1057 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1058 | begin(flags); |
| 1059 | return XGL_SUCCESS; |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 1060 | } |
| 1061 | |
| 1062 | XGL_RESULT XglCommandBufferObj::EndCommandBuffer() |
| 1063 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1064 | end(); |
| 1065 | return XGL_SUCCESS; |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | void XglCommandBufferObj::PrepareMemoryRegions(int transitionCount, XGL_MEMORY_STATE_TRANSITION *transitionPtr) |
| 1069 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1070 | xglCmdPrepareMemoryRegions(obj(), transitionCount, transitionPtr); |
Tony Barbour | 471338d | 2014-12-10 17:28:39 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1073 | void XglCommandBufferObj::ClearAllBuffers(XGL_DEPTH_STENCIL_BIND_INFO *depthStencilBinding, XGL_IMAGE depthStencilImage) |
| 1074 | { |
| 1075 | XGL_UINT i; |
| 1076 | |
| 1077 | // whatever we want to do, we do it to the whole buffer |
| 1078 | XGL_IMAGE_SUBRESOURCE_RANGE srRange = {}; |
| 1079 | srRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 1080 | srRange.baseMipLevel = 0; |
| 1081 | srRange.mipLevels = XGL_LAST_MIP_OR_SLICE; |
| 1082 | srRange.baseArraySlice = 0; |
| 1083 | srRange.arraySize = XGL_LAST_MIP_OR_SLICE; |
| 1084 | |
| 1085 | // clear the back buffer to dark grey |
| 1086 | XGL_UINT clearColor[4] = {64, 64, 64, 0}; |
| 1087 | XGL_IMAGE_STATE_TRANSITION transitionToClear = {}; |
| 1088 | for (i = 0; i < m_renderTargetCount; i++) { |
| 1089 | transitionToClear.image = m_renderTargets[i]->image(); |
| 1090 | transitionToClear.oldState = m_renderTargets[i]->state(); |
| 1091 | transitionToClear.newState = XGL_IMAGE_STATE_CLEAR; |
| 1092 | transitionToClear.subresourceRange = srRange; |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1093 | xglCmdPrepareImages( obj(), 1, &transitionToClear ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1094 | m_renderTargets[i]->state(( XGL_IMAGE_STATE ) transitionToClear.newState); |
| 1095 | |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1096 | xglCmdClearColorImageRaw( obj(), m_renderTargets[i]->image(), clearColor, 1, &srRange ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1097 | } |
| 1098 | |
| 1099 | if (depthStencilImage) |
| 1100 | { |
| 1101 | XGL_IMAGE_SUBRESOURCE_RANGE dsRange = {}; |
| 1102 | dsRange.aspect = XGL_IMAGE_ASPECT_DEPTH; |
| 1103 | dsRange.baseMipLevel = 0; |
| 1104 | dsRange.mipLevels = XGL_LAST_MIP_OR_SLICE; |
| 1105 | dsRange.baseArraySlice = 0; |
| 1106 | dsRange.arraySize = XGL_LAST_MIP_OR_SLICE; |
| 1107 | |
| 1108 | // prepare the depth buffer for clear |
| 1109 | memset(&transitionToClear,0,sizeof(transitionToClear)); |
| 1110 | transitionToClear.image = depthStencilImage; |
| 1111 | transitionToClear.oldState = depthStencilBinding->depthState; |
| 1112 | transitionToClear.newState = XGL_IMAGE_STATE_CLEAR; |
| 1113 | transitionToClear.subresourceRange = dsRange; |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1114 | xglCmdPrepareImages( obj(), 1, &transitionToClear ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1115 | depthStencilBinding->depthState = transitionToClear.newState; |
| 1116 | |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1117 | xglCmdClearDepthStencil(obj(), depthStencilImage, 1.0f, 0, 1, &dsRange); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1118 | |
| 1119 | // prepare depth buffer for rendering |
| 1120 | XGL_IMAGE_STATE_TRANSITION transitionToRender = {}; |
| 1121 | transitionToRender.image = depthStencilImage; |
| 1122 | transitionToRender.oldState = XGL_IMAGE_STATE_CLEAR; |
| 1123 | transitionToRender.newState = depthStencilBinding->depthState; |
| 1124 | transitionToRender.subresourceRange = dsRange; |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1125 | xglCmdPrepareImages( obj(), 1, &transitionToRender ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1126 | depthStencilBinding->depthState = transitionToClear.newState; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | void XglCommandBufferObj::BindAttachments(XGL_DEPTH_STENCIL_BIND_INFO *depthStencilBinding) |
| 1131 | { |
| 1132 | XGL_UINT i; |
| 1133 | XGL_COLOR_ATTACHMENT_BIND_INFO colorBindings[XGL_MAX_COLOR_ATTACHMENTS]; |
| 1134 | XGL_IMAGE_SUBRESOURCE_RANGE srRange = {}; |
| 1135 | srRange.aspect = XGL_IMAGE_ASPECT_COLOR; |
| 1136 | srRange.baseMipLevel = 0; |
| 1137 | srRange.mipLevels = XGL_LAST_MIP_OR_SLICE; |
| 1138 | srRange.baseArraySlice = 0; |
| 1139 | srRange.arraySize = XGL_LAST_MIP_OR_SLICE; |
| 1140 | |
| 1141 | XGL_IMAGE_STATE_TRANSITION transitionToRender = {}; |
| 1142 | for(i=0; i<m_renderTargetCount; i++) |
| 1143 | { |
| 1144 | transitionToRender.image = m_renderTargets[i]->image(); |
| 1145 | transitionToRender.oldState = m_renderTargets[i]->state(); |
| 1146 | transitionToRender.newState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL; |
| 1147 | transitionToRender.subresourceRange = srRange; |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1148 | xglCmdPrepareImages(obj(), 1, &transitionToRender ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1149 | m_renderTargets[i]->state(( XGL_IMAGE_STATE ) transitionToRender.newState); |
| 1150 | } |
| 1151 | for (i = 0; i < m_renderTargetCount; i++) { |
| 1152 | colorBindings[i].view = m_renderTargets[i]->targetView(); |
| 1153 | colorBindings[i].colorAttachmentState = XGL_IMAGE_STATE_TARGET_RENDER_ACCESS_OPTIMAL; |
| 1154 | } |
| 1155 | if (depthStencilBinding) { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1156 | xglCmdBindAttachments(obj(), m_renderTargetCount, colorBindings, depthStencilBinding ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1157 | } else { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1158 | xglCmdBindAttachments(obj(), m_renderTargetCount, colorBindings, XGL_NULL_HANDLE ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | void XglCommandBufferObj::BindState(XGL_RASTER_STATE_OBJECT stateRaster, XGL_VIEWPORT_STATE_OBJECT stateViewport, |
| 1163 | XGL_COLOR_BLEND_STATE_OBJECT colorBlend, XGL_DEPTH_STENCIL_STATE_OBJECT stateDepthStencil, |
| 1164 | XGL_MSAA_STATE_OBJECT stateMsaa) |
| 1165 | { |
| 1166 | // set all states |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1167 | xglCmdBindStateObject( obj(), XGL_STATE_BIND_RASTER, stateRaster ); |
| 1168 | xglCmdBindStateObject( obj(), XGL_STATE_BIND_VIEWPORT, stateViewport ); |
| 1169 | xglCmdBindStateObject( obj(), XGL_STATE_BIND_COLOR_BLEND, colorBlend); |
| 1170 | xglCmdBindStateObject( obj(), XGL_STATE_BIND_DEPTH_STENCIL, stateDepthStencil ); |
| 1171 | xglCmdBindStateObject( obj(), XGL_STATE_BIND_MSAA, stateMsaa ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | void XglCommandBufferObj::AddRenderTarget(XglImage *renderTarget) |
| 1175 | { |
| 1176 | m_renderTargets.push_back(renderTarget); |
| 1177 | m_renderTargetCount++; |
| 1178 | } |
| 1179 | |
| 1180 | void XglCommandBufferObj::DrawIndexed(XGL_UINT firstIndex, XGL_UINT indexCount, XGL_INT vertexOffset, XGL_UINT firstInstance, XGL_UINT instanceCount) |
| 1181 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1182 | xglCmdDrawIndexed(obj(), firstIndex, indexCount, vertexOffset, firstInstance, instanceCount); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | void XglCommandBufferObj::Draw(XGL_UINT firstVertex, XGL_UINT vertexCount, XGL_UINT firstInstance, XGL_UINT instanceCount) |
| 1186 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1187 | xglCmdDraw(obj(), firstVertex, vertexCount, firstInstance, instanceCount); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | void XglCommandBufferObj::QueueCommandBuffer(XGL_MEMORY_REF *memRefs, XGL_UINT32 numMemRefs) |
| 1191 | { |
| 1192 | XGL_RESULT err = XGL_SUCCESS; |
| 1193 | |
| 1194 | // submit the command buffer to the universal queue |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1195 | err = xglQueueSubmit( m_device->m_queue, 1, &obj(), numMemRefs, memRefs, NULL ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1196 | ASSERT_XGL_SUCCESS( err ); |
| 1197 | |
| 1198 | err = xglQueueWaitIdle( m_device->m_queue ); |
| 1199 | ASSERT_XGL_SUCCESS( err ); |
| 1200 | |
| 1201 | // Wait for work to finish before cleaning up. |
| 1202 | xglDeviceWaitIdle(m_device->device()); |
| 1203 | |
| 1204 | } |
| 1205 | void XglCommandBufferObj::BindPipeline(XGL_PIPELINE pipeline) |
| 1206 | { |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1207 | xglCmdBindPipeline( obj(), XGL_PIPELINE_BIND_POINT_GRAPHICS, pipeline ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | void XglCommandBufferObj::BindDescriptorSet(XGL_DESCRIPTOR_SET descriptorSet) |
| 1211 | { |
| 1212 | // bind pipeline, vertex buffer (descriptor set) and WVP (dynamic memory view) |
Chia-I Wu | d28343c | 2014-12-28 15:12:48 +0800 | [diff] [blame] | 1213 | xglCmdBindDescriptorSet(obj(), XGL_PIPELINE_BIND_POINT_GRAPHICS, 0, descriptorSet, 0 ); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1214 | } |
| 1215 | void XglCommandBufferObj::BindIndexBuffer(XglIndexBufferObj *indexBuffer, XGL_UINT offset) |
| 1216 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 1217 | xglCmdBindIndexData(obj(), indexBuffer->obj(), offset, indexBuffer->GetIndexType()); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1218 | } |
| 1219 | void XglCommandBufferObj::BindVertexBuffer(XglConstantBufferObj *vertexBuffer, XGL_UINT offset, XGL_UINT binding) |
| 1220 | { |
Chia-I Wu | a07fee6 | 2014-12-28 15:26:08 +0800 | [diff] [blame] | 1221 | xglCmdBindVertexData(obj(), vertexBuffer->obj(), offset, binding); |
Tony Barbour | 30cc9e8 | 2014-12-17 11:53:55 -0700 | [diff] [blame] | 1222 | } |