Chromium Code Reviews| Index: src/gpu/gl/GrGLGpu.cpp |
| diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp |
| index a83386840e68c959efb43d57c03d80878d3d6875..65161e7b319a1480b2d0fd07d622d76114ca0a55 100644 |
| --- a/src/gpu/gl/GrGLGpu.cpp |
| +++ b/src/gpu/gl/GrGLGpu.cpp |
| @@ -657,6 +657,29 @@ static inline GrGLenum check_alloc_error(const GrSurfaceDesc& desc, |
| } |
| } |
| +/** |
| + * Determines if sized internal formats are available for the texture being created. |
| + * |
| + * @param useTexStorage The result of a call to can_use_tex_storage(). |
|
jvanverth1
2015/12/15 15:35:41
These param comments don't match this function.
bsalomon
2015/12/15 17:09:47
D'oh! Forgot to update when I changed the params.
|
| + * @param caps The capabilities of the GL device. |
| + * @param standard The GL standard in use. |
| + * @param version The GL version in use. |
| + * @param dataConfig The pixel configuration for the texture being created. |
| + */ |
| +static bool use_sized_format_for_texture(bool useTexStorage, const GrGLContextInfo& info, |
| + GrPixelConfig textureConfig) { |
| + // glTexStorage requires sized internal formats on both desktop and ES. ES2 requires an unsized |
| + // format for glTexImage, unlike ES3 and desktop. |
| + bool useSizedFormat = useTexStorage; |
| + if (kGL_GrGLStandard == info.standard() || |
| + (info.version() >= GR_GL_VER(3, 0) && |
| + // ES3 only works with sized BGRA8 format if "GL_APPLE_texture_format_BGRA8888" enabled |
| + (kBGRA_8888_GrPixelConfig != textureConfig || !info.caps()->bgraIsInternalFormat()))) { |
| + useSizedFormat = true; |
| + } |
| + return useSizedFormat; |
| +} |
| + |
| bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, |
| GrGLenum target, |
| bool isNewTexture, |
| @@ -704,21 +727,22 @@ bool GrGLGpu::uploadTexData(const GrSurfaceDesc& desc, |
| GrGLenum externalFormat = 0x0; // suppress warning |
| GrGLenum externalType = 0x0; // suppress warning |
| - // glTexStorage requires sized internal formats on both desktop and ES. ES2 requires an unsized |
| - // format for glTexImage, unlike ES3 and desktop. |
| - bool useSizedFormat = useTexStorage; |
| - if (kGL_GrGLStandard == this->glStandard() || |
| - (this->glVersion() >= GR_GL_VER(3, 0) && |
| - // ES3 only works with sized BGRA8 format if "GL_APPLE_texture_format_BGRA8888" enabled |
| - (kBGRA_8888_GrPixelConfig != dataConfig || !this->glCaps().bgraIsInternalFormat()))) { |
| - useSizedFormat = true; |
| - } |
| + bool useSizedFormat = use_sized_format_for_texture(useTexStorage, this->ctxInfo(), |
| + desc.fConfig); |
|
jvanverth1
2015/12/15 15:35:41
Nit: tab one space?
bsalomon
2015/12/15 17:09:47
Done.
|
| - if (!this->configToGLFormats(dataConfig, useSizedFormat, &internalFormat, |
| + if (!this->configToGLFormats(desc.fConfig, useSizedFormat, &internalFormat, |
| &externalFormat, &externalType)) { |
| return false; |
| } |
| + if (dataConfig != desc.fConfig) { |
| + // call this again if we're going to upload a different config than the texture's config. |
| + if (!this->configToGLFormats(dataConfig, false, nullptr, &externalFormat, |
| + &externalType)) { |
| + return false; |
| + } |
| + } |
| + |
| /* |
| * check whether to allocate a temporary buffer for flipping y or |
| * because our srcData has extra bytes past each row. If so, we need |
| @@ -1260,13 +1284,7 @@ int GrGLGpu::getCompatibleStencilIndex(GrPixelConfig config) { |
| GrGLenum internalFormat = 0x0; // suppress warning |
| GrGLenum externalFormat = 0x0; // suppress warning |
| GrGLenum externalType = 0x0; // suppress warning |
| - bool useSizedFormat = false; |
| - if (kGL_GrGLStandard == this->glStandard() || |
| - (this->glVersion() >= GR_GL_VER(3, 0) && |
| - // ES3 only works with sized BGRA8 format if "GL_APPLE_texture_format_BGRA8888" enabled |
| - (kBGRA_8888_GrPixelConfig != config || !this->glCaps().bgraIsInternalFormat()))) { |
| - useSizedFormat = true; |
| - } |
| + bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo(), config); |
| if (!this->configToGLFormats(config, useSizedFormat, &internalFormat, |
| &externalFormat, &externalType)) { |
| GL_CALL(DeleteTextures(1, &colorID)); |
| @@ -3528,7 +3546,9 @@ GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, in |
| GrGLenum externalFormat = 0x0; // suppress warning |
| GrGLenum externalType = 0x0; // suppress warning |
| - this->configToGLFormats(config, false, &internalFormat, &externalFormat, &externalType); |
| + bool useSizedFormat = use_sized_format_for_texture(false, this->ctxInfo(), config); |
| + this->configToGLFormats(config, useSizedFormat, &internalFormat, &externalFormat, |
| + &externalType); |
| GL_CALL(TexImage2D(info->fTarget, 0, internalFormat, w, h, 0, externalFormat, |
| externalType, pixels)); |