Compare commits

...

5 Commits

Author SHA1 Message Date
combolek
1cc3387933
Merge 8d1ceb0153 into e7ea71be03 2025-01-19 07:30:51 +00:00
combolek
8d1ceb0153 Update to latest master and resolve conflicts. 2024-04-20 21:58:34 -07:00
combolek
f4f4efe53f
Merge branch 'master' into angle-d3d11on12 2024-04-02 15:21:23 -07:00
combolek
1f5fe33e57 Update to latest master and resolve conflicts. 2024-03-18 21:59:16 -07:00
combolek
b9619f07a8 Added support for D3D11on12 on Windows 10+ via ANGLE.
ANGLE's EGL supports D3D11on12 via the ANGLE_platform_angle_d3d11on12 extension. Enabling it requires passing the EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE attribute to eglGetPlatformDisplayEXT. Specifying custom EGL attributes is not currently exposed in GLFW and based on https://github.com/glfw/glfw/issues/1718#issuecomment-653236025 this may not even be desirable.

Instead, this change adds a new value GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12 for the ANGLE platform type glfwInitHint. When specified it implicitly sets the required EGL attribute.

Note that D3D11on12 is supported only on executables specifically targetted for Windows 10, which requires a manifest.
2023-08-19 18:45:17 -07:00
9 changed files with 77 additions and 8 deletions

View File

