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

Side by Side Diff: src/gpu/GrGpu.cpp

Issue 1925303002: Add mipmap loading to Vulkan. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixes to handle mipmap allocations and autogen Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 8
9 #include "GrGpu.h" 9 #include "GrGpu.h"
10 10
11 #include "GrBuffer.h" 11 #include "GrBuffer.h"
12 #include "GrCaps.h" 12 #include "GrCaps.h"
13 #include "GrContext.h" 13 #include "GrContext.h"
14 #include "GrGpuResourcePriv.h" 14 #include "GrGpuResourcePriv.h"
15 #include "GrMesh.h" 15 #include "GrMesh.h"
16 #include "GrPathRendering.h" 16 #include "GrPathRendering.h"
17 #include "GrPipeline.h" 17 #include "GrPipeline.h"
18 #include "GrResourceCache.h" 18 #include "GrResourceCache.h"
19 #include "GrResourceProvider.h" 19 #include "GrResourceProvider.h"
20 #include "GrRenderTargetPriv.h" 20 #include "GrRenderTargetPriv.h"
21 #include "GrStencilAttachment.h" 21 #include "GrStencilAttachment.h"
22 #include "GrSurfacePriv.h" 22 #include "GrSurfacePriv.h"
23 #include "GrTexturePriv.h"
23 #include "SkTypes.h" 24 #include "SkTypes.h"
24 25
25 GrMesh& GrMesh::operator =(const GrMesh& di) { 26 GrMesh& GrMesh::operator =(const GrMesh& di) {
26 fPrimitiveType = di.fPrimitiveType; 27 fPrimitiveType = di.fPrimitiveType;
27 fStartVertex = di.fStartVertex; 28 fStartVertex = di.fStartVertex;
28 fStartIndex = di.fStartIndex; 29 fStartIndex = di.fStartIndex;
29 fVertexCount = di.fVertexCount; 30 fVertexCount = di.fVertexCount;
30 fIndexCount = di.fIndexCount; 31 fIndexCount = di.fIndexCount;
31 32
32 fInstanceCount = di.fInstanceCount; 33 fInstanceCount = di.fInstanceCount;
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return false; 369 return false;
369 } 370 }
370 for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLe vel++) { 371 for (int currentMipLevel = 0; currentMipLevel < texels.count(); currentMipLe vel++) {
371 if (!texels[currentMipLevel].fPixels ) { 372 if (!texels[currentMipLevel].fPixels ) {
372 return false; 373 return false;
373 } 374 }
374 } 375 }
375 376
376 this->handleDirtyContext(); 377 this->handleDirtyContext();
377 if (this->onWritePixels(surface, left, top, width, height, config, texels)) { 378 if (this->onWritePixels(surface, left, top, width, height, config, texels)) {
379 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height);
380 this->didWriteToSurface(surface, &rect, texels.count());
378 fStats.incTextureUploads(); 381 fStats.incTextureUploads();
379 return true; 382 return true;
380 } 383 }
381 return false; 384 return false;
382 } 385 }
383 386
384 bool GrGpu::writePixels(GrSurface* surface, 387 bool GrGpu::writePixels(GrSurface* surface,
385 int left, int top, int width, int height, 388 int left, int top, int width, int height,
386 GrPixelConfig config, const void* buffer, 389 GrPixelConfig config, const void* buffer,
387 size_t rowBytes) { 390 size_t rowBytes) {
388 GrMipLevel mipLevel; 391 GrMipLevel mipLevel;
389 mipLevel.fPixels = buffer; 392 mipLevel.fPixels = buffer;
390 mipLevel.fRowBytes = rowBytes; 393 mipLevel.fRowBytes = rowBytes;
391 SkSTArray<1, GrMipLevel> texels; 394 SkSTArray<1, GrMipLevel> texels;
392 texels.push_back(mipLevel); 395 texels.push_back(mipLevel);
393 396
394 return this->writePixels(surface, left, top, width, height, config, texels); 397 return this->writePixels(surface, left, top, width, height, config, texels);
395 } 398 }
396 399
397 bool GrGpu::transferPixels(GrSurface* surface, 400 bool GrGpu::transferPixels(GrSurface* surface,
398 int left, int top, int width, int height, 401 int left, int top, int width, int height,
399 GrPixelConfig config, GrBuffer* transferBuffer, 402 GrPixelConfig config, GrBuffer* transferBuffer,
400 size_t offset, size_t rowBytes) { 403 size_t offset, size_t rowBytes) {
401 SkASSERT(transferBuffer); 404 SkASSERT(transferBuffer);
402 405
403 this->handleDirtyContext(); 406 this->handleDirtyContext();
404 if (this->onTransferPixels(surface, left, top, width, height, config, 407 if (this->onTransferPixels(surface, left, top, width, height, config,
405 transferBuffer, offset, rowBytes)) { 408 transferBuffer, offset, rowBytes)) {
409 SkIRect rect = SkIRect::MakeXYWH(left, top, width, height);
410 this->didWriteToSurface(surface, &rect);
406 fStats.incTransfersToTexture(); 411 fStats.incTransfersToTexture();
407 return true; 412 return true;
408 } 413 }
409 return false; 414 return false;
410 } 415 }
411 416
412 void GrGpu::resolveRenderTarget(GrRenderTarget* target) { 417 void GrGpu::resolveRenderTarget(GrRenderTarget* target) {
413 SkASSERT(target); 418 SkASSERT(target);
414 this->handleDirtyContext(); 419 this->handleDirtyContext();
415 this->onResolveRenderTarget(target); 420 this->onResolveRenderTarget(target);
416 } 421 }
417 422
423 void GrGpu::didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_ t mipLevels) const {
424 SkASSERT(surface);
425 // Mark any MIP chain and resolve buffer as dirty if and only if there is a non-empty bounds.
426 if (nullptr == bounds || !bounds->isEmpty()) {
427 if (GrRenderTarget* target = surface->asRenderTarget()) {
428 target->flagAsNeedingResolve(bounds);
429 }
430 GrTexture* texture = surface->asTexture();
431 if (texture && 1 == mipLevels) {
egdaniel 2016/04/29 18:10:28 just to clarify for myself here. The reason we mak
jvanverth1 2016/04/29 18:16:10 Yes, that's right.
432 texture->texturePriv().dirtyMipMaps(true);
433 }
434 }
435 }
436
418 inline static uint8_t multisample_specs_id(uint8_t numSamples, GrSurfaceOrigin o rigin, 437 inline static uint8_t multisample_specs_id(uint8_t numSamples, GrSurfaceOrigin o rigin,
419 const GrCaps& caps) { 438 const GrCaps& caps) {
420 if (!caps.sampleLocationsSupport()) { 439 if (!caps.sampleLocationsSupport()) {
421 return numSamples; 440 return numSamples;
422 } 441 }
423 442
424 SkASSERT(numSamples < 128); 443 SkASSERT(numSamples < 128);
425 SkASSERT(kTopLeft_GrSurfaceOrigin == origin || kBottomLeft_GrSurfaceOrigin = = origin); 444 SkASSERT(kTopLeft_GrSurfaceOrigin == origin || kBottomLeft_GrSurfaceOrigin = = origin);
426 return (numSamples << 1) | (origin - 1); 445 return (numSamples << 1) | (origin - 1);
427 446
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 int meshCount) { 497 int meshCount) {
479 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) { 498 if (primProc.numAttribs() > this->caps()->maxVertexAttributes()) {
480 fStats.incNumFailedDraws(); 499 fStats.incNumFailedDraws();
481 return false; 500 return false;
482 } 501 }
483 this->handleDirtyContext(); 502 this->handleDirtyContext();
484 503
485 this->onDraw(pipeline, primProc, meshes, meshCount); 504 this->onDraw(pipeline, primProc, meshes, meshCount);
486 return true; 505 return true;
487 } 506 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.h ('k') | src/gpu/gl/GrGLGpu.h » ('j') | src/gpu/vk/GrVkGpu.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698