зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1604622 - Use float16/float32 sized formats on es3+. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D58179 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
80b492019d
Коммит
ebd8c74f83
|
@ -22,8 +22,9 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
webgl::DriverUnpackInfo dui;
|
||||
const GLint* swizzle = nullptr;
|
||||
|
||||
const auto fnAdd = [&fua, &pi, &dui,
|
||||
&swizzle](webgl::EffectiveFormat effFormat) {
|
||||
const auto fnAdd = [&](webgl::EffectiveFormat effFormat) {
|
||||
MOZ_ASSERT_IF(swizzle, gl->IsSupported(gl::GLFeature::texture_swizzle));
|
||||
|
||||
auto usage = fua->EditUsage(effFormat);
|
||||
usage->textureSwizzleRGBA = swizzle;
|
||||
fua->AddTexUnpack(usage, pi, dui);
|
||||
|
@ -31,19 +32,18 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
fua->AllowUnsizedTexFormat(pi, usage);
|
||||
};
|
||||
|
||||
const bool needsSwizzle = gl->IsCoreProfile();
|
||||
MOZ_ASSERT_IF(needsSwizzle, gl->IsSupported(gl::GLFeature::texture_swizzle));
|
||||
|
||||
const bool needsSizedFormat = !gl->IsGLES();
|
||||
bool useSizedFormats = true;
|
||||
const bool hasSizedLegacyFormats = gl->IsCompatibilityProfile();
|
||||
if (gl->IsGLES() && gl->Version() < 300) {
|
||||
useSizedFormats = false;
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
||||
pi = {LOCAL_GL_RGBA, LOCAL_GL_FLOAT};
|
||||
dui = {pi.format, pi.format, pi.type};
|
||||
swizzle = nullptr;
|
||||
if (needsSizedFormat ||
|
||||
gl->IsExtensionSupported(
|
||||
gl::GLContext::CHROMIUM_color_buffer_float_rgba)) {
|
||||
if (useSizedFormats) {
|
||||
dui.internalFormat = LOCAL_GL_RGBA32F;
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::RGBA32F);
|
||||
|
@ -53,7 +53,7 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
pi = {LOCAL_GL_RGB, LOCAL_GL_FLOAT};
|
||||
dui = {pi.format, pi.format, pi.type};
|
||||
swizzle = nullptr;
|
||||
if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
dui.internalFormat = LOCAL_GL_RGB32F;
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::RGB32F);
|
||||
|
@ -63,11 +63,14 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
pi = {LOCAL_GL_LUMINANCE, LOCAL_GL_FLOAT};
|
||||
dui = {pi.format, pi.format, pi.type};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_R32F, LOCAL_GL_RED, LOCAL_GL_FLOAT};
|
||||
swizzle = webgl::FormatUsageInfo::kLuminanceSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_LUMINANCE32F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_R32F;
|
||||
dui.unpackFormat = LOCAL_GL_RED;
|
||||
swizzle = webgl::FormatUsageInfo::kLuminanceSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Luminance32F);
|
||||
|
||||
|
@ -76,11 +79,14 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
pi = {LOCAL_GL_ALPHA, LOCAL_GL_FLOAT};
|
||||
dui = {pi.format, pi.format, pi.type};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_R32F, LOCAL_GL_RED, LOCAL_GL_FLOAT};
|
||||
swizzle = webgl::FormatUsageInfo::kAlphaSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_ALPHA32F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_R32F;
|
||||
dui.unpackFormat = LOCAL_GL_RED;
|
||||
swizzle = webgl::FormatUsageInfo::kAlphaSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Alpha32F);
|
||||
|
||||
|
@ -89,11 +95,14 @@ WebGLExtensionTextureFloat::WebGLExtensionTextureFloat(WebGLContext* webgl)
|
|||
pi = {LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_FLOAT};
|
||||
dui = {pi.format, pi.format, pi.type};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_RG32F, LOCAL_GL_RG, LOCAL_GL_FLOAT};
|
||||
swizzle = webgl::FormatUsageInfo::kLumAlphaSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_LUMINANCE_ALPHA32F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_RG32F;
|
||||
dui.unpackFormat = LOCAL_GL_RG;
|
||||
swizzle = webgl::FormatUsageInfo::kLumAlphaSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Luminance32FAlpha32F);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,9 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
webgl::DriverUnpackInfo dui;
|
||||
const GLint* swizzle = nullptr;
|
||||
|
||||
const auto fnAdd = [&fua, &pi, &dui,
|
||||
&swizzle](webgl::EffectiveFormat effFormat) {
|
||||
const auto fnAdd = [&](webgl::EffectiveFormat effFormat) {
|
||||
MOZ_ASSERT_IF(swizzle, gl->IsSupported(gl::GLFeature::texture_swizzle));
|
||||
|
||||
auto usage = fua->EditUsage(effFormat);
|
||||
usage->textureSwizzleRGBA = swizzle;
|
||||
fua->AddTexUnpack(usage, pi, dui);
|
||||
|
@ -30,10 +31,11 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
fua->AllowUnsizedTexFormat(pi, usage);
|
||||
};
|
||||
|
||||
const bool needsSwizzle = gl->IsCoreProfile();
|
||||
MOZ_ASSERT_IF(needsSwizzle, gl->IsSupported(gl::GLFeature::texture_swizzle));
|
||||
|
||||
const bool needsSizedFormat = !gl->IsGLES();
|
||||
bool useSizedFormats = true;
|
||||
const bool hasSizedLegacyFormats = gl->IsCompatibilityProfile();
|
||||
if (gl->IsGLES() && gl->Version() < 300) {
|
||||
useSizedFormats = false;
|
||||
}
|
||||
|
||||
GLenum driverUnpackType = LOCAL_GL_HALF_FLOAT;
|
||||
if (!gl->IsSupported(gl::GLFeature::texture_half_float)) {
|
||||
|
@ -46,7 +48,7 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
pi = {LOCAL_GL_RGBA, LOCAL_GL_HALF_FLOAT_OES};
|
||||
dui = {pi.format, pi.format, driverUnpackType};
|
||||
swizzle = nullptr;
|
||||
if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
dui.internalFormat = LOCAL_GL_RGBA16F;
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::RGBA16F);
|
||||
|
@ -56,7 +58,7 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
pi = {LOCAL_GL_RGB, LOCAL_GL_HALF_FLOAT_OES};
|
||||
dui = {pi.format, pi.format, driverUnpackType};
|
||||
swizzle = nullptr;
|
||||
if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
dui.internalFormat = LOCAL_GL_RGB16F;
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::RGB16F);
|
||||
|
@ -66,11 +68,14 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
pi = {LOCAL_GL_LUMINANCE, LOCAL_GL_HALF_FLOAT_OES};
|
||||
dui = {pi.format, pi.format, driverUnpackType};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_R16F, LOCAL_GL_RED, driverUnpackType};
|
||||
swizzle = webgl::FormatUsageInfo::kLuminanceSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_LUMINANCE16F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_R16F;
|
||||
dui.unpackFormat = LOCAL_GL_RED;
|
||||
swizzle = webgl::FormatUsageInfo::kLuminanceSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Luminance16F);
|
||||
|
||||
|
@ -79,11 +84,14 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
pi = {LOCAL_GL_ALPHA, LOCAL_GL_HALF_FLOAT_OES};
|
||||
dui = {pi.format, pi.format, driverUnpackType};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_R16F, LOCAL_GL_RED, driverUnpackType};
|
||||
swizzle = webgl::FormatUsageInfo::kAlphaSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_ALPHA16F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_R16F;
|
||||
dui.unpackFormat = LOCAL_GL_RED;
|
||||
swizzle = webgl::FormatUsageInfo::kAlphaSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Alpha16F);
|
||||
|
||||
|
@ -92,11 +100,14 @@ WebGLExtensionTextureHalfFloat::WebGLExtensionTextureHalfFloat(
|
|||
pi = {LOCAL_GL_LUMINANCE_ALPHA, LOCAL_GL_HALF_FLOAT_OES};
|
||||
dui = {pi.format, pi.format, driverUnpackType};
|
||||
swizzle = nullptr;
|
||||
if (needsSwizzle) {
|
||||
dui = {LOCAL_GL_RG16F, LOCAL_GL_RG, driverUnpackType};
|
||||
swizzle = webgl::FormatUsageInfo::kLumAlphaSwizzleRGBA;
|
||||
} else if (needsSizedFormat) {
|
||||
if (useSizedFormats) {
|
||||
if (hasSizedLegacyFormats) {
|
||||
dui.internalFormat = LOCAL_GL_LUMINANCE_ALPHA16F_ARB;
|
||||
} else {
|
||||
dui.internalFormat = LOCAL_GL_RG16F;
|
||||
dui.unpackFormat = LOCAL_GL_RG;
|
||||
swizzle = webgl::FormatUsageInfo::kLumAlphaSwizzleRGBA;
|
||||
}
|
||||
}
|
||||
fnAdd(webgl::EffectiveFormat::Luminance16FAlpha16F);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче