Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: src/gpu/vk/GrVkGpu.cpp

Issue 1904723003: Revert of Use transfer buffer for BatchAtlas texture copies (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | tools/gpu/GrTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 SkASSERT(kDynamic_GrAccessPattern == accessPattern || 180 SkASSERT(kDynamic_GrAccessPattern == accessPattern ||
181 kStatic_GrAccessPattern == accessPattern); 181 kStatic_GrAccessPattern == accessPattern);
182 buff = GrVkVertexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern); 182 buff = GrVkVertexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern);
183 break; 183 break;
184 case kIndex_GrBufferType: 184 case kIndex_GrBufferType:
185 SkASSERT(kDynamic_GrAccessPattern == accessPattern || 185 SkASSERT(kDynamic_GrAccessPattern == accessPattern ||
186 kStatic_GrAccessPattern == accessPattern); 186 kStatic_GrAccessPattern == accessPattern);
187 buff = GrVkIndexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern); 187 buff = GrVkIndexBuffer::Create(this, size, kDynamic_GrAccessPattern == accessPattern);
188 break; 188 break;
189 case kXferCpuToGpu_GrBufferType: 189 case kXferCpuToGpu_GrBufferType:
190 SkASSERT(kDynamic_GrAccessPattern == accessPattern || 190 SkASSERT(kStream_GrAccessPattern == accessPattern);
191 kStream_GrAccessPattern == accessPattern);
192 buff = GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyRead_ Type); 191 buff = GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyRead_ Type);
193 break; 192 break;
194 case kXferGpuToCpu_GrBufferType: 193 case kXferGpuToCpu_GrBufferType:
195 SkASSERT(kDynamic_GrAccessPattern == accessPattern || 194 SkASSERT(kStream_GrAccessPattern == accessPattern);
196 kStream_GrAccessPattern == accessPattern);
197 buff = GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyWrite _Type); 195 buff = GrVkTransferBuffer::Create(this, size, GrVkBuffer::kCopyWrite _Type);
198 break; 196 break;
199 default: 197 default:
200 SkFAIL("Unknown buffer type."); 198 SkFAIL("Unknown buffer type.");
201 return nullptr; 199 return nullptr;
202 } 200 }
203 if (data && buff) { 201 if (data && buff) {
204 buff->updateData(data, size); 202 buff->updateData(data, size);
205 } 203 }
206 return buff; 204 return buff;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 277 }
280 278
281 if (success) { 279 if (success) {
282 vkTex->texturePriv().dirtyMipMaps(true); 280 vkTex->texturePriv().dirtyMipMaps(true);
283 return true; 281 return true;
284 } 282 }
285 283
286 return false; 284 return false;
287 } 285 }
288 286
289
290 bool GrVkGpu::onTransferPixels(GrTexture* texture,
291 int left, int top, int width, int height,
292 GrPixelConfig config, GrBuffer* transferBuffer,
293 size_t bufferOffset, size_t rowBytes) {
294 GrVkTexture* vkTex = static_cast<GrVkTexture*>(texture);
295 if (!vkTex) {
296 return false;
297 }
298 GrVkTransferBuffer* vkBuffer = static_cast<GrVkTransferBuffer*>(transferBuff er);
299 if (!vkBuffer) {
300 return false;
301 }
302
303 // We assume Vulkan doesn't do sRGB <-> linear conversions when reading and writing pixels.
304 if (GrPixelConfigIsSRGB(texture->config()) != GrPixelConfigIsSRGB(config)) {
305 return false;
306 }
307
308 // TODO: Handle y axis flip via copy to temp image, then blit to final
309 if (kBottomLeft_GrSurfaceOrigin == vkTex->origin()) {
310 return false;
311 }
312
313 bool success = false;
314 if (GrPixelConfigIsCompressed(vkTex->desc().fConfig)) {
315 // We check that config == desc.fConfig in GrGpu::getWritePixelsInfo()
316 SkASSERT(config == vkTex->desc().fConfig);
317 // TODO: add compressed texture support
318 // delete the following two lines and uncomment the two after that when ready
319 vkTex->unref();
320 return false;
321 //success = this->uploadCompressedTexData(vkTex->desc(), buffer, false, left, top, width,
322 // height);
323 } else {
324 // make sure the unmap has finished
325 vkBuffer->addMemoryBarrier(this,
326 VK_ACCESS_HOST_WRITE_BIT,
327 VK_ACCESS_TRANSFER_READ_BIT,
328 VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
329 VK_PIPELINE_STAGE_TRANSFER_BIT,
330 false);
331
332 // Set up copy region
333 size_t bpp = GrBytesPerPixel(config);
334
335 VkBufferImageCopy region;
336 memset(&region, 0, sizeof(VkBufferImageCopy));
337 region.bufferOffset = bufferOffset;
338 region.bufferRowLength = (uint32_t)(rowBytes/bpp);
339 region.bufferImageHeight = 0;
340 region.imageSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 };
341 region.imageOffset = { left, top, 0 };
342 region.imageExtent = { (uint32_t)width, (uint32_t)height, 1 };
343
344 // Change layout of our target so it can be copied to
345 VkImageLayout layout = vkTex->currentLayout();
346 VkPipelineStageFlags srcStageMask = GrVkMemory::LayoutToPipelineStageFla gs(layout);
347 VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT;
348 VkAccessFlags srcAccessMask = GrVkMemory::LayoutToSrcAccessMask(layout);
349 VkAccessFlags dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
350 vkTex->setImageLayout(this,
351 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
352 srcAccessMask,
353 dstAccessMask,
354 srcStageMask,
355 dstStageMask,
356 false);
357
358 // Copy the buffer to the image
359 fCurrentCmdBuffer->copyBufferToImage(this,
360 vkBuffer,
361 vkTex,
362 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMA L,
363 1,
364 &region);
365
366 // Submit the current command buffer to the Queue
367 this->submitCommandBuffer(kSkip_SyncQueue);
368 }
369
370 if (success) {
371 vkTex->texturePriv().dirtyMipMaps(true);
372 return true;
373 }
374
375 return false;
376 }
377
378 bool GrVkGpu::uploadTexData(GrVkTexture* tex, 287 bool GrVkGpu::uploadTexData(GrVkTexture* tex,
379 int left, int top, int width, int height, 288 int left, int top, int width, int height,
380 GrPixelConfig dataConfig, 289 GrPixelConfig dataConfig,
381 const void* data, 290 const void* data,
382 size_t rowBytes) { 291 size_t rowBytes) {
383 SkASSERT(data); 292 SkASSERT(data);
384 293
385 // If we're uploading compressed data then we should be using uploadCompress edTexData 294 // If we're uploading compressed data then we should be using uploadCompress edTexData
386 SkASSERT(!GrPixelConfigIsCompressed(dataConfig)); 295 SkASSERT(!GrPixelConfigIsCompressed(dataConfig));
387 296
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 aglSwapBuffers(aglGetCurrentContext()); 1590 aglSwapBuffers(aglGetCurrentContext());
1682 int set_a_break_pt_here = 9; 1591 int set_a_break_pt_here = 9;
1683 aglSwapBuffers(aglGetCurrentContext()); 1592 aglSwapBuffers(aglGetCurrentContext());
1684 #elif defined(SK_BUILD_FOR_WIN32) 1593 #elif defined(SK_BUILD_FOR_WIN32)
1685 SwapBuf(); 1594 SwapBuf();
1686 int set_a_break_pt_here = 9; 1595 int set_a_break_pt_here = 9;
1687 SwapBuf(); 1596 SwapBuf();
1688 #endif 1597 #endif
1689 #endif 1598 #endif
1690 } 1599 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.h ('k') | tools/gpu/GrTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698