From e5b74c68564baab3639b21a95ce5b4b92949ca27 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Mon, 1 Jun 2015 14:17:47 -0700 Subject: [PATCH] Set GeometryBufferMapThreshold defaults TBR=bsalomon@google.com BUG=skia: Review URL: https://codereview.chromium.org/1161543003 --- include/gpu/GrCaps.h | 3 ++- include/gpu/GrContextOptions.h | 11 +++++------ src/gpu/gl/GrGLCaps.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h index 38cf901..f219cb2 100644 --- a/include/gpu/GrCaps.h +++ b/include/gpu/GrCaps.h @@ -203,6 +203,7 @@ public: } size_t geometryBufferMapThreshold() const { + SkASSERT(fGeometryBufferMapThreshold >= 0); return fGeometryBufferMapThreshold; } @@ -229,6 +230,7 @@ protected: BlendEquationSupport fBlendEquationSupport; uint32_t fMapBufferFlags; + int fGeometryBufferMapThreshold; int fMaxRenderTargetSize; int fMaxTextureSize; @@ -242,7 +244,6 @@ protected: private: bool fSupressPrints : 1; bool fDrawPathMasksToCompressedTextureSupport : 1; - size_t fGeometryBufferMapThreshold; typedef SkRefCnt INHERITED; }; diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h index 231aa30..057bc83 100644 --- a/include/gpu/GrContextOptions.h +++ b/include/gpu/GrContextOptions.h @@ -17,7 +17,7 @@ struct GrContextOptions { , fMaxTextureSizeOverride(SK_MaxS32) , fMinTextureSizeOverride(0) , fSuppressDualSourceBlending(false) - , fGeometryBufferMapThreshold(1 << 15) {} + , fGeometryBufferMapThreshold(-1) {} // EXPERIMENTAL // May be removed in the future, or may become standard depending @@ -35,11 +35,10 @@ struct GrContextOptions { int fMinTextureSizeOverride; bool fSuppressDualSourceBlending; - /** fGeometryBufferMapThreshold gives a threshold (in bytes) for when Gr should - map a GrGeometryBuffer to update its contents. It will use map() if the - size of the updated region is greater than the threshold. Otherwise it will - use updateData(). */ - size_t fGeometryBufferMapThreshold; + /** the threshold in bytes above which we will use a buffer mapping API to map vertex and index + buffers to CPU memory in order to update them. A value of -1 means the GrContext should + deduce the optimal value for this platform. */ + int fGeometryBufferMapThreshold; }; #endif diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp index e1ad852..9489e21 100644 --- a/src/gpu/gl/GrGLCaps.cpp +++ b/src/gpu/gl/GrGLCaps.cpp @@ -271,6 +271,12 @@ void GrGLCaps::init(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli) { } } + // On many GPUs, map memory is very expensive, so we effectively disable it here by setting the + // threshold to the maximum unless the client gives us a hint that map memory is cheap. + if (fGeometryBufferMapThreshold < 0) { + fGeometryBufferMapThreshold = ctxInfo.isChromium() ? 0 : SK_MaxS32; + } + if (kGL_GrGLStandard == standard) { SkASSERT(ctxInfo.version() >= GR_GL_VER(2,0) || ctxInfo.hasExtension("GL_ARB_texture_non_power_of_two")); -- 2.7.4