| OLD | NEW |
| 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 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 this->handleDirtyContext(); | 2142 this->handleDirtyContext(); |
| 2143 | 2143 |
| 2144 // Index buffer state is tied to the vertex array. | 2144 // Index buffer state is tied to the vertex array. |
| 2145 if (kIndex_GrBufferType == type) { | 2145 if (kIndex_GrBufferType == type) { |
| 2146 this->bindVertexArray(0); | 2146 this->bindVertexArray(0); |
| 2147 } | 2147 } |
| 2148 | 2148 |
| 2149 SkASSERT(type >= 0 && type <= kLast_GrBufferType); | 2149 SkASSERT(type >= 0 && type <= kLast_GrBufferType); |
| 2150 auto& bufferState = fHWBufferState[type]; | 2150 auto& bufferState = fHWBufferState[type]; |
| 2151 | 2151 |
| 2152 if (buffer->getUniqueID() != bufferState.fBoundBufferUniqueID) { | 2152 if (buffer->uniqueID() != bufferState.fBoundBufferUniqueID) { |
| 2153 if (buffer->isCPUBacked()) { | 2153 if (buffer->isCPUBacked()) { |
| 2154 if (!bufferState.fBufferZeroKnownBound) { | 2154 if (!bufferState.fBufferZeroKnownBound) { |
| 2155 GL_CALL(BindBuffer(bufferState.fGLTarget, 0)); | 2155 GL_CALL(BindBuffer(bufferState.fGLTarget, 0)); |
| 2156 } | 2156 } |
| 2157 } else { | 2157 } else { |
| 2158 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(buffer); | 2158 const GrGLBuffer* glBuffer = static_cast<const GrGLBuffer*>(buffer); |
| 2159 GL_CALL(BindBuffer(bufferState.fGLTarget, glBuffer->bufferID())); | 2159 GL_CALL(BindBuffer(bufferState.fGLTarget, glBuffer->bufferID())); |
| 2160 } | 2160 } |
| 2161 bufferState.fBufferZeroKnownBound = buffer->isCPUBacked(); | 2161 bufferState.fBufferZeroKnownBound = buffer->isCPUBacked(); |
| 2162 bufferState.fBoundBufferUniqueID = buffer->getUniqueID(); | 2162 bufferState.fBoundBufferUniqueID = buffer->uniqueID(); |
| 2163 } | 2163 } |
| 2164 | 2164 |
| 2165 return bufferState.fGLTarget; | 2165 return bufferState.fGLTarget; |
| 2166 } | 2166 } |
| 2167 | 2167 |
| 2168 void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) { | 2168 void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) { |
| 2169 if (buffer->hasAttachedToTexture()) { | 2169 if (buffer->hasAttachedToTexture()) { |
| 2170 // Detach this buffer from any textures to ensure the underlying memory
is freed. | 2170 // Detach this buffer from any textures to ensure the underlying memory
is freed. |
| 2171 uint32_t uniqueID = buffer->getUniqueID(); | 2171 uint32_t uniqueID = buffer->uniqueID(); |
| 2172 for (int i = fHWMaxUsedBufferTextureUnit; i >= 0; --i) { | 2172 for (int i = fHWMaxUsedBufferTextureUnit; i >= 0; --i) { |
| 2173 auto& buffTex = fHWBufferTextures[i]; | 2173 auto& buffTex = fHWBufferTextures[i]; |
| 2174 if (uniqueID != buffTex.fAttachedBufferUniqueID) { | 2174 if (uniqueID != buffTex.fAttachedBufferUniqueID) { |
| 2175 continue; | 2175 continue; |
| 2176 } | 2176 } |
| 2177 if (i == fHWMaxUsedBufferTextureUnit) { | 2177 if (i == fHWMaxUsedBufferTextureUnit) { |
| 2178 --fHWMaxUsedBufferTextureUnit; | 2178 --fHWMaxUsedBufferTextureUnit; |
| 2179 } | 2179 } |
| 2180 | 2180 |
| 2181 this->setTextureUnit(i); | 2181 this->setTextureUnit(i); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2649 SkASSERT(fMSAAEnabled != kYes_TriState); | 2649 SkASSERT(fMSAAEnabled != kYes_TriState); |
| 2650 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | 2650 GL_CALL(Enable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2651 this->stampPLSSetupRect(SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.01f)
); | 2651 this->stampPLSSetupRect(SkRect::MakeXYWH(-100.0f, -100.0f, 0.01f, 0.01f)
); |
| 2652 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); | 2652 GL_CALL(Disable(GR_GL_SHADER_PIXEL_LOCAL_STORAGE)); |
| 2653 } | 2653 } |
| 2654 } | 2654 } |
| 2655 | 2655 |
| 2656 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds,
bool disableSRGB) { | 2656 void GrGLGpu::flushRenderTarget(GrGLRenderTarget* target, const SkIRect* bounds,
bool disableSRGB) { |
| 2657 SkASSERT(target); | 2657 SkASSERT(target); |
| 2658 | 2658 |
| 2659 uint32_t rtID = target->getUniqueID(); | 2659 uint32_t rtID = target->uniqueID(); |
| 2660 if (fHWBoundRenderTargetUniqueID != rtID) { | 2660 if (fHWBoundRenderTargetUniqueID != rtID) { |
| 2661 fStats.incRenderTargetBinds(); | 2661 fStats.incRenderTargetBinds(); |
| 2662 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); | 2662 GL_CALL(BindFramebuffer(GR_GL_FRAMEBUFFER, target->renderFBOID())); |
| 2663 #ifdef SK_DEBUG | 2663 #ifdef SK_DEBUG |
| 2664 // don't do this check in Chromium -- this is causing | 2664 // don't do this check in Chromium -- this is causing |
| 2665 // lots of repeated command buffer flushes when the compositor is | 2665 // lots of repeated command buffer flushes when the compositor is |
| 2666 // rendering with Ganesh, which is really slow; even too slow for | 2666 // rendering with Ganesh, which is really slow; even too slow for |
| 2667 // Debug mode. | 2667 // Debug mode. |
| 2668 if (kChromium_GrGLDriver != this->glContext().driver()) { | 2668 if (kChromium_GrGLDriver != this->glContext().driver()) { |
| 2669 GrGLenum status; | 2669 GrGLenum status; |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3171 #endif | 3171 #endif |
| 3172 | 3172 |
| 3173 // If we created a rt/tex and rendered to it without using a texture and now
we're texturing | 3173 // If we created a rt/tex and rendered to it without using a texture and now
we're texturing |
| 3174 // from the rt it will still be the last bound texture, but it needs resolvi
ng. So keep this | 3174 // from the rt it will still be the last bound texture, but it needs resolvi
ng. So keep this |
| 3175 // out of the "last != next" check. | 3175 // out of the "last != next" check. |
| 3176 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTa
rget()); | 3176 GrGLRenderTarget* texRT = static_cast<GrGLRenderTarget*>(texture->asRenderTa
rget()); |
| 3177 if (texRT) { | 3177 if (texRT) { |
| 3178 this->onResolveRenderTarget(texRT); | 3178 this->onResolveRenderTarget(texRT); |
| 3179 } | 3179 } |
| 3180 | 3180 |
| 3181 uint32_t textureID = texture->getUniqueID(); | 3181 uint32_t textureID = texture->uniqueID(); |
| 3182 GrGLenum target = texture->target(); | 3182 GrGLenum target = texture->target(); |
| 3183 if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) { | 3183 if (fHWBoundTextureUniqueIDs[unitIdx] != textureID) { |
| 3184 this->setTextureUnit(unitIdx); | 3184 this->setTextureUnit(unitIdx); |
| 3185 GL_CALL(BindTexture(target, texture->textureID())); | 3185 GL_CALL(BindTexture(target, texture->textureID())); |
| 3186 fHWBoundTextureUniqueIDs[unitIdx] = textureID; | 3186 fHWBoundTextureUniqueIDs[unitIdx] = textureID; |
| 3187 } | 3187 } |
| 3188 | 3188 |
| 3189 ResetTimestamp timestamp; | 3189 ResetTimestamp timestamp; |
| 3190 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); | 3190 const GrGLTexture::TexParams& oldTexParams = texture->getCachedTexParams(&ti
mestamp); |
| 3191 bool setAll = timestamp < this->getResetTimestamp(); | 3191 bool setAll = timestamp < this->getResetTimestamp(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3289 return; | 3289 return; |
| 3290 } | 3290 } |
| 3291 } | 3291 } |
| 3292 | 3292 |
| 3293 this->setTextureUnit(unitIdx); | 3293 this->setTextureUnit(unitIdx); |
| 3294 GL_CALL(BindTexture(GR_GL_TEXTURE_BUFFER, buffTex.fTextureID)); | 3294 GL_CALL(BindTexture(GR_GL_TEXTURE_BUFFER, buffTex.fTextureID)); |
| 3295 | 3295 |
| 3296 buffTex.fKnownBound = true; | 3296 buffTex.fKnownBound = true; |
| 3297 } | 3297 } |
| 3298 | 3298 |
| 3299 if (buffer->getUniqueID() != buffTex.fAttachedBufferUniqueID || | 3299 if (buffer->uniqueID() != buffTex.fAttachedBufferUniqueID || |
| 3300 buffTex.fTexelConfig != texelConfig) { | 3300 buffTex.fTexelConfig != texelConfig) { |
| 3301 | 3301 |
| 3302 this->setTextureUnit(unitIdx); | 3302 this->setTextureUnit(unitIdx); |
| 3303 GL_CALL(TexBuffer(GR_GL_TEXTURE_BUFFER, | 3303 GL_CALL(TexBuffer(GR_GL_TEXTURE_BUFFER, |
| 3304 this->glCaps().configSizedInternalFormat(texelConfig), | 3304 this->glCaps().configSizedInternalFormat(texelConfig), |
| 3305 buffer->bufferID())); | 3305 buffer->bufferID())); |
| 3306 | 3306 |
| 3307 buffTex.fTexelConfig = texelConfig; | 3307 buffTex.fTexelConfig = texelConfig; |
| 3308 buffTex.fAttachedBufferUniqueID = buffer->getUniqueID(); | 3308 buffTex.fAttachedBufferUniqueID = buffer->uniqueID(); |
| 3309 | 3309 |
| 3310 if (this->glCaps().textureSwizzleSupport() && | 3310 if (this->glCaps().textureSwizzleSupport() && |
| 3311 this->glCaps().configSwizzle(texelConfig) != buffTex.fSwizzle) { | 3311 this->glCaps().configSwizzle(texelConfig) != buffTex.fSwizzle) { |
| 3312 GrGLenum glSwizzle[4]; | 3312 GrGLenum glSwizzle[4]; |
| 3313 get_tex_param_swizzle(texelConfig, this->glCaps(), glSwizzle); | 3313 get_tex_param_swizzle(texelConfig, this->glCaps(), glSwizzle); |
| 3314 this->setTextureSwizzle(unitIdx, GR_GL_TEXTURE_BUFFER, glSwizzle); | 3314 this->setTextureSwizzle(unitIdx, GR_GL_TEXTURE_BUFFER, glSwizzle); |
| 3315 buffTex.fSwizzle = this->glCaps().configSwizzle(texelConfig); | 3315 buffTex.fSwizzle = this->glCaps().configSwizzle(texelConfig); |
| 3316 } | 3316 } |
| 3317 | 3317 |
| 3318 buffer->setHasAttachedToTexture(); | 3318 buffer->setHasAttachedToTexture(); |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4669 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || | 4669 if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() || |
| 4670 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { | 4670 GR_GL_TEXTURE_RECTANGLE == glTexture->target()) { |
| 4671 copyParams->fFilter = GrTextureParams::kNone_FilterMode; | 4671 copyParams->fFilter = GrTextureParams::kNone_FilterMode; |
| 4672 copyParams->fWidth = texture->width(); | 4672 copyParams->fWidth = texture->width(); |
| 4673 copyParams->fHeight = texture->height(); | 4673 copyParams->fHeight = texture->height(); |
| 4674 return true; | 4674 return true; |
| 4675 } | 4675 } |
| 4676 } | 4676 } |
| 4677 return false; | 4677 return false; |
| 4678 } | 4678 } |
| OLD | NEW |