OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "SkSurface.h" | 10 #include "SkSurface.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (swapchainCreateInfo.oldSwapchain != VK_NULL_HANDLE) { | 233 if (swapchainCreateInfo.oldSwapchain != VK_NULL_HANDLE) { |
234 GR_VK_CALL(fBackendContext->fInterface, DeviceWaitIdle(fBackendContext->
fDevice)); | 234 GR_VK_CALL(fBackendContext->fInterface, DeviceWaitIdle(fBackendContext->
fDevice)); |
235 | 235 |
236 this->destroyBuffers(); | 236 this->destroyBuffers(); |
237 | 237 |
238 GR_VK_CALL(fBackendContext->fInterface, DestroySwapchainKHR(fBackendCont
ext->fDevice, | 238 GR_VK_CALL(fBackendContext->fInterface, DestroySwapchainKHR(fBackendCont
ext->fDevice, |
239 swapchainCrea
teInfo.oldSwapchain, | 239 swapchainCrea
teInfo.oldSwapchain, |
240 nullptr)); | 240 nullptr)); |
241 } | 241 } |
242 | 242 |
243 GrVkFormatToPixelConfig(swapchainCreateInfo.imageFormat, &fPixelConfig); | 243 this->createBuffers(swapchainCreateInfo.imageFormat); |
244 | |
245 this->createBuffers(); | |
246 | 244 |
247 return true; | 245 return true; |
248 } | 246 } |
249 | 247 |
250 void VulkanTestContext::createBuffers() { | 248 void VulkanTestContext::createBuffers(VkFormat format) { |
| 249 GrVkFormatToPixelConfig(format, &fPixelConfig); |
| 250 |
251 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, GetSwapchainImagesKHR(fBack
endContext->fDevice, | 251 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, GetSwapchainImagesKHR(fBack
endContext->fDevice, |
252 fSwap
chain, | 252 fSwap
chain, |
253 &fIma
geCount, | 253 &fIma
geCount, |
254 nullp
tr)); | 254 nullp
tr)); |
255 SkASSERT(fImageCount); | 255 SkASSERT(fImageCount); |
256 fImages = new VkImage[fImageCount]; | 256 fImages = new VkImage[fImageCount]; |
257 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, GetSwapchainImagesKHR(fBack
endContext->fDevice, | 257 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, GetSwapchainImagesKHR(fBack
endContext->fDevice, |
258 fSwap
chain, | 258 fSwap
chain, |
259 &fIma
geCount, | 259 &fIma
geCount, |
260 fImag
es)); | 260 fImag
es)); |
261 | 261 |
262 // set up initial image layouts and create surfaces | 262 // set up initial image layouts and create surfaces |
263 fImageLayouts = new VkImageLayout[fImageCount]; | 263 fImageLayouts = new VkImageLayout[fImageCount]; |
264 fSurfaces = new sk_sp<SkSurface>[fImageCount]; | 264 fSurfaces = new sk_sp<SkSurface>[fImageCount]; |
265 for (uint32_t i = 0; i < fImageCount; ++i) { | 265 for (uint32_t i = 0; i < fImageCount; ++i) { |
266 fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED; | 266 fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED; |
267 | 267 |
268 GrBackendRenderTargetDesc desc; | 268 GrBackendRenderTargetDesc desc; |
269 GrVkTextureInfo info; | 269 GrVkTextureInfo info; |
270 info.fImage = fImages[i]; | 270 info.fImage = fImages[i]; |
271 info.fAlloc = nullptr; | 271 info.fAlloc = nullptr; |
272 info.fImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; | 272 info.fImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; |
273 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL; | 273 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL; |
| 274 info.fFormat = format; |
274 desc.fWidth = fWidth; | 275 desc.fWidth = fWidth; |
275 desc.fHeight = fHeight; | 276 desc.fHeight = fHeight; |
276 desc.fConfig = fPixelConfig; | 277 desc.fConfig = fPixelConfig; |
277 desc.fOrigin = kTopLeft_GrSurfaceOrigin; | 278 desc.fOrigin = kTopLeft_GrSurfaceOrigin; |
278 desc.fSampleCnt = 0; | 279 desc.fSampleCnt = 0; |
279 desc.fStencilBits = 0; | 280 desc.fStencilBits = 0; |
280 desc.fRenderTargetHandle = (GrBackendObject) &info; | 281 desc.fRenderTargetHandle = (GrBackendObject) &info; |
281 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); | 282 SkSurfaceProps props(0, kUnknown_SkPixelGeometry); |
282 fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(fContext, desc, &p
rops); | 283 fSurfaces[i] = SkSurface::MakeFromBackendRenderTarget(fContext, desc, &p
rops); |
283 } | 284 } |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 1, // swapchainCount | 597 1, // swapchainCount |
597 &fSwapchain, // pSwapchains | 598 &fSwapchain, // pSwapchains |
598 &backbuffer->fImageIndex, // pImageIndices | 599 &backbuffer->fImageIndex, // pImageIndices |
599 NULL // pResults | 600 NULL // pResults |
600 }; | 601 }; |
601 | 602 |
602 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, | 603 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, |
603 QueuePresentKHR(fPresentQueue, &presentInfo)); | 604 QueuePresentKHR(fPresentQueue, &presentInfo)); |
604 | 605 |
605 } | 606 } |
OLD | NEW |