| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 164 |
| 165 // Release old command buffer and create a new one | 165 // Release old command buffer and create a new one |
| 166 fCurrentCmdBuffer->unref(this); | 166 fCurrentCmdBuffer->unref(this); |
| 167 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); | 167 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); |
| 168 SkASSERT(fCurrentCmdBuffer); | 168 SkASSERT(fCurrentCmdBuffer); |
| 169 | 169 |
| 170 fCurrentCmdBuffer->begin(this); | 170 fCurrentCmdBuffer->begin(this); |
| 171 } | 171 } |
| 172 | 172 |
| 173 /////////////////////////////////////////////////////////////////////////////// | 173 /////////////////////////////////////////////////////////////////////////////// |
| 174 GrVertexBuffer* GrVkGpu::onCreateVertexBuffer(size_t size, bool dynamic) { | 174 GrBuffer* GrVkGpu::onCreateBuffer(GrBufferType type, size_t size, GrAccessPatter
n accessPattern) { |
| 175 return GrVkVertexBuffer::Create(this, size, dynamic); | 175 switch (type) { |
| 176 } | 176 case kVertex_GrBufferType: |
| 177 | 177 SkASSERT(kDynamic_GrAccessPattern == accessPattern || |
| 178 GrIndexBuffer* GrVkGpu::onCreateIndexBuffer(size_t size, bool dynamic) { | 178 kStatic_GrAccessPattern == accessPattern); |
| 179 return GrVkIndexBuffer::Create(this, size, dynamic); | 179 return GrVkVertexBuffer::Create(this, size, kDynamic_GrAccessPattern
== accessPattern); |
| 180 } | 180 case kIndex_GrBufferType: |
| 181 | 181 SkASSERT(kDynamic_GrAccessPattern == accessPattern || |
| 182 GrTransferBuffer* GrVkGpu::onCreateTransferBuffer(size_t size, TransferType type
) { | 182 kStatic_GrAccessPattern == accessPattern); |
| 183 GrVkBuffer::Type bufferType = kCpuToGpu_TransferType ? GrVkBuffer::kCopyRead
_Type | 183 return GrVkIndexBuffer::Create(this, size, kDynamic_GrAccessPattern
== accessPattern); |
| 184 : GrVkBuffer::kCopyWrit
e_Type; | 184 case kXferCpuToGpu_GrBufferType: |
| 185 return GrVkTransferBuffer::Create(this, size, bufferType); | 185 SkASSERT(kStream_GrAccessPattern == accessPattern); |
| 186 return GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyRead_
Type); |
| 187 case kXferGpuToCpu_GrBufferType: |
| 188 SkASSERT(kStream_GrAccessPattern == accessPattern); |
| 189 return GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyWrite
_Type); |
| 190 default: |
| 191 SkFAIL("Unknown buffer type."); |
| 192 return nullptr; |
| 193 } |
| 186 } | 194 } |
| 187 | 195 |
| 188 //////////////////////////////////////////////////////////////////////////////// | 196 //////////////////////////////////////////////////////////////////////////////// |
| 189 bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, | 197 bool GrVkGpu::onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, |
| 190 GrPixelConfig srcConfig, DrawPreference* draw
Preference, | 198 GrPixelConfig srcConfig, DrawPreference* draw
Preference, |
| 191 WritePixelTempDrawInfo* tempDrawInfo) { | 199 WritePixelTempDrawInfo* tempDrawInfo) { |
| 192 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { | 200 if (kIndex_8_GrPixelConfig == srcConfig || GrPixelConfigIsCompressed(dstSurf
ace->config())) { |
| 193 return false; | 201 return false; |
| 194 } | 202 } |
| 195 | 203 |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; | 1218 VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; |
| 1211 tgt->setImageLayout(this, | 1219 tgt->setImageLayout(this, |
| 1212 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, | 1220 VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, |
| 1213 srcAccessMask, | 1221 srcAccessMask, |
| 1214 dstAccessMask, | 1222 dstAccessMask, |
| 1215 srcStageMask, | 1223 srcStageMask, |
| 1216 dstStageMask, | 1224 dstStageMask, |
| 1217 false); | 1225 false); |
| 1218 | 1226 |
| 1219 GrVkTransferBuffer* transferBuffer = | 1227 GrVkTransferBuffer* transferBuffer = |
| 1220 reinterpret_cast<GrVkTransferBuffer*>(this->createTransferBuffer(rowByte
s * height, | 1228 static_cast<GrVkTransferBuffer*>(this->createBuffer(kXferGpuToCpu_GrBuff
erType, |
| 1221 kGpuToC
pu_TransferType)); | 1229 rowBytes * height, |
| 1230 kStream_GrAccessPatt
ern)); |
| 1222 | 1231 |
| 1223 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); | 1232 bool flipY = kBottomLeft_GrSurfaceOrigin == surface->origin(); |
| 1224 VkOffset3D offset = { | 1233 VkOffset3D offset = { |
| 1225 left, | 1234 left, |
| 1226 flipY ? surface->height() - top - height : top, | 1235 flipY ? surface->height() - top - height : top, |
| 1227 0 | 1236 0 |
| 1228 }; | 1237 }; |
| 1229 | 1238 |
| 1230 // Copy the image to a buffer so we can map it to cpu memory | 1239 // Copy the image to a buffer so we can map it to cpu memory |
| 1231 VkBufferImageCopy region; | 1240 VkBufferImageCopy region; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 int set_a_break_pt_here = 9; | 1430 int set_a_break_pt_here = 9; |
| 1422 aglSwapBuffers(aglGetCurrentContext()); | 1431 aglSwapBuffers(aglGetCurrentContext()); |
| 1423 #elif defined(SK_BUILD_FOR_WIN32) | 1432 #elif defined(SK_BUILD_FOR_WIN32) |
| 1424 SwapBuf(); | 1433 SwapBuf(); |
| 1425 int set_a_break_pt_here = 9; | 1434 int set_a_break_pt_here = 9; |
| 1426 SwapBuf(); | 1435 SwapBuf(); |
| 1427 #endif | 1436 #endif |
| 1428 #endif | 1437 #endif |
| 1429 } | 1438 } |
| 1430 | 1439 |
| OLD | NEW |