From 875539d7b5279e86587ef4955e0cadf66b631f2e Mon Sep 17 00:00:00 2001 From: Ioannis Tsakpinis Date: Wed, 25 Sep 2024 19:14:18 +0300 Subject: [PATCH] feat(EGL) add EXT_display_alloc --- .../java/org/lwjgl/egl/EGLCapabilities.java | 183 ++++++++++-------- .../java/org/lwjgl/egl/EXTDisplayAlloc.java | 63 ++++++ .../kotlin/egl/templates/EXT_display_alloc.kt | 56 ++++++ 3 files changed, 217 insertions(+), 85 deletions(-) create mode 100644 modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EXTDisplayAlloc.java create mode 100644 modules/lwjgl/egl/src/templates/kotlin/egl/templates/EXT_display_alloc.kt diff --git a/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EGLCapabilities.java b/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EGLCapabilities.java index 9d93647a58..fd4632ff31 100644 --- a/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EGLCapabilities.java +++ b/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EGLCapabilities.java @@ -78,6 +78,7 @@ public class EGLCapabilities { eglQueryDeviceAttribEXT, eglQueryDeviceStringEXT, eglQueryDisplayAttribEXT, + eglDestroyDisplayEXT, eglQueryDmaBufFormatsEXT, eglQueryDmaBufModifiersEXT, eglGetOutputLayersEXT, @@ -263,6 +264,8 @@ public class EGLCapabilities { public final boolean EGL_EXT_device_query; /** When true, {@link EXTDeviceQueryName} is supported. */ public final boolean EGL_EXT_device_query_name; + /** When true, {@link EXTDisplayAlloc} is supported. */ + public final boolean EGL_EXT_display_alloc; /** * When true, the EXT_explicit_device extension is supported. * @@ -661,6 +664,7 @@ public class EGLCapabilities { provider.getFunctionAddress("eglQueryDeviceAttribEXT"), provider.getFunctionAddress("eglQueryDeviceStringEXT"), provider.getFunctionAddress("eglQueryDisplayAttribEXT"), + provider.getFunctionAddress("eglDestroyDisplayEXT"), provider.getFunctionAddress("eglQueryDmaBufFormatsEXT"), provider.getFunctionAddress("eglQueryDmaBufModifiersEXT"), provider.getFunctionAddress("eglGetOutputLayersEXT"), @@ -814,6 +818,7 @@ public class EGLCapabilities { caps.eglQueryDeviceAttribEXT, caps.eglQueryDeviceStringEXT, caps.eglQueryDisplayAttribEXT, + caps.eglDestroyDisplayEXT, caps.eglQueryDmaBufFormatsEXT, caps.eglQueryDmaBufModifiersEXT, caps.eglGetOutputLayersEXT, @@ -966,91 +971,92 @@ private EGLCapabilities(Set ext, long... functions) { eglQueryDeviceAttribEXT = functions[60]; eglQueryDeviceStringEXT = functions[61]; eglQueryDisplayAttribEXT = functions[62]; - eglQueryDmaBufFormatsEXT = functions[63]; - eglQueryDmaBufModifiersEXT = functions[64]; - eglGetOutputLayersEXT = functions[65]; - eglGetOutputPortsEXT = functions[66]; - eglOutputLayerAttribEXT = functions[67]; - eglQueryOutputLayerAttribEXT = functions[68]; - eglQueryOutputLayerStringEXT = functions[69]; - eglOutputPortAttribEXT = functions[70]; - eglQueryOutputPortAttribEXT = functions[71]; - eglQueryOutputPortStringEXT = functions[72]; - eglGetPlatformDisplayEXT = functions[73]; - eglCreatePlatformWindowSurfaceEXT = functions[74]; - eglCreatePlatformPixmapSurfaceEXT = functions[75]; - eglStreamConsumerOutputEXT = functions[76]; - eglQuerySupportedCompressionRatesEXT = functions[77]; - eglSwapBuffersWithDamageEXT = functions[78]; - eglUnsignalSyncEXT = functions[79]; - eglCreatePixmapSurfaceHI = functions[80]; - eglCreateSync64KHR = functions[81]; - eglDebugMessageControlKHR = functions[82]; - eglQueryDebugKHR = functions[83]; - eglLabelObjectKHR = functions[84]; - eglQueryDisplayAttribKHR = functions[85]; - eglCreateImageKHR = functions[86]; - eglDestroyImageKHR = functions[87]; - eglLockSurfaceKHR = functions[88]; - eglUnlockSurfaceKHR = functions[89]; - eglQuerySurface64KHR = functions[90]; - eglSetDamageRegionKHR = functions[91]; - eglCreateSyncKHR = functions[92]; - eglDestroySyncKHR = functions[93]; - eglClientWaitSyncKHR = functions[94]; - eglSignalSyncKHR = functions[95]; - eglGetSyncAttribKHR = functions[96]; - eglCreateStreamKHR = functions[97]; - eglDestroyStreamKHR = functions[98]; - eglStreamAttribKHR = functions[99]; - eglQueryStreamKHR = functions[100]; - eglQueryStreamu64KHR = functions[101]; - eglCreateStreamAttribKHR = functions[102]; - eglSetStreamAttribKHR = functions[103]; - eglQueryStreamAttribKHR = functions[104]; - eglStreamConsumerAcquireAttribKHR = functions[105]; - eglStreamConsumerReleaseAttribKHR = functions[106]; - eglStreamConsumerGLTextureExternalKHR = functions[107]; - eglStreamConsumerAcquireKHR = functions[108]; - eglStreamConsumerReleaseKHR = functions[109]; - eglGetStreamFileDescriptorKHR = functions[110]; - eglCreateStreamFromFileDescriptorKHR = functions[111]; - eglQueryStreamTimeKHR = functions[112]; - eglCreateStreamProducerSurfaceKHR = functions[113]; - eglSwapBuffersWithDamageKHR = functions[114]; - eglWaitSyncKHR = functions[115]; - eglCreateDRMImageMESA = functions[116]; - eglExportDRMImageMESA = functions[117]; - eglExportDMABUFImageQueryMESA = functions[118]; - eglExportDMABUFImageMESA = functions[119]; - eglSwapBuffersRegion2NOK = functions[120]; - eglQueryNativeDisplayNV = functions[121]; - eglQueryNativeWindowNV = functions[122]; - eglQueryNativePixmapNV = functions[123]; - eglPostSubBufferNV = functions[124]; - eglStreamImageConsumerConnectNV = functions[125]; - eglQueryStreamConsumerEventNV = functions[126]; - eglStreamAcquireImageNV = functions[127]; - eglStreamReleaseImageNV = functions[128]; - eglStreamConsumerGLTextureExternalAttribsNV = functions[129]; - eglStreamFlush = functions[130]; - eglQueryDisplayAttribNV = functions[131]; - eglSetStreamMetadataNV = functions[132]; - eglQueryStreamMetadataNV = functions[133]; - eglResetStreamNV = functions[134]; - eglCreateStreamSyncNV = functions[135]; - eglCreateFenceSyncNV = functions[136]; - eglDestroySyncNV = functions[137]; - eglFenceNV = functions[138]; - eglClientWaitSyncNV = functions[139]; - eglSignalSyncNV = functions[140]; - eglGetSyncAttribNV = functions[141]; - eglGetSystemTimeFrequencyNV = functions[142]; - eglGetSystemTimeNV = functions[143]; - eglBindWaylandDisplayWL = functions[144]; - eglUnbindWaylandDisplayWL = functions[145]; - eglQueryWaylandBufferWL = functions[146]; - eglCreateWaylandBufferFromImageWL = functions[147]; + eglDestroyDisplayEXT = functions[63]; + eglQueryDmaBufFormatsEXT = functions[64]; + eglQueryDmaBufModifiersEXT = functions[65]; + eglGetOutputLayersEXT = functions[66]; + eglGetOutputPortsEXT = functions[67]; + eglOutputLayerAttribEXT = functions[68]; + eglQueryOutputLayerAttribEXT = functions[69]; + eglQueryOutputLayerStringEXT = functions[70]; + eglOutputPortAttribEXT = functions[71]; + eglQueryOutputPortAttribEXT = functions[72]; + eglQueryOutputPortStringEXT = functions[73]; + eglGetPlatformDisplayEXT = functions[74]; + eglCreatePlatformWindowSurfaceEXT = functions[75]; + eglCreatePlatformPixmapSurfaceEXT = functions[76]; + eglStreamConsumerOutputEXT = functions[77]; + eglQuerySupportedCompressionRatesEXT = functions[78]; + eglSwapBuffersWithDamageEXT = functions[79]; + eglUnsignalSyncEXT = functions[80]; + eglCreatePixmapSurfaceHI = functions[81]; + eglCreateSync64KHR = functions[82]; + eglDebugMessageControlKHR = functions[83]; + eglQueryDebugKHR = functions[84]; + eglLabelObjectKHR = functions[85]; + eglQueryDisplayAttribKHR = functions[86]; + eglCreateImageKHR = functions[87]; + eglDestroyImageKHR = functions[88]; + eglLockSurfaceKHR = functions[89]; + eglUnlockSurfaceKHR = functions[90]; + eglQuerySurface64KHR = functions[91]; + eglSetDamageRegionKHR = functions[92]; + eglCreateSyncKHR = functions[93]; + eglDestroySyncKHR = functions[94]; + eglClientWaitSyncKHR = functions[95]; + eglSignalSyncKHR = functions[96]; + eglGetSyncAttribKHR = functions[97]; + eglCreateStreamKHR = functions[98]; + eglDestroyStreamKHR = functions[99]; + eglStreamAttribKHR = functions[100]; + eglQueryStreamKHR = functions[101]; + eglQueryStreamu64KHR = functions[102]; + eglCreateStreamAttribKHR = functions[103]; + eglSetStreamAttribKHR = functions[104]; + eglQueryStreamAttribKHR = functions[105]; + eglStreamConsumerAcquireAttribKHR = functions[106]; + eglStreamConsumerReleaseAttribKHR = functions[107]; + eglStreamConsumerGLTextureExternalKHR = functions[108]; + eglStreamConsumerAcquireKHR = functions[109]; + eglStreamConsumerReleaseKHR = functions[110]; + eglGetStreamFileDescriptorKHR = functions[111]; + eglCreateStreamFromFileDescriptorKHR = functions[112]; + eglQueryStreamTimeKHR = functions[113]; + eglCreateStreamProducerSurfaceKHR = functions[114]; + eglSwapBuffersWithDamageKHR = functions[115]; + eglWaitSyncKHR = functions[116]; + eglCreateDRMImageMESA = functions[117]; + eglExportDRMImageMESA = functions[118]; + eglExportDMABUFImageQueryMESA = functions[119]; + eglExportDMABUFImageMESA = functions[120]; + eglSwapBuffersRegion2NOK = functions[121]; + eglQueryNativeDisplayNV = functions[122]; + eglQueryNativeWindowNV = functions[123]; + eglQueryNativePixmapNV = functions[124]; + eglPostSubBufferNV = functions[125]; + eglStreamImageConsumerConnectNV = functions[126]; + eglQueryStreamConsumerEventNV = functions[127]; + eglStreamAcquireImageNV = functions[128]; + eglStreamReleaseImageNV = functions[129]; + eglStreamConsumerGLTextureExternalAttribsNV = functions[130]; + eglStreamFlush = functions[131]; + eglQueryDisplayAttribNV = functions[132]; + eglSetStreamMetadataNV = functions[133]; + eglQueryStreamMetadataNV = functions[134]; + eglResetStreamNV = functions[135]; + eglCreateStreamSyncNV = functions[136]; + eglCreateFenceSyncNV = functions[137]; + eglDestroySyncNV = functions[138]; + eglFenceNV = functions[139]; + eglClientWaitSyncNV = functions[140]; + eglSignalSyncNV = functions[141]; + eglGetSyncAttribNV = functions[142]; + eglGetSystemTimeFrequencyNV = functions[143]; + eglGetSystemTimeNV = functions[144]; + eglBindWaylandDisplayWL = functions[145]; + eglUnbindWaylandDisplayWL = functions[146]; + eglQueryWaylandBufferWL = functions[147]; + eglCreateWaylandBufferFromImageWL = functions[148]; EGL10 = check_EGL10(ext); EGL11 = check_EGL11(ext); @@ -1089,6 +1095,7 @@ private EGLCapabilities(Set ext, long... functions) { EGL_EXT_device_persistent_id = check_EXT_device_persistent_id(ext); EGL_EXT_device_query = check_EXT_device_query(ext); EGL_EXT_device_query_name = ext.contains("EGL_EXT_device_query_name"); + EGL_EXT_display_alloc = check_EXT_display_alloc(ext); EGL_EXT_explicit_device = ext.contains("EGL_EXT_explicit_device"); EGL_EXT_gl_colorspace_bt2020_hlg = ext.contains("EGL_EXT_gl_colorspace_bt2020_hlg"); EGL_EXT_gl_colorspace_bt2020_linear = ext.contains("EGL_EXT_gl_colorspace_bt2020_linear"); @@ -1326,6 +1333,12 @@ private boolean check_EXT_device_query(Set ext) { )); } + private boolean check_EXT_display_alloc(Set ext) { + return ext.contains("EGL_EXT_display_alloc") && checkExtension("EGL_EXT_display_alloc", checkFunctions( + eglDestroyDisplayEXT + )); + } + private boolean check_EXT_image_dma_buf_import_modifiers(Set ext) { return ext.contains("EGL_EXT_image_dma_buf_import_modifiers") && checkExtension("EGL_EXT_image_dma_buf_import_modifiers", checkFunctions( eglQueryDmaBufFormatsEXT, eglQueryDmaBufModifiersEXT diff --git a/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EXTDisplayAlloc.java b/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EXTDisplayAlloc.java new file mode 100644 index 0000000000..f71cee8d03 --- /dev/null +++ b/modules/lwjgl/egl/src/generated/java/org/lwjgl/egl/EXTDisplayAlloc.java @@ -0,0 +1,63 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + * MACHINE GENERATED FILE, DO NOT EDIT + */ +package org.lwjgl.egl; + +import org.lwjgl.system.*; + +import static org.lwjgl.system.Checks.*; +import static org.lwjgl.system.JNI.*; + +/** + * Native bindings to the EXT_display_alloc extension. + * + *

The existing semantics of {@code EGLDisplay} object lifetimes work well for applications in which one module manages all EGL usage, and in which EGL + * displays and the underlying native displays are expected to remain available until application termination once they are instantiated. However, EGL + * does not provide reasonable semantics for the following use cases:

+ * + *
    + *
  1. Applications that rely on toolkit libraries which use EGL independently from the application itself.
  2. + *
  3. Applications that use multiple native display objects with EGL and wish to completely release resources associated with EGLDisplay objects they no + * longer need.
  4. + *
  5. Platforms where the native display connection can be closed, such as X11 or Wayland. If the native display is closed, then there's no possible + * reasonable behavior for an EGLDisplay.
  6. + *
+ * + *

This extension solves these problems by adding the ability to create multiple unique, unshared {@code EGLDisplay} objects from the same native display, + * and to destroy those {@code EGLDisplay} objects when the caller no longer needs them.

+ */ +public class EXTDisplayAlloc { + + /** Accepted as an attribute in the {@code attrib_list} parameter of {@link EGL15#eglGetPlatformDisplay GetPlatformDisplay} and the {@code name} parameter of {@link EXTDeviceQuery#eglQueryDisplayAttribEXT QueryDisplayAttribEXT}. */ + public static final int EGL_ALLOC_NEW_DISPLAY_EXT = 0x3379; + + protected EXTDisplayAlloc() { + throw new UnsupportedOperationException(); + } + + // --- [ eglDestroyDisplayEXT ] --- + + /** + * Destroys an {@code EGLDisplay} handle. + * + *

If {@code dpy} is initialized, or if it is current to one or more threads, then is is marked for deletion, and it will be destroyed when it is + * terminated and no longer current.

+ * + *

After {@code dpy} is destroyed, it is not valid to pass to any EGL function. Subsequent calls to {@link EGL15#eglGetPlatformDisplay GetPlatformDisplay} may re-use the EGLDisplay handle + * value for new displays.

+ * + *

If {@code dpy} was not created with the {@link #EGL_ALLOC_NEW_DISPLAY_EXT ALLOC_NEW_DISPLAY_EXT} attribute set to {@link EGL10#EGL_TRUE TRUE}, then an {@link EGL10#EGL_BAD_ACCESS BAD_ACCESS} error is generated.

+ */ + @NativeType("EGLBoolean") + public static boolean eglDestroyDisplayEXT(@NativeType("EGLDisplay") long dpy) { + long __functionAddress = EGL.getCapabilities().eglDestroyDisplayEXT; + if (CHECKS) { + check(__functionAddress); + check(dpy); + } + return callPI(dpy, __functionAddress) != 0; + } + +} \ No newline at end of file diff --git a/modules/lwjgl/egl/src/templates/kotlin/egl/templates/EXT_display_alloc.kt b/modules/lwjgl/egl/src/templates/kotlin/egl/templates/EXT_display_alloc.kt new file mode 100644 index 0000000000..1e3ea449b7 --- /dev/null +++ b/modules/lwjgl/egl/src/templates/kotlin/egl/templates/EXT_display_alloc.kt @@ -0,0 +1,56 @@ +/* + * Copyright LWJGL. All rights reserved. + * License terms: https://www.lwjgl.org/license + */ +package egl.templates + +import egl.* +import org.lwjgl.generator.* + +val EXT_display_alloc = "EXTDisplayAlloc".nativeClassEGL("EXT_display_alloc", postfix = EXT) { + documentation = + """ + Native bindings to the $registryLink extension. + + The existing semantics of {@code EGLDisplay} object lifetimes work well for applications in which one module manages all EGL usage, and in which EGL + displays and the underlying native displays are expected to remain available until application termination once they are instantiated. However, EGL + does not provide reasonable semantics for the following use cases: + ${ol( + "Applications that rely on toolkit libraries which use EGL independently from the application itself.", + """ + Applications that use multiple native display objects with EGL and wish to completely release resources associated with EGLDisplay objects they no + longer need. + """, + """ + Platforms where the native display connection can be closed, such as X11 or Wayland. If the native display is closed, then there's no possible + reasonable behavior for an EGLDisplay. + """ + )} + + This extension solves these problems by adding the ability to create multiple unique, unshared {@code EGLDisplay} objects from the same native display, + and to destroy those {@code EGLDisplay} objects when the caller no longer needs them. + """ + + IntConstant( + "Accepted as an attribute in the {@code attrib_list} parameter of #GetPlatformDisplay() and the {@code name} parameter of #QueryDisplayAttribEXT().", + + "ALLOC_NEW_DISPLAY_EXT"..0x3379 + ) + + EGLBoolean( + "DestroyDisplayEXT", + """ + Destroys an {@code EGLDisplay} handle. + + If {@code dpy} is initialized, or if it is current to one or more threads, then is is marked for deletion, and it will be destroyed when it is + terminated and no longer current. + + After {@code dpy} is destroyed, it is not valid to pass to any EGL function. Subsequent calls to #GetPlatformDisplay() may re-use the EGLDisplay handle + value for new displays. + + If {@code dpy} was not created with the #ALLOC_NEW_DISPLAY_EXT attribute set to #TRUE, then an #BAD_ACCESS error is generated. + """, + + EGLDisplay("dpy", "") + ) +} \ No newline at end of file