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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 382 |
383 // Release old command buffer and create a new one | 383 // Release old command buffer and create a new one |
384 fCurrentCmdBuffer->unref(this); | 384 fCurrentCmdBuffer->unref(this); |
385 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); | 385 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); |
386 SkASSERT(fCurrentCmdBuffer); | 386 SkASSERT(fCurrentCmdBuffer); |
387 | 387 |
388 fCurrentCmdBuffer->begin(this); | 388 fCurrentCmdBuffer->begin(this); |
389 } | 389 } |
390 | 390 |
391 /////////////////////////////////////////////////////////////////////////////// | 391 /////////////////////////////////////////////////////////////////////////////// |
392 GrVertexBuffer* GrVkGpu::onCreateVertexBuffer(size_t size, bool dynamic) { | 392 GrBuffer* GrVkGpu::onCreateBuffer(GrBufferType type, size_t size, GrAccessPatter
n accessPattern) { |
393 return GrVkVertexBuffer::Create(this, size, dynamic); | 393 switch (type) { |
394 } | 394 case kVertex_GrBufferType: |
395 | 395 return GrVkVertexBuffer::Create(this, size, accessPattern); |
396 GrIndexBuffer* GrVkGpu::onCreateIndexBuffer(size_t size, bool dynamic) { | 396 case kIndex_GrBufferType: |
397 return GrVkIndexBuffer::Create(this, size, dynamic); | 397 return GrVkIndexBuffer::Create(this, size, accessPattern); |
398 } | 398 case kXferCpuToGpu_GrBufferType: |
399 | 399 case kXferGpuToCpu_GrBufferType: |
400 GrTransferBuffer* GrVkGpu::onCreateTransferBuffer(size_t size, TransferType type
) { | 400 return GrVkTransferBuffer::Create(this, size, type); |
401 GrVkBuffer::Type bufferType = kCpuToGpu_TransferType ? GrVkBuffer::kCopyRead
_Type | 401 default: |
402 : GrVkBuffer::kCopyWrit
e_Type; | 402 SkFAIL("Unknown buffer type."); |
403 return GrVkTransferBuffer::Create(this, size, bufferType); | 403 return nullptr; |
| 404 } |
404 } | 405 } |
405 | 406 |
406 //////////////////////////////////////////////////////////////////////////////// | 407 //////////////////////////////////////////////////////////////////////////////// |
407 bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 408 bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
408 GrPixelConfig srcConfig, DrawPreference* draw
Preference, | 409 GrPixelConfig srcConfig, DrawPreference* draw
Preference, |
409 WritePixelTempDrawInfo* tempDrawInfo) { | 410 WritePixelTempDrawInfo* tempDrawInfo) { |
410 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { | 411 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { |
411 return false; | 412 return false; |
412 } | 413 } |
413 | 414 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 memcpy(mapPtr, data, trimRowBytes * height); | 550 memcpy(mapPtr, data, trimRowBytes * height); |
550 } else { | 551 } else { |
551 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data,
rowBytes, | 552 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data,
rowBytes, |
552 trimRowBytes, height); | 553 trimRowBytes, height); |
553 } | 554 } |
554 } | 555 } |
555 | 556 |
556 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->textureMemory())); | 557 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->textureMemory())); |
557 } else { | 558 } else { |
558 GrVkTransferBuffer* transferBuffer = | 559 GrVkTransferBuffer* transferBuffer = |
559 GrVkTransferBuffer::Create(this, trimRowBytes * height, GrVkBuffer::
kCopyRead_Type); | 560 GrVkTransferBuffer::Create(this, trimRowBytes * height, kXferCpuToGp
u_GrBufferType); |
560 | 561 |
561 void* mapPtr = transferBuffer->map(); | 562 void* mapPtr = transferBuffer->map(); |
562 | 563 |
563 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { | 564 if (kBottomLeft_GrSurfaceOrigin == desc.fOrigin) { |
564 // copy into buffer by rows | 565 // copy into buffer by rows |
565 const char* srcRow = reinterpret_cast<const char*>(data); | 566 const char* srcRow = reinterpret_cast<const char*>(data); |
566 char* dstRow = reinterpret_cast<char*>(mapPtr)+(height - 1)*trimRowB
ytes; | 567 char* dstRow = reinterpret_cast<char*>(mapPtr)+(height - 1)*trimRowB
ytes; |
567 for (int y = 0; y < height; y++) { | 568 for (int y = 0; y < height; y++) { |
568 memcpy(dstRow, srcRow, trimRowBytes); | 569 memcpy(dstRow, srcRow, trimRowBytes); |
569 srcRow += rowBytes; | 570 srcRow += rowBytes; |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; | 1435 VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
1435 tgt->setImageLayout(this, | 1436 tgt->setImageLayout(this, |
1436 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, | 1437 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
1437 srcAccessMask, | 1438 srcAccessMask, |
1438 dstAccessMask, | 1439 dstAccessMask, |
1439 srcStageMask, | 1440 srcStageMask, |
1440 dstStageMask, | 1441 dstStageMask, |
1441 false); | 1442 false); |
1442 | 1443 |
1443 GrVkTransferBuffer* transferBuffer = | 1444 GrVkTransferBuffer* transferBuffer = |
1444 reinterpret_cast<GrVkTransferBuffer*>(this->createTransferBuffer(rowByte
s * height, | 1445 GrVkTransferBuffer::Create(this, rowBytes * height, kXferGpuToCpu_GrBuff
erType); |
1445 kGpuToC
pu_TransferType)); | |
1446 | 1446 |
1447 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); | 1447 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); |
1448 VkOffset3D offset = { | 1448 VkOffset3D offset = { |
1449 left, | 1449 left, |
1450 flipY ? surface->height() - top - height : top, | 1450 flipY ? surface->height() - top - height : top, |
1451 0 | 1451 0 |
1452 }; | 1452 }; |
1453 | 1453 |
1454 // Copy the image to a buffer so we can map it to cpu memory | 1454 // Copy the image to a buffer so we can map it to cpu memory |
1455 VkBufferImageCopy region; | 1455 VkBufferImageCopy region; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 int set_a_break_pt_here = 9; | 1661 int set_a_break_pt_here = 9; |
1662 aglSwapBuffers(aglGetCurrentContext()); | 1662 aglSwapBuffers(aglGetCurrentContext()); |
1663 #elif defined(SK_BUILD_FOR_WIN32) | 1663 #elif defined(SK_BUILD_FOR_WIN32) |
1664 SwapBuf(); | 1664 SwapBuf(); |
1665 int set_a_break_pt_here = 9; | 1665 int set_a_break_pt_here = 9; |
1666 SwapBuf(); | 1666 SwapBuf(); |
1667 #endif | 1667 #endif |
1668 #endif | 1668 #endif |
1669 } | 1669 } |
1670 | 1670 |
OLD | NEW |