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

Side by Side Diff: src/gpu/gl/GrGLGpu.cpp

Issue 2143333002: Add resource provider flag to avoid client-side buffers (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add resource provider flag to avoid client-side buffers Created 4 years, 5 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/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLVertexArray.h » ('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 2011 Google Inc. 2 * Copyright 2011 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 "GrGLGpu.h" 8 #include "GrGLGpu.h"
9 #include "GrGLBuffer.h" 9 #include "GrGLBuffer.h"
10 #include "GrGLGLSL.h" 10 #include "GrGLGLSL.h"
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 // This must come after textures are flushed because a texture may need 2046 // This must come after textures are flushed because a texture may need
2047 // to be msaa-resolved (which will modify bound FBO state). 2047 // to be msaa-resolved (which will modify bound FBO state).
2048 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo SRGB()); 2048 this->flushRenderTarget(glRT, nullptr, pipeline.getDisableOutputConversionTo SRGB());
2049 2049
2050 return true; 2050 return true;
2051 } 2051 }
2052 2052
2053 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc, 2053 void GrGLGpu::setupGeometry(const GrPrimitiveProcessor& primProc,
2054 const GrNonInstancedMesh& mesh, 2054 const GrNonInstancedMesh& mesh,
2055 size_t* indexOffsetInBytes) { 2055 size_t* indexOffsetInBytes) {
2056 const GrGLBuffer* vbuf; 2056 const GrBuffer* vbuf = mesh.vertexBuffer();
2057 vbuf = static_cast<const GrGLBuffer*>(mesh.vertexBuffer());
2058
2059 SkASSERT(vbuf); 2057 SkASSERT(vbuf);
2060 SkASSERT(!vbuf->isMapped()); 2058 SkASSERT(!vbuf->isMapped());
2061 2059
2062 GrGLAttribArrayState* attribState; 2060 GrGLAttribArrayState* attribState;
2063 if (mesh.isIndexed()) { 2061 if (mesh.isIndexed()) {
2064 SkASSERT(indexOffsetInBytes); 2062 SkASSERT(indexOffsetInBytes);
2065 2063
2066 *indexOffsetInBytes = 0; 2064 *indexOffsetInBytes = 0;
2067 const GrGLBuffer* ibuf = static_cast<const GrGLBuffer*>(mesh.indexBuffer ()); 2065 const GrBuffer* ibuf = mesh.indexBuffer();
2068
2069 SkASSERT(ibuf); 2066 SkASSERT(ibuf);
2070 SkASSERT(!ibuf->isMapped()); 2067 SkASSERT(!ibuf->isMapped());
2071 *indexOffsetInBytes += ibuf->baseOffset(); 2068 *indexOffsetInBytes += ibuf->baseOffset();
2072 attribState = fHWVertexArrayState.bindInternalVertexArray(this, ibuf); 2069 attribState = fHWVertexArrayState.bindInternalVertexArray(this, ibuf);
2073 } else { 2070 } else {
2074 attribState = fHWVertexArrayState.bindInternalVertexArray(this); 2071 attribState = fHWVertexArrayState.bindInternalVertexArray(this);
2075 } 2072 }
2076 2073
2077 int vaCount = primProc.numAttribs(); 2074 int vaCount = primProc.numAttribs();
2078 if (vaCount > 0) { 2075 if (vaCount > 0) {
(...skipping 16 matching lines...) Expand all
2095 vbuf, 2092 vbuf,
2096 attribType, 2093 attribType,
2097 stride, 2094 stride,
2098 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o ffset)); 2095 reinterpret_cast<GrGLvoid*>(vertexOffsetInBytes + o ffset));
2099 offset += attrib.fOffset; 2096 offset += attrib.fOffset;
2100 } 2097 }
2101 attribState->disableUnusedArrays(this, usedAttribArraysMask); 2098 attribState->disableUnusedArrays(this, usedAttribArraysMask);
2102 } 2099 }
2103 } 2100 }
2104 2101
2105 GrGLenum GrGLGpu::bindBuffer(GrBufferType type, const GrGLBuffer* buffer) { 2102 GrGLenum GrGLGpu::bindBuffer(GrBufferType type, const GrBuffer* buffer) {
2106 this->handleDirtyContext(); 2103 this->handleDirtyContext();
2107 2104
2108 // Index buffer state is tied to the vertex array. 2105 // Index buffer state is tied to the vertex array.
2109 if (kIndex_GrBufferType == type) { 2106 if (kIndex_GrBufferType == type) {
2110 this->bindVertexArray(0); 2107 this->bindVertexArray(0);
2111 } 2108 }
2112 2109
2113 SkASSERT(type >= 0 && type <= kLast_GrBufferType); 2110 SkASSERT(type >= 0 && type <= kLast_GrBufferType);
2114 auto& bufferState = fHWBufferState[type]; 2111 auto& bufferState = fHWBufferState[type];
2115 2112
2116 if (buffer->getUniqueID() != bufferState.fBoundBufferUniqueID) { 2113 if (buffer->getUniqueID() != bufferState.fBoundBufferUniqueID) {
2117 if (!buffer->isCPUBacked() || !bufferState.fBufferZeroKnownBound) { 2114 if (buffer->isCPUBacked()) {
2118 GL_CALL(BindBuffer(bufferState.fGLTarget, buffer->bufferID())); 2115 if (!bufferState.fBufferZeroKnownBound) {
2119 bufferState.fBufferZeroKnownBound = buffer->isCPUBacked(); 2116 GL_CALL(BindBuffer(bufferState.fGLTarget, 0));
2117 }
2118 } else {
2119 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(buffer);
2120 GL_CALL(BindBuffer(bufferState.fGLTarget, glBuffer->bufferID()));
2120 } 2121 }
2122 bufferState.fBufferZeroKnownBound = buffer->isCPUBacked();
2121 bufferState.fBoundBufferUniqueID = buffer->getUniqueID(); 2123 bufferState.fBoundBufferUniqueID = buffer->getUniqueID();
2122 } 2124 }
2123 2125
2124 return bufferState.fGLTarget; 2126 return bufferState.fGLTarget;
2125 } 2127 }
2126 2128
2127 void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) { 2129 void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) {
2128 if (buffer->hasAttachedToTexture()) { 2130 if (buffer->hasAttachedToTexture()) {
2129 // Detach this buffer from any textures to ensure the underlying memory is freed. 2131 // Detach this buffer from any textures to ensure the underlying memory is freed.
2130 uint32_t uniqueID = buffer->getUniqueID(); 2132 uint32_t uniqueID = buffer->getUniqueID();
(...skipping 2430 matching lines...) Expand 10 before | Expand all | Expand 10 after
4561 #endif 4563 #endif
4562 } 4564 }
4563 4565
4564 void GrGLGpu::resetShaderCacheForTesting() const { 4566 void GrGLGpu::resetShaderCacheForTesting() const {
4565 fProgramCache->abandon(); 4567 fProgramCache->abandon();
4566 } 4568 }
4567 4569
4568 /////////////////////////////////////////////////////////////////////////////// 4570 ///////////////////////////////////////////////////////////////////////////////
4569 4571
4570 GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG pu* gpu, 4572 GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG pu* gpu,
4571 const GrGLBuffer* ibuf) { 4573 const GrBuffer* ibuf) {
4572 GrGLAttribArrayState* attribState; 4574 GrGLAttribArrayState* attribState;
4573 4575
4574 if (gpu->glCaps().isCoreProfile()) { 4576 if (gpu->glCaps().isCoreProfile()) {
4575 if (!fCoreProfileVertexArray) { 4577 if (!fCoreProfileVertexArray) {
4576 GrGLuint arrayID; 4578 GrGLuint arrayID;
4577 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID)); 4579 GR_GL_CALL(gpu->glInterface(), GenVertexArrays(1, &arrayID));
4578 int attrCount = gpu->glCaps().maxVertexAttributes(); 4580 int attrCount = gpu->glCaps().maxVertexAttributes();
4579 fCoreProfileVertexArray = new GrGLVertexArray(arrayID, attrCount); 4581 fCoreProfileVertexArray = new GrGLVertexArray(arrayID, attrCount);
4580 } 4582 }
4581 if (ibuf) { 4583 if (ibuf) {
(...skipping 25 matching lines...) Expand all
4607 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || 4609 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
4608 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { 4610 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
4609 copyParams->fFilter = GrTextureParams::kNone_FilterMode; 4611 copyParams->fFilter = GrTextureParams::kNone_FilterMode;
4610 copyParams->fWidth = texture->width(); 4612 copyParams->fWidth = texture->width();
4611 copyParams->fHeight = texture->height(); 4613 copyParams->fHeight = texture->height();
4612 return true; 4614 return true;
4613 } 4615 }
4614 } 4616 }
4615 return false; 4617 return false;
4616 } 4618 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLGpu.h ('k') | src/gpu/gl/GrGLVertexArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698