Commit cb8a921b by Geoff Lang Committed by Commit Bot

Vulkan: Support RGB/BGR backbuffers emulated on RGBA/BGRA.

BUG=angleproject:2692 BUG=angleproject:2523 BUG=angleproject:2715 BUG=angleproject:2716 Change-Id: I538b385f8b66fb97e176953b0fc4a6299849c005 Reviewed-on: https://chromium-review.googlesource.com/1118713 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent b01b4802
......@@ -16,7 +16,7 @@
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
"2a6afa5c7381b3cba46bf4e19146511c",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
"27c0b8debb6d5f610ad4f868d0b57aee",
"461eb24ff0b5c45f948568a46ba7416c",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_map.json":
"c60bd3863f0964ea6c3eee7d62d7fab2",
"DXGI format support:src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json":
......@@ -68,7 +68,7 @@
"Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"be1ca0bd596cf826d8f38d110fba35b0",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json":
"8b02327195f831c782b0a30b36b589d6",
"f7d883e82c2d9f284e15edff3a1a7dcb",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py":
"d651e28ab62477029093152e37ed49c9",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/src/FullScreenQuad.vert":
......
......@@ -548,11 +548,11 @@ void AddRGBAFormat(InternalFormatInfoMap *map,
formatInfo.pixelBytes = (red + green + blue + alpha + shared) / 8;
formatInfo.componentCount =
((red > 0) ? 1 : 0) + ((green > 0) ? 1 : 0) + ((blue > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
formatInfo.textureSupport = textureSupport;
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
formatInfo.textureSupport = textureSupport;
formatInfo.filterSupport = filterSupport;
formatInfo.textureAttachmentSupport = textureAttachmentSupport;
formatInfo.renderbufferSupport = renderbufferSupport;
......@@ -578,15 +578,15 @@ static void AddLUMAFormat(InternalFormatInfoMap *map,
formatInfo.sized = sized;
formatInfo.sizedInternalFormat =
sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
formatInfo.luminanceBits = luminance;
formatInfo.alphaBits = alpha;
formatInfo.pixelBytes = (luminance + alpha) / 8;
formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = GL_LINEAR;
formatInfo.textureSupport = textureSupport;
formatInfo.luminanceBits = luminance;
formatInfo.alphaBits = alpha;
formatInfo.pixelBytes = (luminance + alpha) / 8;
formatInfo.componentCount = ((luminance > 0) ? 1 : 0) + ((alpha > 0) ? 1 : 0);
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = GL_LINEAR;
formatInfo.textureSupport = textureSupport;
formatInfo.filterSupport = filterSupport;
formatInfo.textureAttachmentSupport = textureAttachmentSupport;
formatInfo.renderbufferSupport = renderbufferSupport;
......@@ -613,15 +613,15 @@ void AddDepthStencilFormat(InternalFormatInfoMap *map,
formatInfo.sized = sized;
formatInfo.sizedInternalFormat =
sized ? internalFormat : GetSizedFormatInternal(internalFormat, type);
formatInfo.depthBits = depthBits;
formatInfo.stencilBits = stencilBits;
formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = GL_LINEAR;
formatInfo.textureSupport = textureSupport;
formatInfo.depthBits = depthBits;
formatInfo.stencilBits = stencilBits;
formatInfo.pixelBytes = (depthBits + stencilBits + unusedBits) / 8;
formatInfo.componentCount = ((depthBits > 0) ? 1 : 0) + ((stencilBits > 0) ? 1 : 0);
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = componentType;
formatInfo.colorEncoding = GL_LINEAR;
formatInfo.textureSupport = textureSupport;
formatInfo.filterSupport = filterSupport;
formatInfo.textureAttachmentSupport = textureAttachmentSupport;
formatInfo.renderbufferSupport = renderbufferSupport;
......@@ -644,19 +644,19 @@ void AddCompressedFormat(InternalFormatInfoMap *map,
InternalFormat::SupportCheckFunction renderbufferSupport)
{
InternalFormat formatInfo;
formatInfo.internalFormat = internalFormat;
formatInfo.sized = true;
formatInfo.sizedInternalFormat = internalFormat;
formatInfo.compressedBlockWidth = compressedBlockWidth;
formatInfo.compressedBlockHeight = compressedBlockHeight;
formatInfo.pixelBytes = compressedBlockSize / 8;
formatInfo.componentCount = componentCount;
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
formatInfo.compressed = true;
formatInfo.textureSupport = textureSupport;
formatInfo.internalFormat = internalFormat;
formatInfo.sized = true;
formatInfo.sizedInternalFormat = internalFormat;
formatInfo.compressedBlockWidth = compressedBlockWidth;
formatInfo.compressedBlockHeight = compressedBlockHeight;
formatInfo.pixelBytes = compressedBlockSize / 8;
formatInfo.componentCount = componentCount;
formatInfo.format = format;
formatInfo.type = type;
formatInfo.componentType = GL_UNSIGNED_NORMALIZED;
formatInfo.colorEncoding = (srgb ? GL_SRGB : GL_LINEAR);
formatInfo.compressed = true;
formatInfo.textureSupport = textureSupport;
formatInfo.filterSupport = filterSupport;
formatInfo.textureAttachmentSupport = textureAttachmentSupport;
formatInfo.renderbufferSupport = renderbufferSupport;
......@@ -727,6 +727,7 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_BGRA8_SRGB_ANGLEX, true, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, NeverSupported, AlwaysSupported, AlwaysSupported, AlwaysSupported );
// Special format which is not really supported, so always false for all supports.
AddRGBAFormat(&map, GL_BGRX8_ANGLEX, true, 8, 8, 8, 0, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported );
AddRGBAFormat(&map, GL_BGR565_ANGLEX, true, 5, 6, 5, 1, 0, GL_BGRA_EXT, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported );
// Floating point renderability and filtering is provided by OES_texture_float and OES_texture_half_float
......
......@@ -104,6 +104,17 @@
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_BGRA8_SRGB_ANGLEX"
},
"B8G8R8X8_UNORM": {
"texFormat": "DXGI_FORMAT_B8G8R8X8_UNORM",
"srvFormat": "DXGI_FORMAT_B8G8R8X8_UNORM",
"rtvFormat": "DXGI_FORMAT_B8G8R8X8_UNORM",
"channels": "bgra",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"supportTest": "OnlyFL11_1Plus(deviceCaps)",
"fallbackFormat": "R8G8B8A8_UNORM",
"glInternalFormat": "GL_BGRX8_ANGLEX"
},
"BC1_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC1_UNORM",
"srvFormat": "DXGI_FORMAT_BC1_UNORM",
......
......@@ -179,6 +179,37 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
nullptr);
return info;
}
case GL_BGRX8_ANGLEX:
{
if (OnlyFL11_1Plus(deviceCaps))
{
static constexpr Format info(GL_BGRX8_ANGLEX,
angle::Format::ID::B8G8R8X8_UNORM,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B8G8R8X8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_B8G8R8X8_UNORM,
GL_BGRX8_ANGLEX,
nullptr);
return info;
}
else
{
static constexpr Format info(GL_BGRX8_ANGLEX,
angle::Format::ID::R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_R8G8B8A8_UNORM,
GL_RGBA8,
nullptr);
return info;
}
}
case GL_COMPRESSED_R11_EAC:
{
static constexpr Format info(GL_COMPRESSED_R11_EAC,
......
......@@ -18,6 +18,11 @@ namespace d3d11
using FormatSupportFunction = bool (*)(const Renderer11DeviceCaps &);
inline bool OnlyFL11_1Plus(const Renderer11DeviceCaps &deviceCaps)
{
return (deviceCaps.featureLevel >= D3D_FEATURE_LEVEL_11_1);
}
inline bool OnlyFL10Plus(const Renderer11DeviceCaps &deviceCaps)
{
return (deviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0);
......
......@@ -37,7 +37,7 @@ SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &st
egl::ConfigSet DisplayVkAndroid::generateConfigs()
{
constexpr GLenum kColorFormats[] = {GL_RGBA8};
constexpr GLenum kColorFormats[] = {GL_RGBA8, GL_RGB8};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
......
......@@ -224,6 +224,10 @@
},
"R8G8B8_UNORM": {
"texture": "R8G8B8A8_UNORM"
},
"B8G8R8X8_UNORM": {
"buffer": "NONE",
"texture": "B8G8R8A8_UNORM"
}
},
"fallbacks": {
......
......@@ -414,8 +414,15 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
break;
case angle::Format::ID::B8G8R8X8_UNORM:
// This format is not implemented in Vulkan.
{
internalFormat = GL_BGRX8_ANGLEX;
textureFormatID = angle::Format::ID::B8G8R8A8_UNORM;
vkTextureFormat = VK_FORMAT_B8G8R8A8_UNORM;
bufferFormatID = angle::Format::ID::NONE;
vkBufferFormat = VK_FORMAT_UNDEFINED;
dataInitializerFunction = nullptr;
break;
}
case angle::Format::ID::BC1_RGBA_UNORM_BLOCK:
{
......
......@@ -36,7 +36,7 @@ SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &stat
egl::ConfigSet DisplayVkWin32::generateConfigs()
{
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT, GL_BGRX8_ANGLEX};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
......
......@@ -64,7 +64,7 @@ SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state,
egl::ConfigSet DisplayVkXcb::generateConfigs()
{
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT, GL_BGRX8_ANGLEX};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
......
......@@ -149,8 +149,8 @@
1340 WIN : dEQP-EGL.functional.negative_api.swap_interval = FAIL
2382 WIN : dEQP-EGL.functional.native_color_mapping.native_window.* = SKIP
1340 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.* = FAIL
1340 WIN : dEQP-EGL.functional.preserve_swap.preserve.no_read_before_swap.* = SKIP
1340 WIN : dEQP-EGL.functional.preserve_swap.preserve.read_before_swap.* = SKIP
2716 WIN : dEQP-EGL.functional.preserve_swap.preserve.no_read_before_swap.* = SKIP
2716 WIN : dEQP-EGL.functional.preserve_swap.preserve.read_before_swap.* = SKIP
1340 WIN : dEQP-EGL.functional.resize.back_buffer.* = SKIP
1340 WIN : dEQP-EGL.functional.resize.pixel_density.* = SKIP
......@@ -169,11 +169,14 @@
2635 WIN VULKAN : dEQP-EGL.functional.multicontext.shared_make_current = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.query_surface.set_attribute.pbuffer.rgba8888_depth_stencil = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.query_surface.set_attribute.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgb888_depth_stencil = FAIL
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgb888_no_depth_no_stencil = FAIL
2715 WIN VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.grow = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_height = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_width = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.wide_color.pbuffer_8888_colorspace_default = FAIL
2716 WIN VULKAN : dEQP-EGL.functional.preserve_swap.no_preserve.* = FAIL
// Linux failures
2546 LINUX : dEQP-EGL.functional.color_clears.multi_context.gles1.rgba8888_pixmap = SKIP
......@@ -213,10 +216,13 @@
// Linux Vulkan failures
2635 LINUX VULKAN : dEQP-EGL.functional.query_surface.set_attribute.pbuffer.rgba8888_depth_stencil = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.query_surface.set_attribute.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2715 LINUX VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgb888_depth_stencil = FAIL
2715 LINUX VULKAN : dEQP-EGL.functional.query_surface.simple.pbuffer.rgb888_no_depth_no_stencil = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.resize.surface_size.grow = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.resize.surface_size.shrink = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_height = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.resize.surface_size.stretch_width = FAIL
2716 LINUX VULKAN : dEQP-EGL.functional.preserve_swap.no_preserve.* = FAIL
// Mac failures
2546 MAC : dEQP-EGL.functional.native_color_mapping.native_window.* = FAIL
......@@ -247,7 +253,7 @@
2546 ANDROID : dEQP-EGL.functional.partial_update.odd_clear_* = FAIL
2546 ANDROID : dEQP-EGL.functional.partial_update.odd_render_* = FAIL
2546 ANDROID : dEQP-EGL.functional.partial_update.render_* = FAIL
2546 ANDROID : dEQP-EGL.functional.preserve_swap.preserve.* = FAIL
2716 ANDROID : dEQP-EGL.functional.preserve_swap.preserve.* = FAIL
2546 ANDROID : dEQP-EGL.functional.query_context.get_current_context.* = FAIL
2546 ANDROID : dEQP-EGL.functional.query_context.get_current_display.* = FAIL
2546 ANDROID : dEQP-EGL.functional.query_context.get_current_surface.r* = FAIL
......
......@@ -77,8 +77,25 @@ class ClearTestBase : public ANGLETest
std::vector<GLuint> mTextures;
};
class ClearTest : public ClearTestBase {};
class ClearTestES3 : public ClearTestBase {};
class ClearTest : public ClearTestBase
{
};
class ClearTestES3 : public ClearTestBase
{
};
class ClearTestRGB : public ANGLETest
{
protected:
ClearTestRGB()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
}
};
// Test clearing the default framebuffer
TEST_P(ClearTest, DefaultFramebuffer)
......@@ -88,6 +105,14 @@ TEST_P(ClearTest, DefaultFramebuffer)
EXPECT_PIXEL_NEAR(0, 0, 64, 128, 128, 128, 1.0);
}
// Test clearing the RGB default framebuffer and verify that the alpha channel is not cleared
TEST_P(ClearTestRGB, DefaultFramebufferRGB)
{
glClearColor(0.25f, 0.5f, 0.5f, 0.5f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_PIXEL_NEAR(0, 0, 64, 128, 128, 255, 1.0);
}
// Test clearing a RGBA8 Framebuffer
TEST_P(ClearTest, RGBA8Framebuffer)
{
......@@ -233,7 +258,7 @@ TEST_P(ClearTest, ClearIssue)
// mistakenly clear every channel (including the masked-out ones)
TEST_P(ClearTestES3, MaskedClearBufferBug)
{
unsigned char pixelData[] = { 255, 255, 255, 255 };
unsigned char pixelData[] = {255, 255, 255, 255};
glBindFramebuffer(GL_FRAMEBUFFER, mFBOs[0]);
......@@ -250,8 +275,8 @@ TEST_P(ClearTestES3, MaskedClearBufferBug)
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(0, 0, 255, 255, 255, 255);
float clearValue[] = { 0, 0.5f, 0.5f, 1.0f };
GLenum drawBuffers[] = { GL_NONE, GL_COLOR_ATTACHMENT1 };
float clearValue[] = {0, 0.5f, 0.5f, 1.0f};
GLenum drawBuffers[] = {GL_NONE, GL_COLOR_ATTACHMENT1};
glDrawBuffers(2, drawBuffers);
glColorMask(GL_TRUE, GL_TRUE, GL_FALSE, GL_TRUE);
glClearBufferfv(GL_COLOR, 1, clearValue);
......@@ -276,10 +301,10 @@ TEST_P(ClearTestES3, BadFBOSerialBug)
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, getWindowWidth(), getWindowHeight());
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textures[0], 0);
GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0 };
GLenum drawBuffers[] = {GL_COLOR_ATTACHMENT0};
glDrawBuffers(1, drawBuffers);
float clearValues1[] = { 0.0f, 1.0f, 0.0f, 1.0f };
float clearValues1[] = {0.0f, 1.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, clearValues1);
ASSERT_GL_NO_ERROR();
......@@ -460,7 +485,7 @@ TEST_P(ClearTestES3, RepeatedClear)
const Vector4 color = RandomVec4(seed, fmtValueMin, fmtValueMax);
GLColor expectedColor = Vec4ToColor(color);
int testN = cellX * cellSize + cellY * backFBOSize * cellSize + backFBOSize + 1;
int testN = cellX * cellSize + cellY * backFBOSize * cellSize + backFBOSize + 1;
GLColor actualColor = pixelData[testN];
EXPECT_NEAR(expectedColor.R, actualColor.R, 1);
EXPECT_NEAR(expectedColor.G, actualColor.G, 1);
......@@ -603,8 +628,8 @@ TEST_P(ClearTest, MaskedColorAndDepthClear)
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
// Vulkan support disabled because of incomplete implementation.
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. Vulkan support disabled because of incomplete implementation.
ANGLE_INSTANTIATE_TEST(ClearTest,
ES2_D3D9(),
ES2_D3D11(),
......@@ -617,4 +642,7 @@ ANGLE_INSTANTIATE_TEST(ClearTest,
ANGLE_INSTANTIATE_TEST(ClearTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());
ANGLE_INSTANTIATE_TEST(ScissoredClearTest, ES2_D3D11(), ES2_OPENGL(), ES2_VULKAN());
// Not all ANGLE backends support RGB backbuffers
ANGLE_INSTANTIATE_TEST(ClearTestRGB, ES2_D3D11(), ES3_D3D11(), ES2_VULKAN());
} // anonymous namespace
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