Fix float and half float support on mobile.

It's unclear what params should be used for half float alpha
rendertargets, so they are disabled for the moment.

Review URL: https://codereview.chromium.org/799593002
This commit is contained in:
jvanverth 2014-12-12 05:58:06 -08:00 committed by Commit bot
parent b5f4961b30
commit a60b2ead80
3 changed files with 20 additions and 12 deletions

View File

@ -470,21 +470,28 @@ void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
}
if (this->isConfigTexturable(kRGBA_float_GrPixelConfig)) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kYes_MSAA] = true;
} else {
// for now we don't support float point MSAA on ES
if (ctxInfo.hasExtension("GL_EXT_color_buffer_float")) {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = true;
} else {
fConfigRenderSupport[kRGBA_float_GrPixelConfig][kNo_MSAA] = false;
}
// for now we don't support floating point MSAA on ES
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
}
}
if (this->isConfigTexturable(kAlpha_half_GrPixelConfig)) {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
if (kGL_GrGLStandard == standard) {
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = true;
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = true;
} else {
// for now we don't support float point MSAA on ES
// in theory, check for "GL_EXT_color_buffer_half_float"
// for now we don't support half float alpha render target on ES
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kNo_MSAA] = false;
fConfigRenderSupport[kAlpha_half_GrPixelConfig][kYes_MSAA] = false;
}
}
@ -620,7 +627,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
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_linear") &&
ctxInfo.hasExtension("GL_OES_texture_float"));
}
fConfigTextureSupport[kRGBA_float_GrPixelConfig] = hasFPTextures;
@ -633,7 +640,7 @@ void GrGLCaps::initConfigTexturableTable(const GrGLContextInfo& ctxInfo, const G
bool hasHalfFPTextures = version >= GR_GL_VER(3, 1);
if (!hasHalfFPTextures) {
hasHalfFPTextures = ctxInfo.hasExtension("GL_ARB_texture_float") ||
(ctxInfo.hasExtension("OES_texture_half_float_linear") &&
(ctxInfo.hasExtension("GL_OES_texture_half_float_linear") &&
ctxInfo.hasExtension("GL_OES_texture_half_float"));
}
fConfigTextureSupport[kAlpha_half_GrPixelConfig] = hasHalfFPTextures && fTextureRedSupport;

View File

@ -2246,16 +2246,18 @@ bool GrGpuGL::configToGLFormats(GrPixelConfig config,
break;
case kAlpha_half_GrPixelConfig:
if (this->glCaps().textureRedSupport()) {
if (kGLES_GrGLStandard == this->glStandard() && this->glVersion() < GR_GL_VER(3, 1)) {
*internalFormat = GR_GL_ALPHA;
*externalFormat = GR_GL_ALPHA;
*externalType = GR_GL_HALF_FLOAT_OES;
} else if (this->glCaps().textureRedSupport()) {
*internalFormat = GR_GL_R16F;
*externalFormat = GR_GL_RED;
*externalType = (kGLES_GrGLStandard == this->glStandard()) ? GR_GL_HALF_FLOAT
: GR_GL_HALF_FLOAT_OES;
*externalType = GR_GL_HALF_FLOAT;
} else {
*internalFormat = GR_GL_ALPHA16F;
*externalFormat = GR_GL_ALPHA;
*externalType = (kGLES_GrGLStandard == this->glStandard()) ? GR_GL_HALF_FLOAT
: GR_GL_HALF_FLOAT_OES;
*externalType = GR_GL_HALF_FLOAT;
}
break;

View File

@ -127,7 +127,6 @@ DEF_GPUTEST(HalfFloatTextureTest, reporter, factory) {
fpTexture->writePixels(0, 0, DEV_W, DEV_H, desc.fConfig, controlPixelData, 0);
fpTexture->readPixels(0, 0, DEV_W, DEV_H, desc.fConfig, readBuffer, 0);
for (int j = 0; j < HALF_CONTROL_ARRAY_SIZE; ++j) {
SkASSERT(readBuffer[j] == controlPixelData[j]);
REPORTER_ASSERT(reporter, readBuffer[j] == controlPixelData[j]);
}
}