diff options
author | Brian Osman <brianosman@google.com> | 2017-09-05 15:34:52 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-09-05 19:59:46 +0000 |
commit | 9b560247c73b0306b5eb732bab804ea9519e0b82 (patch) | |
tree | 44961a4fdaf5cdf8a6e33f3d9ec31445127c849d /src/gpu | |
parent | 16e357c711d40f4b6609f71276c37a0614f77d89 (diff) |
Unbind xfer buffer in a couple more places
Move code into a helper function, make sure that all TexImage and
TexSubImage calls are correctly unbinding.
Bug: skia:
Change-Id: I79bfa0af43a08f775186a867167fa67b4437688c
Reviewed-on: https://skia-review.googlesource.com/42640
Reviewed-by: Jim Van Verth <jvanverth@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 27 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 4 |
2 files changed, 18 insertions, 13 deletions
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index af7156c759..b9c172a776 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -994,6 +994,15 @@ static void restore_pixelstore_state(const GrGLInterface& interface, const GrGLC } } +void GrGLGpu::unbindCpuToGpuXferBuffer() { + auto& xferBufferState = fHWBufferState[kXferCpuToGpu_GrBufferType]; + if (!xferBufferState.fBoundBufferUniqueID.isInvalid()) { + GL_CALL(BindBuffer(xferBufferState.fGLTarget, 0)); + xferBufferState.invalidate(); + } + +} + bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight, GrSurfaceOrigin texOrigin, GrGLenum target, UploadType uploadType, int left, int top, int width, int height, GrPixelConfig dataConfig, @@ -1007,12 +1016,7 @@ bool GrGLGpu::uploadTexData(GrPixelConfig texConfig, int texWidth, int texHeight SkASSERT(1 == mipLevelCount || (0 == left && 0 == top && width == texWidth && height == texHeight)); - // unbind any previous transfer buffer - auto& xferBufferState = fHWBufferState[kXferCpuToGpu_GrBufferType]; - if (!xferBufferState.fBoundBufferUniqueID.isInvalid()) { - GL_CALL(BindBuffer(xferBufferState.fGLTarget, 0)); - xferBufferState.invalidate(); - } + this->unbindCpuToGpuXferBuffer(); // texels is const. // But we may need to flip the texture vertically to prepare it. @@ -1481,13 +1485,6 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { // Default to unsupported, set this if we find a stencil format that works. int firstWorkingStencilFormatIndex = -1; - // unbind any previous transfer buffer - auto& xferBufferState = fHWBufferState[kXferCpuToGpu_GrBufferType]; - if (!xferBufferState.fBoundBufferUniqueID.isInvalid()) { - GL_CALL(BindBuffer(xferBufferState.fGLTarget, 0)); - xferBufferState.invalidate(); - } - // Create color texture GrGLuint colorID = 0; GL_CALL(GenTextures(1, &colorID)); @@ -1513,6 +1510,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { &externalType)) { return false; } + this->unbindCpuToGpuXferBuffer(); CLEAR_ERROR_BEFORE_ALLOC(this->glInterface()); GL_ALLOC_CALL(this->glInterface(), TexImage2D(GR_GL_TEXTURE_2D, 0, @@ -4044,6 +4042,8 @@ bool GrGLGpu::generateMipmap(GrGLTexture* texture, GrSurfaceOrigin textureOrigin return false; } + this->unbindCpuToGpuXferBuffer(); + for (GrGLint level = 1; level < levelCount; ++level) { // Define the next mip: width = SkTMax(1, width / 2); @@ -4230,6 +4230,7 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in return reinterpret_cast<GrBackendObject>(nullptr); } + this->unbindCpuToGpuXferBuffer(); GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat, externalType, pixels)); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index ba9afbca26..479217e751 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -261,6 +261,10 @@ private: GrPixelConfig config, GrBuffer* transferBuffer, size_t offset, size_t rowBytes) override; + // Before calling any variation of TexImage, TexSubImage, etc..., call this to ensure that the + // PIXEL_UNPACK_BUFFER is unbound. + void unbindCpuToGpuXferBuffer(); + void onResolveRenderTarget(GrRenderTarget* target, GrSurfaceOrigin) override; bool onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, |