b=738872; implement WebGL OES_texture_half_float; part 3 - desktop GL compat; r=jgilbert

This commit is contained in:
Vladimir Vukicevic 2014-01-27 13:30:33 -05:00
parent a988bc2a34
commit 9e20208adb
3 changed files with 27 additions and 8 deletions

View File

@ -88,7 +88,11 @@ bool WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
case OES_texture_float_linear:
return gl->IsSupported(GLFeature::texture_float_linear);
case OES_texture_half_float:
return gl->IsExtensionSupported(GLContext::OES_texture_half_float);
// If we have Feature::texture_half_float, we must not be on ES2
// and need to translate HALF_FLOAT_OES -> HALF_FLOAT. We do that
// right before making the relevant calls.
return gl->IsExtensionSupported(GLContext::OES_texture_half_float) ||
gl->IsSupported(GLFeature::texture_half_float);
case OES_vertex_array_object:
return WebGLExtensionVertexArray::IsSupported(this);
case EXT_texture_filter_anisotropic:

View File

@ -3674,16 +3674,25 @@ GLenum WebGLContext::CheckedTexImage2D(GLenum target,
type != imageInfo.Type();
}
// convert type for half float if not on GLES2
GLenum realType = type;
if (realType == LOCAL_GL_HALF_FLOAT_OES && !gl->IsGLES2()) {
realType = LOCAL_GL_HALF_FLOAT;
}
if (sizeMayChange) {
UpdateWebGLErrorAndClearGLError();
gl->fTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
gl->fTexImage2D(target, level, internalFormat, width, height, border, format, realType, data);
GLenum error = LOCAL_GL_NO_ERROR;
UpdateWebGLErrorAndClearGLError(&error);
return error;
} else {
gl->fTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
return LOCAL_GL_NO_ERROR;
}
gl->fTexImage2D(target, level, internalFormat, width, height, border, format, realType, data);
return LOCAL_GL_NO_ERROR;
}
void
@ -3972,13 +3981,19 @@ WebGLContext::TexSubImage2D_base(GLenum target, GLint level,
// There are checks above to ensure that this won't overflow.
size_t dstStride = RoundedToNextMultipleOf(dstPlainRowSize, mPixelStoreUnpackAlignment).value();
// convert type for half float if not on GLES2
GLenum realType = type;
if (realType == LOCAL_GL_HALF_FLOAT_OES && !gl->IsGLES2()) {
realType = LOCAL_GL_HALF_FLOAT;
}
if (actualSrcFormat == dstFormat &&
srcPremultiplied == mPixelStorePremultiplyAlpha &&
srcStride == dstStride &&
!mPixelStoreFlipY)
{
// no conversion, no flipping, so we avoid copying anything and just pass the source pointer
gl->fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
gl->fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, realType, pixels);
}
else
{
@ -3989,7 +4004,7 @@ WebGLContext::TexSubImage2D_base(GLenum target, GLint level,
actualSrcFormat, srcPremultiplied,
dstFormat, mPixelStorePremultiplyAlpha, dstTexelSize);
gl->fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, convertedData);
gl->fTexSubImage2D(target, level, xoffset, yoffset, width, height, format, realType, convertedData);
}
}

View File

@ -186,7 +186,7 @@ public:
static const size_t sMinDrawBuffers = 4;
/*
WEBGL_draw_buffers does not give a minal value for GL_MAX_DRAW_BUFFERS. But, we request
for GL_MAX_DRAW_BUFFERS = 4 at least to be able to use all requested color attachements.
for GL_MAX_DRAW_BUFFERS = 4 at least to be able to use all requested color attachments.
See DrawBuffersWEBGL in WebGLExtensionDrawBuffers.cpp inner comments for more informations.
*/