aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-07-16 13:32:56 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-07-16 13:32:56 -0700
commitee5da55477d1679eaf50b56b6017cbfc07af02a7 (patch)
treeaa001bf600c2143b412ee4101d30fb1bf117d1fa /src/gpu/gl
parent2ec93fc1d3206db4dcf74ccfc1c995badbc135e9 (diff)
32 bpp floating point textures
This is VERY preliminary, but it was sufficient for me to get 32 bit floating point textures in a sample app BUG=skia: R=bsalomon@chromium.org, bsalomon@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/359803003
Diffstat (limited to 'src/gpu/gl')
-rw-r--r--src/gpu/gl/GrGLCaps.cpp19
-rw-r--r--src/gpu/gl/GrGLDefines.h1
-rw-r--r--src/gpu/gl/GrGpuGL.cpp8
3 files changed, 26 insertions, 2 deletions
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 8f2d4c1297..178550bd5c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -444,6 +444,10 @@ void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
}
}
+ if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
+ fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
+ }
+
// If we don't support MSAA then undo any places above where we set a config as renderable with
// msaa.
if (kNone_MSFBOType == fMSFBOType) {
@@ -504,7 +508,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
// First check version for support
if (kGL_GrGLStandard == standard) {
hasETC1 = hasCompressTex2D &&
- (version >= GR_GL_VER(4, 3) ||
+ (version >= GR_GL_VER(4, 3) ||
ctxInfo.hasExtension("GL_ARB_ES3_compatibility"));
} else {
hasETC1 = hasCompressTex2D &&
@@ -558,6 +562,19 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
} else {
fConfigTextureSupport[kR11_EAC_GrPixelConfig] = version >= GR_GL_VER(3, 0);
}
+
+ // Check for floating point texture support
+ // NOTE: We disallow floating point textures on ES devices if linear
+ // filtering modes are not supported. This is for simplicity, but a more
+ // granular approach is possible. Coincidentally, floating point textures became part of
+ // the standard in ES3.1 / OGL 3.1, hence the shorthand
+ bool hasFPTextures = version >= GR_GL_VER(3, 1);
+ if (!hasFPTextures) {
+ hasFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
+ (ctxInfo.hasExtension("OES_texture_float_linear") &&
+ ctxInfo.hasExtension("GL_OES_texture_float"));
+ }
+ fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
}
bool GrGLCaps::readPixelsSupported(const GrGLInterface* intf,
diff --git a/src/gpu/gl/GrGLDefines.h b/src/gpu/gl/GrGLDefines.h
index 1e8d7cc278..77b7a15366 100644
--- a/src/gpu/gl/GrGLDefines.h
+++ b/src/gpu/gl/GrGLDefines.h
@@ -731,6 +731,7 @@
#define GR_GL_RGB5_A1 0x8057
#define GR_GL_RGB565 0x8D62
#define GR_GL_RGBA8 0x8058
+#define GR_GL_RGBA32F 0x8814
#define GR_GL_RGB8 0x8051
#define GR_GL_BGRA8 0x93A1
#define GR_GL_SRGB 0x8C40
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index eddccc39f6..b66feb27c0 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -639,7 +639,8 @@ bool GrGpuGL::uploadTexData(const GrGLTexture::Desc& desc,
if (glFlipY) {
GL_CALL(PixelStorei(GR_GL_UNPACK_FLIP_Y, GR_GL_TRUE));
}
- GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT, static_cast<GrGLint>(bpp)));
+ GL_CALL(PixelStorei(GR_GL_UNPACK_ALIGNMENT,
+ static_cast<GrGLint>(GrUnpackAlignment(dataConfig))));
}
bool succeeded = true;
if (isNewTexture &&
@@ -2697,6 +2698,11 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config,
case kR11_EAC_GrPixelConfig:
*internalFormat = GR_GL_COMPRESSED_R11;
break;
+ case kRGBA_float_GrPixelConfig:
+ *internalFormat = GR_GL_RGBA32F;
+ *externalFormat = GR_GL_RGBA;
+ *externalType = GR_GL_FLOAT;
+ break;
default:
return false;
}