Index: src/gpu/gl/GrGpuGL.cpp |
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp |
index 39cb84ecfe8247616b4bd10b77b67e5284c30031..bc6adcd0652cfcf82955334159f6cd6df744ce73 100644 |
--- a/src/gpu/gl/GrGpuGL.cpp |
+++ b/src/gpu/gl/GrGpuGL.cpp |
@@ -592,6 +592,11 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, |
&externalFormat, &externalType)) { |
return false; |
} |
+ |
+ bool is3DTexture = SkToBool(desc.fFlags & k3DTexture_GrTextureFlagBit); |
+ if (is3DTexture && !this->glCaps().has3DTexImageSupport()) { |
+ return false; |
+ } |
/* |
* check whether to allocate a temporary buffer for flipping y or |
@@ -657,6 +662,16 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, |
1, // levels |
internalFormat, |
desc.fWidth, desc.fHeight)); |
+ } else if (is3DTexture) { |
+ GL_ALLOC_CALL(this->glInterface(), |
+ TexImage3D(GR_GL_TEXTURE_3D, |
+ 0, // level |
+ internalFormat, |
+ desc.fWidth, desc.fHeight, |
+ desc.fWidth, // FIXME: width is used as depth |
bsalomon
2014/09/19 13:47:04
Why not just add a depth to fDesc and get rid of t
sugoi1
2014/09/24 19:12:48
Done.
|
+ 0, // border |
+ externalFormat, externalType, |
+ data)); |
} else { |
GL_ALLOC_CALL(this->glInterface(), |
TexImage2D(GR_GL_TEXTURE_2D, |
@@ -674,23 +689,45 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc, |
// if we have data and we used TexStorage to create the texture, we |
// now upload with TexSubImage. |
if (data && useTexStorage) { |
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, |
- 0, // level |
- left, top, |
- width, height, |
- externalFormat, externalType, |
- data)); |
+ if (is3DTexture) { |
+ GL_CALL(TexSubImage3D(GR_GL_TEXTURE_3D, |
+ 0, // level, |
+ left, top, |
+ left, // FIXME: left used as Z offset |
+ desc.fWidth, desc.fHeight, |
+ desc.fWidth, // FIXME: width is used as depth |
+ externalFormat, externalType, |
+ data)); |
+ } else { |
+ GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, |
+ 0, // level |
+ left, top, |
+ width, height, |
+ externalFormat, externalType, |
+ data)); |
+ } |
} |
} |
} else { |
if (swFlipY || glFlipY) { |
top = desc.fHeight - (top + height); |
} |
- GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, |
- 0, // level |
- left, top, |
- width, height, |
- externalFormat, externalType, data)); |
+ if (is3DTexture) { |
+ GL_CALL(TexSubImage3D(GR_GL_TEXTURE_3D, |
+ 0, // level, |
+ left, top, |
+ left, // FIXME: left used as Z offset |
+ desc.fWidth, desc.fHeight, |
+ desc.fWidth, // FIXME: width is used as depth |
+ externalFormat, externalType, |
+ data)); |
+ } else { |
+ GL_CALL(TexSubImage2D(GR_GL_TEXTURE_2D, |
+ 0, // level |
+ left, top, |
+ width, height, |
+ externalFormat, externalType, data)); |
+ } |
} |
if (restoreGLRowLength) { |
@@ -741,7 +778,9 @@ bool GrGpuGL::uploadCompressedTexData(const GrGLTexture::Desc& desc, |
// We only need the internal format for compressed 2D textures. |
GrGLenum internalFormat = 0; |
- if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, NULL, NULL)) { |
+ if (!this->configToGLFormats(desc.fConfig, false, &internalFormat, NULL, NULL) || |
+ // Compressed 3D textures not supported |
+ SkToBool(desc.fFlags & k3DTexture_GrTextureFlagBit)) { |
return false; |
} |