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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 GR_VK_CALL(fBackendContext->fInterface, | 505 GR_VK_CALL(fBackendContext->fInterface, |
505 CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[0], | 506 CmdPipelineBarrier(backbuffer->fTransitionCmdBuffers[0], |
506 srcStageMask, dstStageMask, 0, | 507 srcStageMask, dstStageMask, 0, |
507 0, nullptr, | 508 0, nullptr, |
508 0, nullptr, | 509 0, nullptr, |
509 1, &imageMemoryBarrier)); | 510 1, &imageMemoryBarrier)); |
510 | 511 |
511 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, | 512 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, |
512 EndCommandBuffer(backbuffer->fTransitionCmdBuffers[0]));
| 513 EndCommandBuffer(backbuffer->fTransitionCmdBuffers[0]));
|
513 | 514 |
| 515 VkPipelineStageFlags waitDstStageFlags = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_
OUTPUT_BIT; |
514 // insert the layout transfer into the queue and wait on the acquire | 516 // insert the layout transfer into the queue and wait on the acquire |
515 VkSubmitInfo submitInfo; | 517 VkSubmitInfo submitInfo; |
516 memset(&submitInfo, 0, sizeof(VkSubmitInfo)); | 518 memset(&submitInfo, 0, sizeof(VkSubmitInfo)); |
517 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | 519 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
518 submitInfo.waitSemaphoreCount = 1; | 520 submitInfo.waitSemaphoreCount = 1; |
519 submitInfo.pWaitSemaphores = &backbuffer->fAcquireSemaphore; | 521 submitInfo.pWaitSemaphores = &backbuffer->fAcquireSemaphore; |
520 submitInfo.pWaitDstStageMask = 0; | 522 submitInfo.pWaitDstStageMask = &waitDstStageFlags; |
521 submitInfo.commandBufferCount = 1; | 523 submitInfo.commandBufferCount = 1; |
522 submitInfo.pCommandBuffers = &backbuffer->fTransitionCmdBuffers[0]; | 524 submitInfo.pCommandBuffers = &backbuffer->fTransitionCmdBuffers[0]; |
523 submitInfo.signalSemaphoreCount = 0; | 525 submitInfo.signalSemaphoreCount = 0; |
524 | 526 |
525 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, | 527 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, |
526 QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, | 528 QueueSubmit(fBackendContext->fQueue, 1, &submitInfo, |
527 backbuffer->fUsageFences[0])); | 529 backbuffer->fUsageFences[0])); |
528 | 530 |
529 return fSurfaces[backbuffer->fImageIndex].get(); | 531 return fSurfaces[backbuffer->fImageIndex].get(); |
530 } | 532 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 1, // swapchainCount | 598 1, // swapchainCount |
597 &fSwapchain, // pSwapchains | 599 &fSwapchain, // pSwapchains |
598 &backbuffer->fImageIndex, // pImageIndices | 600 &backbuffer->fImageIndex, // pImageIndices |
599 NULL // pResults | 601 NULL // pResults |
600 }; | 602 }; |
601 | 603 |
602 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, | 604 GR_VK_CALL_ERRCHECK(fBackendContext->fInterface, |
603 QueuePresentKHR(fPresentQueue, &presentInfo)); | 605 QueuePresentKHR(fPresentQueue, &presentInfo)); |
604 | 606 |
605 } | 607 } |
OLD | NEW |