@ -132,6 +132,7 @@ information on what to include when reporting a bug.
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`
- [EGL] Added `GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12` init hint for D3D11on12 support
- [EGL] Allowed native access on Wayland with `GLFW_CONTEXT_CREATION_API` set to
`GLFW_NATIVE_CONTEXT_API` (#2518)

View File

@ -109,8 +109,8 @@ request when using OpenGL ES and EGL via [ANGLE][]. If the requested platform
type is unavailable, ANGLE will use its default. Possible values are one of
`GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`,
`GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`,
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and
`GLFW_ANGLE_PLATFORM_TYPE_METAL`.
`GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12`,
`GLFW_ANGLE_PLATFORM_TYPE_VULKAN` and `GLFW_ANGLE_PLATFORM_TYPE_METAL`.
[ANGLE]: https://chromium.googlesource.com/angle/angle/
@ -159,7 +159,7 @@ Initialization hint | Default value | Supported v
-------------------------------- | ------------------------------- | ----------------
@ref GLFW_PLATFORM | `GLFW_ANY_PLATFORM` | `GLFW_ANY_PLATFORM`, `GLFW_PLATFORM_WIN32`, `GLFW_PLATFORM_COCOA`, `GLFW_PLATFORM_WAYLAND`, `GLFW_PLATFORM_X11` or `GLFW_PLATFORM_NULL`
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
@ref GLFW_ANGLE_PLATFORM_TYPE | `GLFW_ANGLE_PLATFORM_TYPE_NONE` | `GLFW_ANGLE_PLATFORM_TYPE_NONE`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGL`, `GLFW_ANGLE_PLATFORM_TYPE_OPENGLES`, `GLFW_ANGLE_PLATFORM_TYPE_D3D9`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11`, `GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12`, `GLFW_ANGLE_PLATFORM_TYPE_VULKAN` or `GLFW_ANGLE_PLATFORM_TYPE_METAL`
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
@ref GLFW_WAYLAND_LIBDECOR | `GLFW_WAYLAND_PREFER_LIBDECOR` | `GLFW_WAYLAND_PREFER_LIBDECOR` or `GLFW_WAYLAND_DISABLE_LIBDECOR`

View File

@ -14,6 +14,9 @@ values over 8. For compatibility with older versions, the
@ref GLFW_UNLIMITED_MOUSE_BUTTONS input mode needs to be set to make use of
this.
On Windows 10 or newer it is now possible to specify ANGLE's D3D11on12
backend via the @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12 init hint.
## Caveats {#caveats}
## Deprecations {#deprecations}
@ -29,6 +32,7 @@ this.
### New constants {#new_constants}
- @ref GLFW_UNLIMITED_MOUSE_BUTTONS
- @ref GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12
## Release notes for earlier versions {#news_archive}

View File

@ -1174,6 +1174,7 @@ extern "C" {
#define GLFW_ANGLE_PLATFORM_TYPE_OPENGLES 0x00037003
#define GLFW_ANGLE_PLATFORM_TYPE_D3D9 0x00037004
#define GLFW_ANGLE_PLATFORM_TYPE_D3D11 0x00037005
#define GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12 0x00037006
#define GLFW_ANGLE_PLATFORM_TYPE_VULKAN 0x00037007
#define GLFW_ANGLE_PLATFORM_TYPE_METAL 0x00037008

View File

@ -110,6 +110,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#define EGL_TRUE 1
#define EGL_SUCCESS 0x3000
#define EGL_NOT_INITIALIZED 0x3001
#define EGL_BAD_ACCESS 0x3002
@ -185,6 +186,7 @@ typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint);
#define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
#define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489
#define EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE 0x3488
#define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f
#define EGL_PLATFORM_SURFACELESS_MESA 0x31dd

View File

@ -2463,8 +2463,18 @@ const char* _glfwGetClipboardStringWin32(void)
return _glfw.win32.clipboardString;
}
#define SET_ATTRIB(a, v) \
{ \
assert(((size_t) index + 1) < sizeof(tmp_attribs) / sizeof(tmp_attribs[0])); \
tmp_attribs[index++] = a; \
tmp_attribs[index++] = v; \
}
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
{
EGLint tmp_attribs[8];
int index = 0;
if (_glfw.egl.ANGLE_platform_angle)
{
int type = 0;
@ -2483,6 +2493,11 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
type = EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE;
else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11)
type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
else if (_glfw.hints.init.angleType == GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12)
{
type = EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE;
SET_ATTRIB(EGL_PLATFORM_ANGLE_D3D11ON12_ANGLE, EGL_TRUE);
}
}
if (_glfw.egl.ANGLE_platform_angle_vulkan)
@ -2493,10 +2508,10 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
if (type)
{
*attribs = _glfw_calloc(3, sizeof(EGLint));
(*attribs)[0] = EGL_PLATFORM_ANGLE_TYPE_ANGLE;
(*attribs)[1] = type;
(*attribs)[2] = EGL_NONE;
SET_ATTRIB(EGL_PLATFORM_ANGLE_TYPE_ANGLE, type);
SET_ATTRIB(EGL_NONE, EGL_NONE);
*attribs = _glfw_calloc(index, sizeof(EGLint));
memcpy(*attribs, tmp_attribs, index * sizeof(EGLint));
return EGL_PLATFORM_ANGLE_ANGLE;
}
}
@ -2504,6 +2519,8 @@ EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
return 0;
}
#undef SET_ATTRIB
EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void)
{
return GetDC(_glfw.win32.helperWindowHandle);

View File

@ -23,7 +23,7 @@ add_executable(allocator allocator.c ${GLAD_GL})
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
add_executable(events events.c ${GETOPT} ${GLAD_GL})
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
add_executable(glfwinfo glfwinfo.c ${GETOPT} ${GLAD_GL} ${GLAD_VULKAN})
add_executable(glfwinfo glfwinfo.c glfwinfo.manifest ${GETOPT} ${GLAD_GL} ${GLAD_VULKAN})
add_executable(iconify iconify.c ${GETOPT} ${GLAD_GL})
add_executable(monitors monitors.c ${GETOPT} ${GLAD_GL})
add_executable(reopen reopen.c ${GLAD_GL})

View File

@ -61,6 +61,7 @@
#define ANGLE_TYPE_OPENGLES "es"
#define ANGLE_TYPE_D3D9 "d3d9"
#define ANGLE_TYPE_D3D11 "d3d11"
#define ANGLE_TYPE_D3D11ON12 "d3d11on12"
#define ANGLE_TYPE_VULKAN "vk"
#define ANGLE_TYPE_METAL "mtl"
@ -129,6 +130,7 @@ static void usage(void)
ANGLE_TYPE_OPENGLES ", "
ANGLE_TYPE_D3D9 ", "
ANGLE_TYPE_D3D11 ", "
ANGLE_TYPE_D3D11ON12 ", "
ANGLE_TYPE_VULKAN " or "
ANGLE_TYPE_METAL ")\n");
printf(" --graphics-switching request macOS graphics switching\n");
@ -638,6 +640,8 @@ int main(int argc, char** argv)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D9;
else if (strcmp(optarg, ANGLE_TYPE_D3D11) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D11;
else if (strcmp(optarg, ANGLE_TYPE_D3D11ON12) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_D3D11ON12;
else if (strcmp(optarg, ANGLE_TYPE_VULKAN) == 0)
angle_type = GLFW_ANGLE_PLATFORM_TYPE_VULKAN;
else if (strcmp(optarg, ANGLE_TYPE_METAL) == 0)

40
tests/glfwinfo.manifest Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name="glfw.glfw.glfwinfo"
version="3.4.0.0"
processorArchitecture="x86"
/>
<description>GLFW context creation and information tool</description>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!--
UAC settings:
- app should run at same integrity level as calling process
- app does not need to manipulate windows belonging to
higher-integrity-level processes
-->
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>