Add ANGLE DirectComposition surface hint

Fix #2876
Add a new ANGLE-specific window hint that enables EGL_DIRECT_COMPOSITION_ANGLE during EGL window surface creation on Windows.

When used with ANGLE on Windows, this allows ANGLE to create DirectComposition-backed swap chains.

The EGL_ANGLE_direct_composition extension is checked during EGL initialization. If the extension is not supported by the platform, the hint is safely ignored.

Default behavior remains unchanged.
This commit is contained in:
fabiitch 2026-08-19 12:03:04 +02:00
parent 92dcf4ce74
commit e19059118d
4 changed files with 31 additions and 0 deletions

View file

@ -1307,6 +1307,19 @@ extern "C" {
*
* Platform selection [init hint](@ref GLFW_PLATFORM).
*/
#define GLFW_ANGLE_SURFACE_DIRECT_COMPOSITION 0x00050004
/*! @brief ANGLE DirectComposition surface hint.
*
* Specifies whether to use EGL_DIRECT_COMPOSITION_ANGLE for surface creation
* when using ANGLE on Windows.
*
* Possible values are `GLFW_TRUE` and `GLFW_FALSE`. This hint is ignored on
* other platforms or context APIs.
*
* @ingroup window
*/
#define GLFW_PLATFORM 0x00050003
/*! @brief macOS specific init hint.
*

View file

@ -562,6 +562,8 @@ GLFWbool _glfwInitEGL(void)
extensionSupportedEGL("EGL_KHR_context_flush_control");
_glfw.egl.EXT_present_opaque =
extensionSupportedEGL("EGL_EXT_present_opaque");
_glfw.egl.ANGLE_direct_composition =
_glfwStringInExtensionString("EGL_ANGLE_direct_composition", extensions);
return GLFW_TRUE;
}
@ -744,6 +746,13 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
SET_ATTRIB(EGL_HEIGHT, height);
}
// ANGLE surface creation attributes
if (ctxconfig->angleDirectComposition && _glfw.egl.ANGLE_direct_composition)
{
SET_ATTRIB(EGL_DIRECT_COMPOSITION_ANGLE, EGL_TRUE);
}
SET_ATTRIB(EGL_NONE, EGL_NONE);
native = _glfw.platform.getEGLNativeWindow(window);

View file

@ -188,6 +188,9 @@ typedef void (APIENTRY * PFNGLFLUSHPROC)(void);
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
#define EGL_PLATFORM_SURFACELESS_MESA 0x31dd
#define EGL_DIRECT_COMPOSITION_ANGLE 0x33A5
#define EGL_FALSE 0
#define EGL_TRUE 1
typedef int EGLint;
typedef unsigned int EGLBoolean;
@ -449,6 +452,7 @@ struct _GLFWctxconfig
int profile;
int robustness;
int release;
bool angleDirectComposition;
_GLFWwindow* share;
struct {
bool offline;
@ -812,6 +816,7 @@ struct _GLFWlibrary
bool KHR_gl_colorspace;
bool KHR_get_all_proc_addresses;
bool KHR_context_flush_control;
bool ANGLE_direct_composition;
bool EXT_client_extensions;
bool EXT_platform_base;
bool EXT_platform_x11;

View file

@ -262,6 +262,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
_glfw.hints.context.major = 1;
_glfw.hints.context.minor = 0;
_glfw.hints.context.angleDirectComposition = false;
// The default is a focused, visible, resizable window with decorations
memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
@ -397,6 +398,9 @@ GLFWAPI void glfwWindowHint(int hint, int value)
case GLFW_MOUSE_PASSTHROUGH:
_glfw.hints.window.mousePassthrough = value;
return;
case GLFW_ANGLE_SURFACE_DIRECT_COMPOSITION:
_glfw.hints.context.angleDirectComposition = value;
return;
case GLFW_CLIENT_API:
_glfw.hints.context.client = value;
return;