Commit 6caa2652 by Mohan Maiya Committed by Commit Bot

Vulkan: Support float textures and renderbuffers

Fixed support in the vulkan backend for legacy GLES2.0 formats (luminance, alpha, luminance_alpha) Correctly exposed the following extensions: OES_texture_float OES_texture_half_float OES_texture_float_linear OES_texture_half_float_linear EXT_color_buffer_float EXT_color_buffer_half_float Some of the above extensions have different requirements depending on other extension support and the context client version, and were incorrectly assuming the most restrictive requirements to be exposed. Implemented end2end tests for: OES_texture_float OES_texture_half_float OES_texture_float_linear OES_texture_half_float_linear EXT_color_buffer_float EXT_color_buffer_half_float Bug: angleproject:2898 Bug: angleproject:2726 Test: ./angle_end2end_tests --gtest_filter='Texture2DFloatTest*' Change-Id: I7024aa1393eadafb5a0fb83c23e9035aae650b67 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1740276 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent c4b1fbd6
......@@ -2,7 +2,7 @@
"src/libANGLE/renderer/gen_load_functions_table.py":
"e65c50e84fc38ad34d0eb0bebb84aab6",
"src/libANGLE/renderer/load_functions_data.json":
"2225ec8e466cb151fe383fc467d35d65",
"16264b125e5410a4791a0c2697a4ff77",
"src/libANGLE/renderer/load_functions_table_autogen.cpp":
"f4c1c06efea4b69ac29c7f8dff68ea6d"
"99e876f3871810c6a7fee8f4ff81b0e6"
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"ed6800108a872709e5e53fde2833aa86",
"src/libANGLE/renderer/vulkan/vk_format_map.json":
"0e63169b162b3720db40e80c80163edb",
"d83e8f19044c7709e33412231226a3ae",
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"8b9e38b91ec6b8b23573e2ef9df5284a"
"ffc343058ee7f21e0a945558e653c4fc"
}
\ No newline at end of file
......@@ -257,11 +257,20 @@ static bool DetermineHalfFloatTextureSupport(const TextureCapsMap &textureCaps)
}
// Checks for GL_OES_texture_half_float_linear support
static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
static bool DetermineHalfFloatTextureFilteringSupport(const TextureCapsMap &textureCaps,
bool checkLegacyFormats)
{
constexpr GLenum requiredFormats[] = {
GL_RGBA16F, GL_RGB16F, GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT, GL_ALPHA16F_EXT,
};
constexpr GLenum requiredFormats[] = {GL_RGBA16F, GL_RGB16F};
// If GL_OES_texture_half_float is present, this extension must also support legacy formats
// introduced by that extension
constexpr GLenum requiredFormatsES2[] = {GL_LUMINANCE_ALPHA16F_EXT, GL_LUMINANCE16F_EXT,
GL_ALPHA16F_EXT};
if (checkLegacyFormats &&
!GetFormatSupport(textureCaps, requiredFormatsES2, false, true, false, false))
{
return false;
}
return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false);
}
......@@ -277,11 +286,26 @@ static bool DetermineFloatTextureSupport(const TextureCapsMap &textureCaps)
}
// Checks for GL_OES_texture_float_linear support
static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps)
static bool DetermineFloatTextureFilteringSupport(const TextureCapsMap &textureCaps,
bool checkLegacyFormats)
{
constexpr GLenum requiredFormats[] = {
GL_RGBA32F, GL_RGB32F, GL_LUMINANCE_ALPHA32F_EXT, GL_LUMINANCE32F_EXT, GL_ALPHA32F_EXT,
GL_RGBA32F,
GL_RGB32F,
};
// If GL_OES_texture_float is present, this extension must also support legacy formats
// introduced by that extension
constexpr GLenum requiredFormatsES2[] = {
GL_LUMINANCE_ALPHA32F_EXT,
GL_LUMINANCE32F_EXT,
GL_ALPHA32F_EXT,
};
if (checkLegacyFormats &&
!GetFormatSupport(textureCaps, requiredFormatsES2, false, true, false, false))
{
return false;
}
return GetFormatSupport(textureCaps, requiredFormats, false, true, false, false);
}
......@@ -664,9 +688,9 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps);
textureHalfFloatLinear =
textureHalfFloat && DetermineHalfFloatTextureFilteringSupport(textureCaps);
DetermineHalfFloatTextureFilteringSupport(textureCaps, textureHalfFloat);
textureFloat = DetermineFloatTextureSupport(textureCaps);
textureFloatLinear = textureFloat && DetermineFloatTextureFilteringSupport(textureCaps);
textureFloatLinear = DetermineFloatTextureFilteringSupport(textureCaps, textureFloat);
textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat);
colorBufferHalfFloat = textureHalfFloat && DetermineColorBufferHalfFloatSupport(textureCaps);
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
......
......@@ -3271,6 +3271,15 @@ Extensions Context::generateSupportedExtensions() const
{
supportedExtensions.textureSRGBDecode = false;
}
// Don't expose GL_OES_texture_float_linear without full legacy float texture support
// The renderer may report OES_texture_float_linear without OES_texture_float
// This is valid in a GLES 3.0 context, but not in a GLES 2.0 context
if (!(supportedExtensions.textureFloat && supportedExtensions.textureHalfFloat))
{
supportedExtensions.textureFloatLinear = false;
supportedExtensions.textureHalfFloatLinear = false;
}
}
if (getClientVersion() < ES_3_1)
......@@ -3287,6 +3296,20 @@ Extensions Context::generateSupportedExtensions() const
{
// FIXME(geofflang): Don't support EXT_sRGB in non-ES2 contexts
// supportedExtensions.sRGB = false;
// If colorBufferFloat is disabled but colorBufferHalfFloat is enabled, then we will expose
// some floating-point formats as color buffer targets but reject blits between fixed-point
// and floating-point formats (this behavior is only enabled in colorBufferFloat, and must
// be rejected if only colorBufferHalfFloat is enabled).
// dEQP does not check for this, and will assume that floating-point and fixed-point formats
// can be blit onto each other if the format is available.
// We require colorBufferFloat to be present in order to enable colorBufferHalfFloat, so
// that blitting is always allowed if the requested formats are exposed and have the correct
// feature capabilities
if (!supportedExtensions.colorBufferFloat)
{
supportedExtensions.colorBufferHalfFloat = false;
}
}
// Some extensions are always available because they are implemented in the GL layer.
......
......@@ -144,6 +144,15 @@ static bool RequireExtOrExtOrExt(const Version &, const Extensions &extensions)
return extensions.*bool1 || extensions.*bool2 || extensions.*bool3;
}
static bool UnsizedHalfFloatOESRGBATextureAttachmentSupport(const Version &clientVersion,
const Extensions &extensions)
{
// dEQP requires ES3 + EXT_color_buffer_half_float for rendering to RGB[A] + HALF_FLOAT_OES
// textures but WebGL allows it with just ES 2.0
return (clientVersion.major >= 3 || extensions.webglCompatibility) &&
extensions.colorBufferHalfFloat;
}
// R8, RG8
static bool SizedRGSupport(const Version &clientVersion, const Extensions &extensions)
{
......@@ -1004,8 +1013,8 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT, GL_FLOAT, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, AlwaysSupported, NeverSupported);
AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureHalfFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureHalfFloatLinear>, AlwaysSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, RequireExt<&Extensions::colorBufferHalfFloat>, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, RequireExt<&Extensions::colorBufferHalfFloat>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 16, 16, 16, 0, 0, GL_RGB, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, UnsizedHalfFloatOESRGBATextureAttachmentSupport, NeverSupported);
AddRGBAFormat(&map, GL_RGBA, false, 16, 16, 16, 16, 0, GL_RGBA, GL_HALF_FLOAT_OES, GL_FLOAT, false, RequireExt<&Extensions::textureHalfFloat>, RequireExt<&Extensions::textureHalfFloatLinear>, UnsizedHalfFloatOESRGBATextureAttachmentSupport, NeverSupported);
AddRGBAFormat(&map, GL_RED, false, 32, 0, 0, 0, 0, GL_RED, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, AlwaysSupported, NeverSupported);
AddRGBAFormat(&map, GL_RG, false, 32, 32, 0, 0, 0, GL_RG, GL_FLOAT, GL_FLOAT, false, RequireExtAndExt<&Extensions::textureFloat, &Extensions::textureRG>, RequireExt<&Extensions::textureFloatLinear>, AlwaysSupported, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 32, 32, 32, 0, 0, GL_RGB, GL_FLOAT, GL_FLOAT, false, RequireExt<&Extensions::textureFloat>, RequireExt<&Extensions::textureFloatLinear>, NeverSupported, NeverSupported);
......
......@@ -54,6 +54,9 @@
}
},
"GL_ALPHA32F_EXT": {
"R32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat, 1>"
},
"NONE": {
"GL_FLOAT": "LoadA32FToRGBA32F"
}
......@@ -93,6 +96,9 @@
}
},
"GL_LUMINANCE32F_EXT": {
"R32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat, 1>"
},
"NONE": {
"GL_FLOAT": "LoadL32FToRGBA32F"
}
......@@ -529,6 +535,10 @@
}
},
"GL_LUMINANCE_ALPHA16F_EXT": {
"R16G16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 2>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 2>"
},
"NONE": {
"GL_HALF_FLOAT": "LoadLA16FToRGBA16F",
"GL_HALF_FLOAT_OES": "LoadLA16FToRGBA16F"
......@@ -613,6 +623,9 @@
}
},
"GL_LUMINANCE_ALPHA32F_EXT": {
"R32G32_FLOAT": {
"GL_FLOAT": "LoadToNative<GLfloat, 2>"
},
"NONE": {
"GL_FLOAT": "LoadLA32FToRGBA32F"
}
......@@ -670,6 +683,10 @@
}
},
"GL_LUMINANCE16F_EXT": {
"R16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 1>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 1>"
},
"NONE": {
"GL_HALF_FLOAT": "LoadL16FToRGBA16F",
"GL_HALF_FLOAT_OES": "LoadL16FToRGBA16F"
......@@ -696,6 +713,10 @@
}
},
"GL_ALPHA16F_EXT": {
"R16_FLOAT": {
"GL_HALF_FLOAT": "LoadToNative<GLhalf, 1>",
"GL_HALF_FLOAT_OES": "LoadToNative<GLhalf, 1>"
},
"NONE": {
"GL_HALF_FLOAT": "LoadA16FToRGBA16F",
"GL_HALF_FLOAT_OES": "LoadA16FToRGBA16F"
......
......@@ -112,6 +112,20 @@ LoadImageFunctionInfo ALPHA_to_default(GLenum type)
}
}
LoadImageFunctionInfo ALPHA16F_EXT_to_R16_FLOAT(GLenum type)
{
switch (type)
{
case GL_HALF_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 1>, false);
case GL_HALF_FLOAT_OES:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 1>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo ALPHA16F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -126,6 +140,18 @@ LoadImageFunctionInfo ALPHA16F_EXT_to_default(GLenum type)
}
}
LoadImageFunctionInfo ALPHA32F_EXT_to_R32_FLOAT(GLenum type)
{
switch (type)
{
case GL_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLfloat, 1>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo ALPHA32F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -1538,6 +1564,20 @@ LoadImageFunctionInfo LUMINANCE_to_default(GLenum type)
}
}
LoadImageFunctionInfo LUMINANCE16F_EXT_to_R16_FLOAT(GLenum type)
{
switch (type)
{
case GL_HALF_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 1>, false);
case GL_HALF_FLOAT_OES:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 1>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo LUMINANCE16F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -1552,6 +1592,18 @@ LoadImageFunctionInfo LUMINANCE16F_EXT_to_default(GLenum type)
}
}
LoadImageFunctionInfo LUMINANCE32F_EXT_to_R32_FLOAT(GLenum type)
{
switch (type)
{
case GL_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLfloat, 1>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo LUMINANCE32F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -1654,6 +1706,20 @@ LoadImageFunctionInfo LUMINANCE_ALPHA_to_default(GLenum type)
}
}
LoadImageFunctionInfo LUMINANCE_ALPHA16F_EXT_to_R16G16_FLOAT(GLenum type)
{
switch (type)
{
case GL_HALF_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 2>, false);
case GL_HALF_FLOAT_OES:
return LoadImageFunctionInfo(LoadToNative<GLhalf, 2>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo LUMINANCE_ALPHA16F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -1668,6 +1734,18 @@ LoadImageFunctionInfo LUMINANCE_ALPHA16F_EXT_to_default(GLenum type)
}
}
LoadImageFunctionInfo LUMINANCE_ALPHA32F_EXT_to_R32G32_FLOAT(GLenum type)
{
switch (type)
{
case GL_FLOAT:
return LoadImageFunctionInfo(LoadToNative<GLfloat, 2>, false);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo LUMINANCE_ALPHA32F_EXT_to_default(GLenum type)
{
switch (type)
......@@ -2939,9 +3017,25 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
}
}
case GL_ALPHA16F_EXT:
return ALPHA16F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R16_FLOAT:
return ALPHA16F_EXT_to_R16_FLOAT;
default:
return ALPHA16F_EXT_to_default;
}
}
case GL_ALPHA32F_EXT:
return ALPHA32F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R32_FLOAT:
return ALPHA32F_EXT_to_R32_FLOAT;
default:
return ALPHA32F_EXT_to_default;
}
}
case GL_ALPHA8_EXT:
{
switch (angleFormat)
......@@ -3404,9 +3498,25 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
}
}
case GL_LUMINANCE16F_EXT:
return LUMINANCE16F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R16_FLOAT:
return LUMINANCE16F_EXT_to_R16_FLOAT;
default:
return LUMINANCE16F_EXT_to_default;
}
}
case GL_LUMINANCE32F_EXT:
return LUMINANCE32F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R32_FLOAT:
return LUMINANCE32F_EXT_to_R32_FLOAT;
default:
return LUMINANCE32F_EXT_to_default;
}
}
case GL_LUMINANCE8_ALPHA8_EXT:
{
switch (angleFormat)
......@@ -3446,9 +3556,25 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
}
}
case GL_LUMINANCE_ALPHA16F_EXT:
return LUMINANCE_ALPHA16F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R16G16_FLOAT:
return LUMINANCE_ALPHA16F_EXT_to_R16G16_FLOAT;
default:
return LUMINANCE_ALPHA16F_EXT_to_default;
}
}
case GL_LUMINANCE_ALPHA32F_EXT:
return LUMINANCE_ALPHA32F_EXT_to_default;
{
switch (angleFormat)
{
case FormatID::R32G32_FLOAT:
return LUMINANCE_ALPHA32F_EXT_to_R32G32_FLOAT;
default:
return LUMINANCE_ALPHA32F_EXT_to_default;
}
}
case GL_R11F_G11F_B10F:
{
switch (angleFormat)
......
......@@ -462,7 +462,14 @@ GLenum FramebufferVk::getImplementationColorReadFormat(const gl::Context *contex
GLenum FramebufferVk::getImplementationColorReadType(const gl::Context *context) const
{
return GetReadAttachmentInfo(context, mRenderTargetCache.getColorRead(mState)).type;
GLenum readType = GetReadAttachmentInfo(context, mRenderTargetCache.getColorRead(mState)).type;
if (context->getClientMajorVersion() < 3 && readType == GL_HALF_FLOAT)
{
// GL_HALF_FLOAT was not introduced until GLES 3.0, and has a different value from
// GL_HALF_FLOAT_OES
readType = GL_HALF_FLOAT_OES;
}
return readType;
}
angle::Result FramebufferVk::readPixels(const gl::Context *context,
......
......@@ -172,6 +172,18 @@
"A32_FLOAT": {
"image": "R32_FLOAT"
},
"L16_FLOAT": {
"image": "R16_FLOAT"
},
"L32_FLOAT": {
"image": "R32_FLOAT"
},
"L16A16_FLOAT": {
"image": "R16G16_FLOAT"
},
"L32A32_FLOAT": {
"image": "R32G32_FLOAT"
},
"A8_UNORM": {
"image": "R8_UNORM"
},
......
......@@ -978,19 +978,35 @@ void Format::initialize(RendererVk *renderer, const angle::Format &angleFormat)
break;
case angle::FormatID::L16A16_FLOAT:
// This format is not implemented in Vulkan.
internalFormat = GL_LUMINANCE_ALPHA16F_EXT;
imageFormatID = angle::FormatID::R16G16_FLOAT;
vkImageFormat = VK_FORMAT_R16G16_SFLOAT;
imageInitializerFunction = nullptr;
break;
case angle::FormatID::L16_FLOAT:
// This format is not implemented in Vulkan.
internalFormat = GL_LUMINANCE16F_EXT;
imageFormatID = angle::FormatID::R16_FLOAT;
vkImageFormat = VK_FORMAT_R16_SFLOAT;
imageInitializerFunction = nullptr;
break;
case angle::FormatID::L32A32_FLOAT:
// This format is not implemented in Vulkan.
internalFormat = GL_LUMINANCE_ALPHA32F_EXT;
imageFormatID = angle::FormatID::R32G32_FLOAT;
vkImageFormat = VK_FORMAT_R32G32_SFLOAT;
imageInitializerFunction = nullptr;
break;
case angle::FormatID::L32_FLOAT:
// This format is not implemented in Vulkan.
internalFormat = GL_LUMINANCE32F_EXT;
imageFormatID = angle::FormatID::R32_FLOAT;
vkImageFormat = VK_FORMAT_R32_SFLOAT;
imageInitializerFunction = nullptr;
break;
case angle::FormatID::L8A8_UNORM:
......
......@@ -342,55 +342,51 @@ void MapSwizzleState(const ContextVk *contextVk,
gl::SwizzleState internalSwizzle;
switch (format.internalFormat)
if (angleFormat.isLUMA())
{
case GL_LUMINANCE8_OES:
internalSwizzle.swizzleRed = GL_RED;
internalSwizzle.swizzleGreen = GL_RED;
internalSwizzle.swizzleBlue = GL_RED;
GLenum swizzleRGB, swizzleA;
if (angleFormat.luminanceBits > 0)
{
swizzleRGB = GL_RED;
swizzleA = (angleFormat.alphaBits > 0 ? GL_GREEN : GL_ONE);
}
else
{
swizzleRGB = GL_ZERO;
swizzleA = GL_RED;
}
internalSwizzle.swizzleRed = swizzleRGB;
internalSwizzle.swizzleGreen = swizzleRGB;
internalSwizzle.swizzleBlue = swizzleRGB;
internalSwizzle.swizzleAlpha = swizzleA;
}
else
{
if (angleFormat.hasDepthOrStencilBits())
{
bool hasRed = angleFormat.depthBits > 0;
// In OES_depth_texture/ARB_depth_texture, depth
// textures are treated as luminance.
// If the internalformat was not sized, use OES_depth_texture behavior
bool hasGB = hasRed && !sized;
internalSwizzle.swizzleRed = hasRed ? GL_RED : GL_ZERO;
internalSwizzle.swizzleGreen = hasGB ? GL_RED : GL_ZERO;
internalSwizzle.swizzleBlue = hasGB ? GL_RED : GL_ZERO;
internalSwizzle.swizzleAlpha = GL_ONE;
break;
case GL_LUMINANCE8_ALPHA8_OES:
internalSwizzle.swizzleRed = GL_RED;
internalSwizzle.swizzleGreen = GL_RED;
internalSwizzle.swizzleBlue = GL_RED;
internalSwizzle.swizzleAlpha = GL_GREEN;
break;
case GL_ALPHA8_OES:
internalSwizzle.swizzleRed = GL_ZERO;
internalSwizzle.swizzleGreen = GL_ZERO;
internalSwizzle.swizzleBlue = GL_ZERO;
internalSwizzle.swizzleAlpha = GL_RED;
break;
default:
if (angleFormat.hasDepthOrStencilBits())
{
bool hasRed = angleFormat.depthBits > 0;
// In OES_depth_texture/ARB_depth_texture, depth
// textures are treated as luminance.
// If the internalformat was not sized, use OES_depth_texture behavior
bool hasGB = hasRed && !sized;
internalSwizzle.swizzleRed = hasRed ? GL_RED : GL_ZERO;
internalSwizzle.swizzleGreen = hasGB ? GL_RED : GL_ZERO;
internalSwizzle.swizzleBlue = hasGB ? GL_RED : GL_ZERO;
internalSwizzle.swizzleAlpha = GL_ONE;
}
else
}
else
{
// Color bits are all zero for blocked formats
if (!angleFormat.isBlock)
{
if (angleFormat.isBlock)
{
// Color bits are all zero for blocked formats, so the
// below will erroneously set swizzle to (0, 0, 0, 1).
break;
}
// Set any missing channel to default in case the emulated format has that channel.
internalSwizzle.swizzleRed = angleFormat.redBits > 0 ? GL_RED : GL_ZERO;
internalSwizzle.swizzleGreen = angleFormat.greenBits > 0 ? GL_GREEN : GL_ZERO;
internalSwizzle.swizzleBlue = angleFormat.blueBits > 0 ? GL_BLUE : GL_ZERO;
internalSwizzle.swizzleAlpha = angleFormat.alphaBits > 0 ? GL_ALPHA : GL_ONE;
}
break;
}
}
ComposeSwizzleState(internalSwizzle, swizzleState, swizzleStateOut);
}
......
......@@ -2021,8 +2021,13 @@ angle::Result ImageHelper::generateMipmapsWithBlit(ContextVk *contextVk, GLuint
mipWidth = nextMipWidth;
mipHeight = nextMipHeight;
commandBuffer->blitImage(mImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_LINEAR);
bool formatSupportsLinearFiltering = contextVk->getRenderer()->hasImageFormatFeatureBits(
getFormat().vkImageFormat, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
commandBuffer->blitImage(
mImage, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, mImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit,
formatSupportsLinearFiltering ? VK_FILTER_LINEAR : VK_FILTER_NEAREST);
}
// Transition the last mip level to the same layout as all the other ones, so we can declare
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment