OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
9 | 9 |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return false; | 358 return false; |
359 } | 359 } |
360 } | 360 } |
361 success = this->uploadTexDataOptimal(vkTex, left, top, width, height
, config, texels); | 361 success = this->uploadTexDataOptimal(vkTex, left, top, width, height
, config, texels); |
362 } | 362 } |
363 } | 363 } |
364 | 364 |
365 return success; | 365 return success; |
366 } | 366 } |
367 | 367 |
| 368 void GrVkGpu::onResolveRenderTarget(GrRenderTarget* target) { |
| 369 if (target->needsResolve()) { |
| 370 SkASSERT(target->numColorSamples() > 1); |
| 371 |
| 372 GrVkRenderTarget* rt = static_cast<GrVkRenderTarget*>(target); |
| 373 SkASSERT(rt->msaaImage()); |
| 374 |
| 375 // Flip rect if necessary |
| 376 SkIRect srcVkRect = rt->getResolveRect(); |
| 377 |
| 378 if (kBottomLeft_GrSurfaceOrigin == rt->origin()) { |
| 379 srcVkRect.fTop = rt->height() - rt->getResolveRect().fBottom; |
| 380 srcVkRect.fBottom = rt->height() - rt->getResolveRect().fTop; |
| 381 } |
| 382 |
| 383 VkImageResolve resolveInfo; |
| 384 resolveInfo.srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; |
| 385 resolveInfo.srcOffset = { srcVkRect.fLeft, srcVkRect.fTop, 0 }; |
| 386 resolveInfo.dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 }; |
| 387 resolveInfo.dstOffset = { srcVkRect.fLeft, srcVkRect.fTop, 0 }; |
| 388 // By the spec the depth of the extent should be ignored for 2D images,
but certain devices |
| 389 // (e.g. nexus 5x) currently fail if it is not 1 |
| 390 resolveInfo.extent = { (uint32_t)srcVkRect.width(), (uint32_t)srcVkRect.
height(), 1 }; |
| 391 |
| 392 rt->setImageLayout(this, |
| 393 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, |
| 394 VK_ACCESS_TRANSFER_WRITE_BIT, |
| 395 VK_PIPELINE_STAGE_TRANSFER_BIT, |
| 396 false); |
| 397 |
| 398 rt->msaaImage()->setImageLayout(this, |
| 399 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 400 VK_ACCESS_TRANSFER_READ_BIT, |
| 401 VK_PIPELINE_STAGE_TRANSFER_BIT, |
| 402 false); |
| 403 |
| 404 fCurrentCmdBuffer->resolveImage(this, *rt, *rt->msaaImage(), 1, &resolve
Info); |
| 405 |
| 406 rt->flagAsResolved(); |
| 407 } |
| 408 } |
| 409 |
368 bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, | 410 bool GrVkGpu::uploadTexDataLinear(GrVkTexture* tex, |
369 int left, int top, int width, int height, | 411 int left, int top, int width, int height, |
370 GrPixelConfig dataConfig, | 412 GrPixelConfig dataConfig, |
371 const void* data, | 413 const void* data, |
372 size_t rowBytes) { | 414 size_t rowBytes) { |
373 SkASSERT(data); | 415 SkASSERT(data); |
374 SkASSERT(tex->isLinearTiled()); | 416 SkASSERT(tex->isLinearTiled()); |
375 | 417 |
376 // If we're uploading compressed data then we should be using uploadCompress
edTexData | 418 // If we're uploading compressed data then we should be using uploadCompress
edTexData |
377 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); | 419 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 } | 1604 } |
1563 | 1605 |
1564 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment | 1606 // Currently it is fine for us to always pass in 1 for the clear count even
if no attachment |
1565 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment | 1607 // uses it. In the current state, we also only use the LOAD_OP_CLEAR for the
color attachment |
1566 // which is always at the first attachment. | 1608 // which is always at the first attachment. |
1567 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); | 1609 fCurrentCmdBuffer->beginRenderPass(this, renderPass, 1, colorClear, *target,
*pBounds, true); |
1568 fCurrentCmdBuffer->executeCommands(this, buffer); | 1610 fCurrentCmdBuffer->executeCommands(this, buffer); |
1569 fCurrentCmdBuffer->endRenderPass(this); | 1611 fCurrentCmdBuffer->endRenderPass(this); |
1570 } | 1612 } |
1571 | 1613 |
OLD | NEW |