Commit c5a2a172 by Geoff Lang Committed by Commit Bot

Add EGL_EXT_pixel_format_float support, enables float EGL surfaces.

Add floating point EGL configs for the D3D11 backend. BUG=angleproject:1707 Change-Id: Ic84cd3a0d41e78cc39d0275d83e7695f55673ddf Reviewed-on: https://chromium-review.googlesource.com/428294 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 17a5c062
...@@ -810,6 +810,25 @@ GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer) ...@@ -810,6 +810,25 @@ GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer)
} }
} // namespace egl_gl } // namespace egl_gl
namespace gl_egl
{
EGLenum GLComponentTypeToEGLColorComponentType(GLenum glComponentType)
{
switch (glComponentType)
{
case GL_FLOAT:
return EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT;
case GL_UNSIGNED_NORMALIZED:
return EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
default:
UNREACHABLE();
return EGL_NONE;
}
}
} // namespace gl_egl
#if !defined(ANGLE_ENABLE_WINDOWS_STORE) #if !defined(ANGLE_ENABLE_WINDOWS_STORE)
std::string getTempPath() std::string getTempPath()
{ {
......
...@@ -160,6 +160,11 @@ GLenum EGLImageTargetToGLTextureTarget(EGLenum eglTarget); ...@@ -160,6 +160,11 @@ GLenum EGLImageTargetToGLTextureTarget(EGLenum eglTarget);
GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer); GLuint EGLClientBufferToGLObjectHandle(EGLClientBuffer buffer);
} }
namespace gl_egl
{
EGLenum GLComponentTypeToEGLColorComponentType(GLenum glComponentType);
} // namespace gl_egl
#if !defined(ANGLE_ENABLE_WINDOWS_STORE) #if !defined(ANGLE_ENABLE_WINDOWS_STORE)
std::string getTempPath(); std::string getTempPath();
void writeFile(const char* path, const void* data, size_t size); void writeFile(const char* path, const void* data, size_t size);
......
...@@ -1028,7 +1028,8 @@ DisplayExtensions::DisplayExtensions() ...@@ -1028,7 +1028,8 @@ DisplayExtensions::DisplayExtensions()
streamProducerD3DTextureNV12(false), streamProducerD3DTextureNV12(false),
createContextWebGLCompatibility(false), createContextWebGLCompatibility(false),
createContextBindGeneratesResource(false), createContextBindGeneratesResource(false),
swapBuffersWithDamage(false) swapBuffersWithDamage(false),
pixelFormatFloat(false)
{ {
} }
...@@ -1066,6 +1067,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const ...@@ -1066,6 +1067,7 @@ std::vector<std::string> DisplayExtensions::getStrings() const
InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility", createContextWebGLCompatibility, &extensionStrings); InsertExtensionString("EGL_ANGLE_create_context_webgl_compatibility", createContextWebGLCompatibility, &extensionStrings);
InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings); InsertExtensionString("EGL_CHROMIUM_create_context_bind_generates_resource", createContextBindGeneratesResource, &extensionStrings);
InsertExtensionString("EGL_EXT_swap_buffers_with_damage", swapBuffersWithDamage, &extensionStrings); InsertExtensionString("EGL_EXT_swap_buffers_with_damage", swapBuffersWithDamage, &extensionStrings);
InsertExtensionString("EGL_EXT_pixel_format_float", pixelFormatFloat, &extensionStrings);
// TODO(jmadill): Enable this when complete. // TODO(jmadill): Enable this when complete.
//InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings); //InsertExtensionString("KHR_create_context_no_error", createContextNoError, &extensionStrings);
// clang-format on // clang-format on
......
...@@ -637,6 +637,9 @@ struct DisplayExtensions ...@@ -637,6 +637,9 @@ struct DisplayExtensions
// EGL_EXT_swap_buffers_with_damage // EGL_EXT_swap_buffers_with_damage
bool swapBuffersWithDamage; bool swapBuffersWithDamage;
// EGL_EXT_pixel_format_float
bool pixelFormatFloat;
}; };
struct DeviceExtensions struct DeviceExtensions
......
...@@ -58,7 +58,8 @@ Config::Config() ...@@ -58,7 +58,8 @@ Config::Config()
transparentRedValue(0), transparentRedValue(0),
transparentGreenValue(0), transparentGreenValue(0),
transparentBlueValue(0), transparentBlueValue(0),
optimalOrientation(0) optimalOrientation(0),
colorComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT)
{ {
} }
...@@ -134,6 +135,10 @@ class ConfigSorter ...@@ -134,6 +135,10 @@ class ConfigSorter
static_assert(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG, "Unexpected EGL enum value."); static_assert(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG, "Unexpected EGL enum value.");
SORT(configCaveat); SORT(configCaveat);
static_assert(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT < EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT,
"Unexpected order of EGL enums.");
SORT(colorComponentType);
static_assert(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER, "Unexpected EGL enum value."); static_assert(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER, "Unexpected EGL enum value.");
SORT(colorBufferType); SORT(colorBufferType);
...@@ -255,6 +260,9 @@ std::vector<const Config*> ConfigSet::filter(const AttributeMap &attributeMap) c ...@@ -255,6 +260,9 @@ std::vector<const Config*> ConfigSet::filter(const AttributeMap &attributeMap) c
case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE: case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE:
match = config.optimalOrientation == attributeValue; match = config.optimalOrientation == attributeValue;
break; break;
case EGL_COLOR_COMPONENT_TYPE_EXT:
match = config.colorComponentType == static_cast<EGLenum>(attributeValue);
break;
default: UNREACHABLE(); default: UNREACHABLE();
} }
......
...@@ -65,6 +65,7 @@ struct Config ...@@ -65,6 +65,7 @@ struct Config
EGLint transparentGreenValue; // Transparent green value EGLint transparentGreenValue; // Transparent green value
EGLint transparentBlueValue; // Transparent blue value EGLint transparentBlueValue; // Transparent blue value
EGLint optimalOrientation; // Optimal window surface orientation EGLint optimalOrientation; // Optimal window surface orientation
EGLenum colorComponentType; // Color component type
}; };
class ConfigSet class ConfigSet
......
...@@ -931,6 +931,7 @@ void Display::initDisplayExtensions() ...@@ -931,6 +931,7 @@ void Display::initDisplayExtensions()
mDisplayExtensions.createContextNoError = true; mDisplayExtensions.createContextNoError = true;
mDisplayExtensions.createContextWebGLCompatibility = true; mDisplayExtensions.createContextWebGLCompatibility = true;
mDisplayExtensions.createContextBindGeneratesResource = true; mDisplayExtensions.createContextBindGeneratesResource = true;
mDisplayExtensions.pixelFormatFloat = true;
// Force EGL_KHR_get_all_proc_addresses on. // Force EGL_KHR_get_all_proc_addresses on.
mDisplayExtensions.getAllProcAddresses = true; mDisplayExtensions.getAllProcAddresses = true;
......
...@@ -985,6 +985,9 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value) ...@@ -985,6 +985,9 @@ void QueryConfigAttrib(const Config *config, EGLint attribute, EGLint *value)
case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE: case EGL_OPTIMAL_SURFACE_ORIENTATION_ANGLE:
*value = config->optimalOrientation; *value = config->optimalOrientation;
break; break;
case EGL_COLOR_COMPONENT_TYPE_EXT:
*value = config->colorComponentType;
break;
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;
......
...@@ -932,6 +932,12 @@ egl::ConfigSet Renderer11::generateConfigs() ...@@ -932,6 +932,12 @@ egl::ConfigSet Renderer11::generateConfigs()
// 24-bit supported formats // 24-bit supported formats
colorBufferFormats.push_back(GL_RGB8_OES); colorBufferFormats.push_back(GL_RGB8_OES);
if (mRenderer11DeviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0)
{
// floating point formats
colorBufferFormats.push_back(GL_RGBA16F);
}
if (!mPresentPathFastEnabled) if (!mPresentPathFastEnabled)
{ {
// 16-bit supported formats // 16-bit supported formats
...@@ -1040,6 +1046,8 @@ egl::ConfigSet Renderer11::generateConfigs() ...@@ -1040,6 +1046,8 @@ egl::ConfigSet Renderer11::generateConfigs()
config.transparentGreenValue = 0; config.transparentGreenValue = 0;
config.transparentBlueValue = 0; config.transparentBlueValue = 0;
config.optimalOrientation = optimalSurfaceOrientation; config.optimalOrientation = optimalSurfaceOrientation;
config.colorComponentType =
gl_egl::GLComponentTypeToEGLColorComponentType(colorBufferFormatInfo.componentType);
configs.add(config); configs.add(config);
} }
......
...@@ -480,7 +480,28 @@ DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const ...@@ -480,7 +480,28 @@ DXGI_FORMAT SwapChain11::getSwapChainNativeFormat() const
{ {
// Return a render target format for offscreen rendering is supported by IDXGISwapChain. // Return a render target format for offscreen rendering is supported by IDXGISwapChain.
// MSDN https://msdn.microsoft.com/en-us/library/windows/desktop/bb173064(v=vs.85).aspx // MSDN https://msdn.microsoft.com/en-us/library/windows/desktop/bb173064(v=vs.85).aspx
return (mOffscreenRenderTargetFormat == GL_BGRA8_EXT) ? DXGI_FORMAT_B8G8R8A8_UNORM : DXGI_FORMAT_R8G8B8A8_UNORM; switch (mOffscreenRenderTargetFormat)
{
case GL_RGBA8:
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGB8:
case GL_RGB565:
return DXGI_FORMAT_R8G8B8A8_UNORM;
case GL_BGRA8_EXT:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case GL_RGB10_A2:
return DXGI_FORMAT_R10G10B10A2_UNORM;
case GL_RGBA16F:
return DXGI_FORMAT_R16G16B16A16_FLOAT;
default:
UNREACHABLE();
return DXGI_FORMAT_UNKNOWN;
}
} }
EGLint SwapChain11::reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval) EGLint SwapChain11::reset(EGLint backbufferWidth, EGLint backbufferHeight, EGLint swapInterval)
......
...@@ -505,6 +505,8 @@ egl::ConfigSet Renderer9::generateConfigs() ...@@ -505,6 +505,8 @@ egl::ConfigSet Renderer9::generateConfigs()
config.transparentRedValue = 0; config.transparentRedValue = 0;
config.transparentGreenValue = 0; config.transparentGreenValue = 0;
config.transparentBlueValue = 0; config.transparentBlueValue = 0;
config.colorComponentType = gl_egl::GLComponentTypeToEGLColorComponentType(
colorBufferFormatInfo.componentType);
configs.add(config); configs.add(config);
} }
......
...@@ -208,6 +208,8 @@ egl::ConfigSet DisplayCGL::generateConfigs() ...@@ -208,6 +208,8 @@ egl::ConfigSet DisplayCGL::generateConfigs()
config.matchNativePixmap = EGL_NONE; config.matchNativePixmap = EGL_NONE;
config.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
configs.add(config); configs.add(config);
return configs; return configs;
} }
......
...@@ -74,8 +74,18 @@ egl::Error DisplayAndroid::initialize(egl::Display *display) ...@@ -74,8 +74,18 @@ egl::Error DisplayAndroid::initialize(egl::Display *display)
EGL_CONFIG_CAVEAT, EGL_NONE, EGL_CONFIG_CAVEAT, EGL_NONE,
EGL_CONFORMANT, esBit, EGL_CONFORMANT, esBit,
EGL_RENDERABLE_TYPE, esBit, EGL_RENDERABLE_TYPE, esBit,
EGL_NONE
}; };
if (mEGL->hasExtension("EGL_EXT_pixel_format_float"))
{
// Don't request floating point configs
mConfigAttribList.push_back(EGL_COLOR_COMPONENT_TYPE_EXT);
mConfigAttribList.push_back(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT);
}
// Complete the attrib list
mConfigAttribList.push_back(EGL_NONE);
// clang-format on // clang-format on
EGLint numConfig; EGLint numConfig;
...@@ -213,6 +223,23 @@ void DisplayAndroid::getConfigAttrib(EGLConfig config, EGLint attribute, T *valu ...@@ -213,6 +223,23 @@ void DisplayAndroid::getConfigAttrib(EGLConfig config, EGLint attribute, T *valu
*value = tmp; *value = tmp;
} }
template <typename T, typename U>
void DisplayAndroid::getConfigAttribIfExtension(EGLConfig config,
EGLint attribute,
T *value,
const char *extension,
const U &defaultValue) const
{
if (mEGL->hasExtension(extension))
{
getConfigAttrib(config, attribute, value);
}
else
{
*value = static_cast<T>(defaultValue);
}
}
egl::ConfigSet DisplayAndroid::generateConfigs() egl::ConfigSet DisplayAndroid::generateConfigs()
{ {
egl::ConfigSet configSet; egl::ConfigSet configSet;
...@@ -264,9 +291,13 @@ egl::ConfigSet DisplayAndroid::generateConfigs() ...@@ -264,9 +291,13 @@ egl::ConfigSet DisplayAndroid::generateConfigs()
getConfigAttrib(configs[i], EGL_TRANSPARENT_RED_VALUE, &config.transparentRedValue); getConfigAttrib(configs[i], EGL_TRANSPARENT_RED_VALUE, &config.transparentRedValue);
getConfigAttrib(configs[i], EGL_TRANSPARENT_GREEN_VALUE, &config.transparentGreenValue); getConfigAttrib(configs[i], EGL_TRANSPARENT_GREEN_VALUE, &config.transparentGreenValue);
getConfigAttrib(configs[i], EGL_TRANSPARENT_BLUE_VALUE, &config.transparentBlueValue); getConfigAttrib(configs[i], EGL_TRANSPARENT_BLUE_VALUE, &config.transparentBlueValue);
getConfigAttribIfExtension(configs[i], EGL_COLOR_COMPONENT_TYPE_EXT,
&config.colorComponentType, "EGL_EXT_pixel_format_float",
EGL_COLOR_COMPONENT_TYPE_FIXED_EXT);
if (config.colorBufferType == EGL_RGB_BUFFER) if (config.colorBufferType == EGL_RGB_BUFFER)
{ {
ASSERT(config.colorComponentType == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT);
if (config.redSize == 8 && config.greenSize == 8 && config.blueSize == 8 && if (config.redSize == 8 && config.greenSize == 8 && config.blueSize == 8 &&
config.alphaSize == 8) config.alphaSize == 8)
{ {
......
...@@ -64,6 +64,13 @@ class DisplayAndroid : public DisplayEGL ...@@ -64,6 +64,13 @@ class DisplayAndroid : public DisplayEGL
template <typename T> template <typename T>
void getConfigAttrib(EGLConfig config, EGLint attribute, T *value) const; void getConfigAttrib(EGLConfig config, EGLint attribute, T *value) const;
template <typename T, typename U>
void getConfigAttribIfExtension(EGLConfig config,
EGLint attribute,
T *value,
const char *extension,
const U &defaultValue) const;
std::vector<EGLint> mConfigAttribList; std::vector<EGLint> mConfigAttribList;
std::map<EGLint, EGLint> mConfigIds; std::map<EGLint, EGLint> mConfigIds;
EGLSurface mDummyPbuffer; EGLSurface mDummyPbuffer;
......
...@@ -716,6 +716,8 @@ egl::ConfigSet DisplayGLX::generateConfigs() ...@@ -716,6 +716,8 @@ egl::ConfigSet DisplayGLX::generateConfigs()
// TODO(cwallez) I have no idea what this is // TODO(cwallez) I have no idea what this is
config.matchNativePixmap = EGL_NONE; config.matchNativePixmap = EGL_NONE;
config.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
int id = configs.add(config); int id = configs.add(config);
configIdToGLXConfig[id] = glxConfig; configIdToGLXConfig[id] = glxConfig;
} }
......
...@@ -549,6 +549,7 @@ egl::ConfigSet DisplayWGL::generateConfigs() ...@@ -549,6 +549,7 @@ egl::ConfigSet DisplayWGL::generateConfigs()
((getAttrib(WGL_SWAP_METHOD_ARB) == WGL_SWAP_COPY_ARB) ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT ((getAttrib(WGL_SWAP_METHOD_ARB) == WGL_SWAP_COPY_ARB) ? EGL_SWAP_BEHAVIOR_PRESERVED_BIT
: 0); : 0);
config.optimalOrientation = optimalSurfaceOrientation; config.optimalOrientation = optimalSurfaceOrientation;
config.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
config.transparentType = EGL_NONE; config.transparentType = EGL_NONE;
config.transparentRedValue = 0; config.transparentRedValue = 0;
......
...@@ -84,6 +84,7 @@ egl::ConfigSet DisplayVk::generateConfigs() ...@@ -84,6 +84,7 @@ egl::ConfigSet DisplayVk::generateConfigs()
singleton.transparentRedValue = 0; singleton.transparentRedValue = 0;
singleton.transparentGreenValue = 0; singleton.transparentGreenValue = 0;
singleton.transparentBlueValue = 0; singleton.transparentBlueValue = 0;
singleton.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
egl::ConfigSet configSet; egl::ConfigSet configSet;
configSet.add(singleton); configSet.add(singleton);
......
...@@ -199,6 +199,13 @@ egl::Error ValidateConfigAttribute(const egl::Display *display, EGLAttrib attrib ...@@ -199,6 +199,13 @@ egl::Error ValidateConfigAttribute(const egl::Display *display, EGLAttrib attrib
} }
break; break;
case EGL_COLOR_COMPONENT_TYPE_EXT:
if (!display->getExtensions().pixelFormatFloat)
{
return egl::Error(EGL_BAD_ATTRIBUTE, "EGL_EXT_pixel_format_float is not enabled.");
}
break;
default: default:
return egl::Error(EGL_BAD_ATTRIBUTE, "Unknown attribute."); return egl::Error(EGL_BAD_ATTRIBUTE, "Unknown attribute.");
} }
...@@ -847,6 +854,12 @@ Error ValidateCompatibleConfigs(const Display *display, ...@@ -847,6 +854,12 @@ Error ValidateCompatibleConfigs(const Display *display,
return Error(EGL_BAD_MATCH, "Color buffer sizes are not compatible."); return Error(EGL_BAD_MATCH, "Color buffer sizes are not compatible.");
} }
bool componentTypeCompat = config1->colorComponentType == config2->colorComponentType;
if (!componentTypeCompat)
{
return Error(EGL_BAD_MATCH, "Color buffer component types are not compatible.");
}
bool dsCompat = config1->depthSize == config2->depthSize && bool dsCompat = config1->depthSize == config2->depthSize &&
config1->stencilSize == config2->stencilSize; config1->stencilSize == config2->stencilSize;
if (!dsCompat) if (!dsCompat)
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
'<(angle_path)/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/ETCTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/ETCTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp', '<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp',
'<(angle_path)/src/tests/gl_tests/FloatingPointSurfaceTest.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferTest.cpp',
......
...@@ -28,6 +28,34 @@ ...@@ -28,6 +28,34 @@
1340 WIN MAC LINUX : dEQP-EGL.functional.multithread.* = SKIP 1340 WIN MAC LINUX : dEQP-EGL.functional.multithread.* = SKIP
1340 WIN MAC LINUX : dEQP-EGL.functional.render.multi_thread.* = SKIP 1340 WIN MAC LINUX : dEQP-EGL.functional.render.multi_thread.* = SKIP
// dEQP doesn't handle configs created for extensions
1662 WIN : dEQP-EGL.functional.color_clears.single_context.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.color_clears.single_context.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.color_clears.multi_context.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.color_clears.multi_context.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.color_clears.multi_thread.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.color_clears.multi_thread.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.render.single_context.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.render.single_context.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_context.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_context.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_context.gles2_gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_thread.gles2.other = FAIL
1662 WIN : dEQP-EGL.functional.render.multi_thread.gles3.other = FAIL
1662 WIN : dEQP-EGL.functional.swap_buffers.other = FAIL
1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_clear = FAIL
1662 WIN : dEQP-EGL.functional.native_coord_mapping.native_window.other_render = FAIL
1662 WIN : dEQP-EGL.functional.query_context.get_current_context.other = FAIL
1662 WIN : dEQP-EGL.functional.query_context.get_current_surface.other = FAIL
1662 WIN : dEQP-EGL.functional.query_context.get_current_display.other = FAIL
1662 WIN : dEQP-EGL.functional.query_context.query_context.other = FAIL
1662 WIN : dEQP-EGL.functional.query_surface.simple.window.other = FAIL
1662 WIN : dEQP-EGL.functional.query_surface.simple.pbuffer.other = FAIL
1662 WIN : dEQP-EGL.functional.query_surface.set_attribute.window.other = FAIL
1662 WIN : dEQP-EGL.functional.query_surface.set_attribute.pbuffer.other = FAIL
1662 WIN : dEQP-EGL.functional.native_color_mapping.native_window.other_clear = FAIL
1662 WIN : dEQP-EGL.functional.native_color_mapping.native_window.other_render = FAIL
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// //
// Temprory entries: they should be removed once the bugs are fixed. // Temprory entries: they should be removed once the bugs are fixed.
......
...@@ -99,10 +99,19 @@ class EGLContextCompatibilityTest : public ANGLETest ...@@ -99,10 +99,19 @@ class EGLContextCompatibilityTest : public ANGLETest
eglGetConfigAttrib(mDisplay, c1, EGL_SURFACE_TYPE, &surfaceType1); eglGetConfigAttrib(mDisplay, c1, EGL_SURFACE_TYPE, &surfaceType1);
eglGetConfigAttrib(mDisplay, c2, EGL_SURFACE_TYPE, &surfaceType2); eglGetConfigAttrib(mDisplay, c2, EGL_SURFACE_TYPE, &surfaceType2);
return colorBufferType1 == colorBufferType2 && EGLint colorComponentType1 = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
red1 == red2 && green1 == green2 && blue1 == blue2 && alpha1 == alpha2 && EGLint colorComponentType2 = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
depth1 == depth2 && stencil1 == stencil2 && if (eglDisplayExtensionEnabled(mDisplay, "EGL_EXT_pixel_format_float"))
(surfaceType1 & surfaceBit) != 0 && {
eglGetConfigAttrib(mDisplay, c1, EGL_COLOR_COMPONENT_TYPE_EXT, &colorComponentType1);
eglGetConfigAttrib(mDisplay, c2, EGL_COLOR_COMPONENT_TYPE_EXT, &colorComponentType2);
}
EXPECT_EGL_SUCCESS();
return colorBufferType1 == colorBufferType2 && red1 == red2 && green1 == green2 &&
blue1 == blue2 && alpha1 == alpha2 && colorComponentType1 == colorComponentType2 &&
depth1 == depth2 && stencil1 == stencil2 && (surfaceType1 & surfaceBit) != 0 &&
(surfaceType2 & surfaceBit) != 0; (surfaceType2 & surfaceBit) != 0;
} }
...@@ -121,7 +130,7 @@ class EGLContextCompatibilityTest : public ANGLETest ...@@ -121,7 +130,7 @@ class EGLContextCompatibilityTest : public ANGLETest
if (compatible) if (compatible)
{ {
testClearSurface(window, context); testClearSurface(window, windowConfig, context);
} }
else else
{ {
...@@ -153,7 +162,7 @@ class EGLContextCompatibilityTest : public ANGLETest ...@@ -153,7 +162,7 @@ class EGLContextCompatibilityTest : public ANGLETest
if (compatible) if (compatible)
{ {
testClearSurface(pbuffer, context); testClearSurface(pbuffer, pbufferConfig, context);
} }
else else
{ {
...@@ -171,7 +180,7 @@ class EGLContextCompatibilityTest : public ANGLETest ...@@ -171,7 +180,7 @@ class EGLContextCompatibilityTest : public ANGLETest
EGLDisplay mDisplay; EGLDisplay mDisplay;
private: private:
void testClearSurface(EGLSurface surface, EGLContext context) const void testClearSurface(EGLSurface surface, EGLConfig surfaceConfig, EGLContext context) const
{ {
eglMakeCurrent(mDisplay, surface, surface, context); eglMakeCurrent(mDisplay, surface, surface, context);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
...@@ -180,7 +189,22 @@ class EGLContextCompatibilityTest : public ANGLETest ...@@ -180,7 +189,22 @@ class EGLContextCompatibilityTest : public ANGLETest
glClearColor(0.0f, 0.0f, 1.0f, 1.0f); glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_EQ(250, 250, 0, 0, 255, 255);
EGLint surfaceCompontentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
if (eglDisplayExtensionEnabled(mDisplay, "EGL_EXT_pixel_format_float"))
{
eglGetConfigAttrib(mDisplay, surfaceConfig, EGL_COLOR_COMPONENT_TYPE_EXT,
&surfaceCompontentType);
}
if (surfaceCompontentType == EGL_COLOR_COMPONENT_TYPE_FIXED_EXT)
{
EXPECT_PIXEL_EQ(250, 250, 0, 0, 255, 255);
}
else
{
EXPECT_PIXEL_32F_EQ(250, 250, 0, 0, 1.0f, 1.0f);
}
eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
......
//
// Copyright 2017 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FloatingPointSurfaceTest.cpp : Test functionality of the EGL_EXT_pixel_format_float extension.
#include "test_utils/ANGLETest.h"
using namespace angle;
class FloatingPointSurfaceTest : public ANGLETest
{
protected:
FloatingPointSurfaceTest()
{
setWindowWidth(512);
setWindowHeight(512);
setConfigRedBits(16);
setConfigGreenBits(16);
setConfigBlueBits(16);
setConfigAlphaBits(16);
setConfigComponentType(EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT);
}
void SetUp() override
{
ANGLETest::SetUp();
const std::string vsSource =
"precision highp float;\n"
"attribute vec4 position;\n"
"void main()\n"
"{\n"
" gl_Position = position;\n"
"}\n";
const std::string fsSource =
"precision highp float;\n"
"void main()\n"
"{\n"
" gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);\n"
"}\n";
mProgram = CompileProgram(vsSource, fsSource);
ASSERT_NE(0u, mProgram) << "shader compilation failed.";
ASSERT_GL_NO_ERROR();
}
void TearDown() override
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
GLuint mProgram;
};
// Test clearing and checking the color is correct
TEST_P(FloatingPointSurfaceTest, Clearing)
{
GLColor32F clearColor(0.0f, 1.0f, 2.0f, 3.0f);
glClearColor(clearColor.R, clearColor.G, clearColor.B, clearColor.A);
glClear(GL_COLOR_BUFFER_BIT);
ASSERT_GL_NO_ERROR();
EXPECT_PIXEL_COLOR32F_EQ(0, 0, clearColor);
}
// Test drawing and checking the color is correct
TEST_P(FloatingPointSurfaceTest, Drawing)
{
glUseProgram(mProgram);
drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_32F_EQ(0, 0, 1.0f, 2.0f, 3.0f, 4.0f);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(FloatingPointSurfaceTest,
ES2_D3D11(),
ES3_D3D11(),
ES2_D3D11(EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE));
...@@ -160,6 +160,14 @@ angle::Vector4 GLColor::toNormalizedVector() const ...@@ -160,6 +160,14 @@ angle::Vector4 GLColor::toNormalizedVector() const
return angle::Vector4(ColorNorm(R), ColorNorm(G), ColorNorm(B), ColorNorm(A)); return angle::Vector4(ColorNorm(R), ColorNorm(G), ColorNorm(B), ColorNorm(A));
} }
GLColor32F::GLColor32F() : GLColor32F(0.0f, 0.0f, 0.0f, 0.0f)
{
}
GLColor32F::GLColor32F(GLfloat r, GLfloat g, GLfloat b, GLfloat a) : R(r), G(g), B(b), A(a)
{
}
GLColor ReadColor(GLint x, GLint y) GLColor ReadColor(GLint x, GLint y)
{ {
GLColor actual; GLColor actual;
...@@ -181,6 +189,25 @@ std::ostream &operator<<(std::ostream &ostream, const GLColor &color) ...@@ -181,6 +189,25 @@ std::ostream &operator<<(std::ostream &ostream, const GLColor &color)
return ostream; return ostream;
} }
bool operator==(const GLColor32F &a, const GLColor32F &b)
{
return a.R == b.R && a.G == b.G && a.B == b.B && a.A == b.A;
}
std::ostream &operator<<(std::ostream &ostream, const GLColor32F &color)
{
ostream << "(" << color.R << ", " << color.G << ", " << color.B << ", " << color.A << ")";
return ostream;
}
GLColor32F ReadColor32F(GLint x, GLint y)
{
GLColor32F actual;
glReadPixels((x), (y), 1, 1, GL_RGBA, GL_FLOAT, &actual.R);
EXPECT_GL_NO_ERROR();
return actual;
}
} // namespace angle } // namespace angle
// static // static
...@@ -637,6 +664,11 @@ void ANGLETest::setConfigStencilBits(int bits) ...@@ -637,6 +664,11 @@ void ANGLETest::setConfigStencilBits(int bits)
mEGLWindow->setConfigStencilBits(bits); mEGLWindow->setConfigStencilBits(bits);
} }
void ANGLETest::setConfigComponentType(EGLenum componentType)
{
mEGLWindow->setConfigComponentType(componentType);
}
void ANGLETest::setMultisampleEnabled(bool enabled) void ANGLETest::setMultisampleEnabled(bool enabled)
{ {
mEGLWindow->setMultisample(enabled); mEGLWindow->setMultisample(enabled);
......
...@@ -84,6 +84,14 @@ struct GLColor ...@@ -84,6 +84,14 @@ struct GLColor
static const GLColor yellow; static const GLColor yellow;
}; };
struct GLColor32F
{
GLColor32F();
GLColor32F(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
GLfloat R, G, B, A;
};
struct WorkaroundsD3D; struct WorkaroundsD3D;
// Useful to cast any type to GLubyte. // Useful to cast any type to GLubyte.
...@@ -98,15 +106,34 @@ bool operator==(const GLColor &a, const GLColor &b); ...@@ -98,15 +106,34 @@ bool operator==(const GLColor &a, const GLColor &b);
std::ostream &operator<<(std::ostream &ostream, const GLColor &color); std::ostream &operator<<(std::ostream &ostream, const GLColor &color);
GLColor ReadColor(GLint x, GLint y); GLColor ReadColor(GLint x, GLint y);
// Useful to cast any type to GLfloat.
template <typename TR, typename TG, typename TB, typename TA>
GLColor32F MakeGLColor32F(TR r, TG g, TB b, TA a)
{
return GLColor32F(static_cast<GLfloat>(r), static_cast<GLfloat>(g), static_cast<GLfloat>(b),
static_cast<GLfloat>(a));
}
bool operator==(const GLColor32F &a, const GLColor32F &b);
std::ostream &operator<<(std::ostream &ostream, const GLColor32F &color);
GLColor32F ReadColor32F(GLint x, GLint y);
} // namespace angle } // namespace angle
#define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \ #define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \
EXPECT_EQ(angle::MakeGLColor(r, g, b, a), angle::ReadColor(x, y)) EXPECT_EQ(angle::MakeGLColor(r, g, b, a), angle::ReadColor(x, y))
#define EXPECT_PIXEL_32F_EQ(x, y, r, g, b, a) \
EXPECT_EQ(angle::MakeGLColor32F(r, g, b, a), angle::ReadColor32F(x, y))
#define EXPECT_PIXEL_ALPHA_EQ(x, y, a) EXPECT_EQ(a, angle::ReadColor(x, y).A) #define EXPECT_PIXEL_ALPHA_EQ(x, y, a) EXPECT_EQ(a, angle::ReadColor(x, y).A)
#define EXPECT_PIXEL_ALPHA32F_EQ(x, y, a) EXPECT_EQ(a, angle::ReadColor32F(x, y).A)
#define EXPECT_PIXEL_COLOR_EQ(x, y, angleColor) EXPECT_EQ(angleColor, angle::ReadColor(x, y)) #define EXPECT_PIXEL_COLOR_EQ(x, y, angleColor) EXPECT_EQ(angleColor, angle::ReadColor(x, y))
#define EXPECT_PIXEL_COLOR32F_EQ(x, y, angleColor) EXPECT_EQ(angleColor, angle::ReadColor32F(x, y))
#define EXPECT_PIXEL_NEAR(x, y, r, g, b, a, abs_error) \ #define EXPECT_PIXEL_NEAR(x, y, r, g, b, a, abs_error) \
{ \ { \
GLubyte pixel[4]; \ GLubyte pixel[4]; \
...@@ -191,6 +218,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -191,6 +218,7 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
void setConfigAlphaBits(int bits); void setConfigAlphaBits(int bits);
void setConfigDepthBits(int bits); void setConfigDepthBits(int bits);
void setConfigStencilBits(int bits); void setConfigStencilBits(int bits);
void setConfigComponentType(EGLenum componentType);
void setMultisampleEnabled(bool enabled); void setMultisampleEnabled(bool enabled);
void setDebugEnabled(bool enabled); void setDebugEnabled(bool enabled);
void setNoErrorEnabled(bool enabled); void setNoErrorEnabled(bool enabled);
......
...@@ -107,6 +107,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion, ...@@ -107,6 +107,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion,
mAlphaBits(-1), mAlphaBits(-1),
mDepthBits(-1), mDepthBits(-1),
mStencilBits(-1), mStencilBits(-1),
mComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT),
mMultisample(false), mMultisample(false),
mDebug(false), mDebug(false),
mNoError(false), mNoError(false),
...@@ -240,20 +241,35 @@ bool EGLWindow::initializeGL(OSWindow *osWindow) ...@@ -240,20 +241,35 @@ bool EGLWindow::initializeGL(OSWindow *osWindow)
return false; return false;
} }
const EGLint configAttributes[] = std::vector<EGLint> configAttributes = {
{ EGL_RED_SIZE, (mRedBits >= 0) ? mRedBits : EGL_DONT_CARE,
EGL_RED_SIZE, (mRedBits >= 0) ? mRedBits : EGL_DONT_CARE, EGL_GREEN_SIZE, (mGreenBits >= 0) ? mGreenBits : EGL_DONT_CARE,
EGL_GREEN_SIZE, (mGreenBits >= 0) ? mGreenBits : EGL_DONT_CARE, EGL_BLUE_SIZE, (mBlueBits >= 0) ? mBlueBits : EGL_DONT_CARE,
EGL_BLUE_SIZE, (mBlueBits >= 0) ? mBlueBits : EGL_DONT_CARE, EGL_ALPHA_SIZE, (mAlphaBits >= 0) ? mAlphaBits : EGL_DONT_CARE,
EGL_ALPHA_SIZE, (mAlphaBits >= 0) ? mAlphaBits : EGL_DONT_CARE, EGL_DEPTH_SIZE, (mDepthBits >= 0) ? mDepthBits : EGL_DONT_CARE,
EGL_DEPTH_SIZE, (mDepthBits >= 0) ? mDepthBits : EGL_DONT_CARE,
EGL_STENCIL_SIZE, (mStencilBits >= 0) ? mStencilBits : EGL_DONT_CARE, EGL_STENCIL_SIZE, (mStencilBits >= 0) ? mStencilBits : EGL_DONT_CARE,
EGL_SAMPLE_BUFFERS, mMultisample ? 1 : 0, EGL_SAMPLE_BUFFERS, mMultisample ? 1 : 0,
EGL_NONE
}; };
// Add dynamic attributes
bool hasPixelFormatFloat = strstr(displayExtensions, "EGL_EXT_pixel_format_float") != nullptr;
if (!hasPixelFormatFloat && mComponentType != EGL_COLOR_COMPONENT_TYPE_FIXED_EXT)
{
destroyGL();
return false;
}
if (hasPixelFormatFloat)
{
configAttributes.push_back(EGL_COLOR_COMPONENT_TYPE_EXT);
configAttributes.push_back(mComponentType);
}
// Finish the attribute list
configAttributes.push_back(EGL_NONE);
EGLint configCount; EGLint configCount;
if (!eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount) || (configCount != 1)) if (!eglChooseConfig(mDisplay, configAttributes.data(), &mConfig, 1, &configCount) ||
(configCount != 1))
{ {
destroyGL(); destroyGL();
return false; return false;
......
...@@ -66,6 +66,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -66,6 +66,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
void setConfigAlphaBits(int bits) { mAlphaBits = bits; } void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
void setConfigDepthBits(int bits) { mDepthBits = bits; } void setConfigDepthBits(int bits) { mDepthBits = bits; }
void setConfigStencilBits(int bits) { mStencilBits = bits; } void setConfigStencilBits(int bits) { mStencilBits = bits; }
void setConfigComponentType(EGLenum componentType) { mComponentType = componentType; }
void setMultisample(bool multisample) { mMultisample = multisample; } void setMultisample(bool multisample) { mMultisample = multisample; }
void setDebugEnabled(bool debug) { mDebug = debug; } void setDebugEnabled(bool debug) { mDebug = debug; }
void setNoErrorEnabled(bool noError) { mNoError = noError; } void setNoErrorEnabled(bool noError) { mNoError = noError; }
...@@ -120,6 +121,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -120,6 +121,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
int mAlphaBits; int mAlphaBits;
int mDepthBits; int mDepthBits;
int mStencilBits; int mStencilBits;
EGLenum mComponentType;
bool mMultisample; bool mMultisample;
bool mDebug; bool mDebug;
bool mNoError; bool mNoError;
......
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