Bug 1306628 - Handle large sizes in GrResourceProvider::createBuffer. r=mchang, a=gchang
authorLee Salzman <lsalzman@mozilla.com>
Tue, 25 Oct 2016 00:31:43 -0400
changeset 352800 1258309afc856df19a2ef82affceec98720e149d
parent 352799 16b0b8d30804927c93c70dc7aee279f3a279f593
child 352801 776b92e3ec431a94b96ee3b898eecc781f73d99a
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang, gchang
bugs1306628
milestone52.0a2
Bug 1306628 - Handle large sizes in GrResourceProvider::createBuffer. r=mchang, a=gchang MozReview-Commit-ID: 3ZGDmIum5OU
gfx/skia/skia/src/gpu/GrResourceProvider.cpp
--- a/gfx/skia/skia/src/gpu/GrResourceProvider.cpp
+++ b/gfx/skia/skia/src/gpu/GrResourceProvider.cpp
@@ -104,18 +104,21 @@ GrBuffer* GrResourceProvider::createBuff
     if (!(flags & kRequireGpuMemory_Flag) &&
         this->gpu()->caps()->preferClientSideDynamicBuffers() &&
         GrBufferTypeIsVertexOrIndex(intendedType) &&
         kDynamic_GrAccessPattern == accessPattern) {
         return GrBuffer::CreateCPUBacked(this->gpu(), size, intendedType, data);
     }
 
     // bin by pow2 with a reasonable min
-    static const uint32_t MIN_SIZE = 1 << 12;
-    size_t allocSize = SkTMax(MIN_SIZE, GrNextPow2(SkToUInt(size)));
+    static const size_t MIN_SIZE = 1 << 12;
+    size_t allocSize = size > (1u << 31)
+                       ? size_t(SkTMin(uint64_t(SIZE_MAX), uint64_t(GrNextPow2(uint32_t(uint64_t(size) >> 32))) << 32))
+                       : size_t(GrNextPow2(uint32_t(size)));
+    allocSize = SkTMax(allocSize, MIN_SIZE);
 
     GrScratchKey key;
     GrBuffer::ComputeScratchKeyForDynamicVBO(allocSize, intendedType, &key);
     uint32_t scratchFlags = 0;
     if (flags & kNoPendingIO_Flag) {
         scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
     } else {
         scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;